google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program for simple calculator using if else - 2nd puc computer science

Write a c program for simple calculator using if else

Write a c program for simple calculator using if else

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b;

char op;

clrscr();

printf("Choose the operator\n+ Addition\n- Difference\n* Product\n/ Division\nEnter the operator: ");

scanf("%c",&op);

printf("Enter two numbers:\n");

scanf("%d%d",&a,&b);

if(op=='+')

printf("%d+%d=%d",a,b,a+b);

else if(op=='-')

printf("%d-%d=%d",a,b,a-b);

else if(op=='*')

printf("%d*%d=%d",a,b,a*b);

else if(op=='/')

printf("%d/%d=%f",a,b,(float)a/b);

else

printf("Error in operator");

getch();

}

Write a c program for simple calculator using if else Write a c program for simple calculator using if else Reviewed by Vision Academy on January 09, 2022 Rating: 5

No comments:

CheckOut

Powered by Blogger.