advertisements
السلام عليكم
التمرين :
حل التمرين :
SalahEddine Loukili الحل تم وضعه من طرف
#include "stdio.h" #include "conio.h" main() { float x,y; char c; printf("\nEnter the first number :"); scanf("%f",&x); printf("Enter an operation \"+ or - or * or / or %%\" :"); fflush(stdin); // empy stdin so we can take value from user keyboard c=getchar(); // c=getch() c=getche() printf("\nEnter the second number :"); scanf("%f",&y); switch (c) { case '*' : printf(" %g * %g = %g",x,y,x*y); break; case '+' : printf(" %g + %g = %g",x,y,x+y); break; case '-' : printf(" %g - %g = %g",x,y,x-y); break; case '/' : printf(" %g / %g = %g",x,y,x/y); break; case '%' : if(x-(int)x!=0||y-(int)y!=0) { printf("% require integer valus:auto convert to int...\n"); } if((int)y==0) { printf(" %d mod %d = %d",(int)x,(int)y,(int)x); } else printf(" %d mod %d = %d",(int)x,(int)y,(int)x%(int)y); break; default : printf("operation invalide"); } getch(); }
في أمان الله
0 commentaires :
Publier un commentaire