0% found this document useful (0 votes)
12 views1 page

CALCU

This C program allows a user to perform basic mathematical operations like addition, subtraction, multiplication, division, modulus, power and factorial on two integers. The user is prompted to enter an integer, operation and another integer, then the result is displayed. This continues in a loop until the user enters 'A' to stop the program.

Uploaded by

SALAH ADIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

CALCU

This C program allows a user to perform basic mathematical operations like addition, subtraction, multiplication, division, modulus, power and factorial on two integers. The user is prompted to enter an integer, operation and another integer, then the result is displayed. This continues in a loop until the user enters 'A' to stop the program.

Uploaded by

SALAH ADIN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <stdio.

h>
#include <stdlib.h>
#include<math.h>
int main()
{
int A,B,F,N;
char O,stop;
printf("Addition:'+'\nSoustraction:'-'\nMultiplication:'*'\nDivision:'/'\nReste
de la division entiere:'%%'\nPuissance:'^'\nFactorielle:'!'\n");
do{
printf("Entrer entier1:");
scanf("%d",&A);
printf("Choisir l'operation:");
scanf(" %c",&O);
printf("Entrer entier2:");
scanf("%d",&B);
switch (O){
case'+': printf("%.2d+%.2d=%.2d\n",A,B,A+B);
break;
case'-': printf("%.2d-%.2d=%.2d\n",A,B,A-B);
break;
case'*': printf("%.2d*%.2d=%.2d\n",A,B,A*B);
break;
case'/': if (B!=0){printf("%.2d/%.2d=%.2d\n",A,B,A/B);}
else {do{printf("Entrez nombre2 different de 0\
n");scanf("%d",&B);}while(B==0);
printf("%.2d/%.2d=%.2d\n",A,B,A/B);};
break;
case'%': printf("Reste de division de %.2d/%.2d=%.2d\n",A,B,A%B);
break;
case'^': printf("%.2d^%.2d=%.2f\n",A,B,pow(A,B));
break;
case'!': if (A>=0){F=1;for(N=1;N<=A;N++){F=F*N;}printf("%d!=%d\n",A,F);}
else {do{printf("Entrer nombre1 superieur ou egale a 0\
n");scanf("%d",&A);}while(A<=0);
F=1;for(N=1;N<=A;N++){F=F*N;}printf("%d!=%d\n",A,F);}
if (B>=0){F=1;for(N=1;N<=B;N++){F=F*N;}printf("%d!=%d\n",B,F);}
else {do{printf("Entrer nombre2 superieur ou egale a 0\
n");scanf("%d",&B);}while(B<=0);
F=1;for(N=1;N<=B;N++){F=F*N;}printf("%d!=%d\n",B,F);}
break;
default: printf("Error!!\n");
break;
}
printf("Pour arreter programme entrer A\nPour continue saisir une lettre
different de A\n");
scanf(" %c",&stop);}while(stop!='A');
return 0;
}

You might also like