How to Make Calculator In C Language
How to make calculatoR in C Lanuguage
#include<stdio.h>
#include<conio.h>
main()
{
float num1;
float num2;
char opt;
float result;
clrscr();
printf("enter the first number:");
scanf("%f",&num1);
printf("enter the operation:");
scanf(" %c",&opt);
printf("enter the second number:");
scanf("%f",&num2);
switch(opt)
{
case'-':
result =num1-num2;
printf("%f",result);
break;
case'+':
result =num1+num2;
printf("%f",result);
break;
case'*':
result =num1*num2;
printf("%f",result);
break;
case'/':
result =num1/num2;
printf("%f",result);
break;
default :
printf("the operator is not valid");
}
getch();
}
#HS_Creations
#Kepp_Visiting
#include<stdio.h>
#include<conio.h>
main()
{
float num1;
float num2;
char opt;
float result;
clrscr();
printf("enter the first number:");
scanf("%f",&num1);
printf("enter the operation:");
scanf(" %c",&opt);
printf("enter the second number:");
scanf("%f",&num2);
switch(opt)
{
case'-':
result =num1-num2;
printf("%f",result);
break;
case'+':
result =num1+num2;
printf("%f",result);
break;
case'*':
result =num1*num2;
printf("%f",result);
break;
case'/':
result =num1/num2;
printf("%f",result);
break;
default :
printf("the operator is not valid");
}
getch();
}
#HS_Creations
#Kepp_Visiting
Comments
Post a Comment