SIMPLE CALCULATOR USING C
- Get link
- X
- Other Apps
#include<stdio.h>
void main()
{
int a,b,c,e;
char d;
do
{
printf("Enter your choice:\n");
printf("MENU\n");
printf("1:Add\n2:sub\n3:mult\n4:div\n");
scanf("%d",&a);
switch(a)
{
case 1:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b+c;
printf("the sum between %d and%d is %d",b,c,e);
break;
case 2:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b-c;
printf("the diffrence between %d and%d is %d",b,c,e);
break;
case 3:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b*c;
printf("the multiplication between %d and%d is %d",b,c,e);
break;
case 4:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b/c;
printf("The division between %d and%d is %d",b,c,e);
break;
default:
printf("please enter valid input\n");
}
printf("\ndo you want to continue(y/n):");
scanf("%s",&d);
}while (d=='y');
}

void main()
{
int a,b,c,e;
char d;
do
{
printf("Enter your choice:\n");
printf("MENU\n");
printf("1:Add\n2:sub\n3:mult\n4:div\n");
scanf("%d",&a);
switch(a)
{
case 1:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b+c;
printf("the sum between %d and%d is %d",b,c,e);
break;
case 2:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b-c;
printf("the diffrence between %d and%d is %d",b,c,e);
break;
case 3:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b*c;
printf("the multiplication between %d and%d is %d",b,c,e);
break;
case 4:
printf("Enter 2 numbers:");
scanf("%d %d",&b,&c);
e=b/c;
printf("The division between %d and%d is %d",b,c,e);
break;
default:
printf("please enter valid input\n");
}
printf("\ndo you want to continue(y/n):");
scanf("%s",&d);
}while (d=='y');
}

- Get link
- X
- Other Apps
Popular posts from this blog
FIND NUMBER OF VOWELS IN A STRING
FIND NUMBER OF VOWELS IN A STRING c=raw_input("Enter A String:") b=c.lower() x=0 for letter in b: if letter in "aeiou": x+=1 print "Total Number Of Vowels = " + str(x) print "Number Of Vowels In Each" d,e,f,g,h=0,0,0,0,0 for letter in b: if letter in "a": d+=1 print "a=" +str(d) for letter in b: if letter in "e": e+=1 print "e=" +str(e) for letter in b: if letter in "i": f+=1 print "i=" +str(f) for letter in b: if letter in "o": g+=1 print "o=" +str(g) for letter in b: if letter in "u": h+=1 print "u=" +str(h) OUTPUT
TO FIND EVEN NUMBERS UP TO N
ENTERED NUMBER IS PRIME OR NOT
ENTERED NUMBER IS PRIME OR NOT n=int(input("enter a number:")) if n<0: print "enter a valid input" elif n<2: print "neither prime nor composite" else: for i in range(2,n/2): if(n%i)==0: print n,"is not a prime number" break else: print n,"is a prime number" OUTPUT --------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment