C Program For Arithmetic Calculator using if else ladder(2 operands 1 operator frm user)

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,opt;
l: printf("enter the following option");
printf("\n1.add\n2.asub\n3.mul\n4.exit");
scanf("%d",&opt);
if(opt==1)
{
printf("enter first operand");
scanf("%d",&a);
printf("enter second operand");
scanf("%d",&b);
printf("a+b=%d",a+b);
}
else if(opt==2)
{
printf("enter the 1operand");
scanf("%d",&a);
printf("enter 2nd operand");
scanf("%d",&b);
printf("a-b=%d",a-b);
}
else if(opt==3)
{
printf("enter the 1st value");
scanf("%d",&a);
printf("enter the 2nd value");
scanf("%d",&b);
printf("\n a*b=%d",a*b);
}
else if(opt==4)
exit(0);
else
printf("\nwrong option\n");
goto l;
getch();
}




Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

1 comment:

  1. good work bro but you put the longer way to do the programming

    ReplyDelete