Calculater using c language.
Calculater using c language
This blog introduce you to concept of making simple calculater using c language.It is the simple code
that everyone should know.
Following method has used inside the programme
- Take two input from user for performing the operation.
- Display the message for which operation user want to operate on input.
- Use conditional operation(switch statement) for operation.
- Take the input from user and perform the operation accordingly.
Simple calculater
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,result,op;
printf("Enter first number\n");
scanf("%d",&a);
printf("Enter second number\n");
scanf("%d",&b);
printf("Which operation you want to operate\n");
printf("1.add, 2.subs,3.dic,4.multi\n");
printf("Enter your choice\n");
scanf("%d",&op);
switch(op)
{
case 1:result=a+b;
printf("Result is %d",result);
break;
case 2:result=a-b;
printf("Result is %d",result);
break;
case 3:result=a/b;
printf("Result is %d",result);
break;
case 4:result=a*b;
printf("Result is %d",result);
break;
default:printf("Enter valid option\n");
}
getch();
}
Calculater using c language.
Reviewed by Deepak kumar soni
on
December 19, 2018
Rating:
Nice.
ReplyDelete