16-06-2010, 12:02 AM
|
#6
|
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
|
رد: نموذج اختبار نهائي برمجة202 ,,,,
بسم الله الرحمن الرحيم
السلام عليكم ورحمة الله وبركاته
تنفيذاً لطلب أحد الأخوة ,, هذه حلول السؤال ما قبل الأخير والأخير :
حل Part IV :
كود PHP:
#include <stdio.h> void inverses(char *input, int size) { int MaxIndex; for (MaxIndex=0; MaxIndex<size; MaxIndex++) { if (input[MaxIndex] == '\n') break; } //print for( ; MaxIndex >= 0; MaxIndex--) { printf("%c",input[MaxIndex]); } printf("\n"); } int main () { char x[100]; int i; //input printf("Enter numbers or characters: "); for (i=0; i < 100; i++) { scanf("%c",&x[i]); if (x[i] == '\n') break; } // call inverses function inverses(x,100); return (0); }
حل السؤال Part V :
كود PHP:
#include <stdio.h> float discount (float x) { if (x <= 1000) return (x - ((x * 10 )/100)); else if (x >= 1001 && x <= 2000) return (x - ((x * 20 )/100)); else return (x - ((x * 30 )/100)); } void pay (float item, int select) { float total; switch (select) { case 1: total = item * 1500; printf("price before discount : %f S.R.\n",total); printf("price after discount : %f S.R.\n",discount(total)); break; case 2: total = item * 750; printf("price before discount : %f S.R.\n",total); printf("price after discount : %f S.R.\n",discount(total)); break; case 3: total = item * 300; printf("price before discount : %f S.R.\n",total); printf("price after discount : %f S.R.\n",discount(total)); break; } } int main () { float x,price; int select; while (1) { printf("1- PC -> 1500 RS\n"); printf("2- Monitor (LCD) -> 750 RS\n"); printf("3- Printer -> 300 RS\n"); printf("4- Exit\n"); printf("What do you want: "); scanf("%d",&select); switch (select) { case 1: case 2: case 3: printf("how many do you want: "); scanf("%f",&x); pay(x,select); break; default: printf("Error!\n"); } if (select == 4) break; printf("\n\n"); } return (0); }
بالتوفيق .
|
|
سبحان الله وبحمد ,,, سبحان الله العظيم الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه . اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.
|
|
|
|