Create Calculator in C programming

Create Calculator in C programming

Hello and welcome every one. I am Kusum for bca expert and today i will come you all to this tutorial 
section.  so in this blogger i want show you How you can builds  calculator  program in c .simple
and easiest way i will explain you. 

*Create Calculator in C programming Language in just 10 minutes with line by line code explanation

*Learn to Make Calculator using C Programming Language Full Easy Guide

How to Make Calculator using Programming Language Step By Step Coding Guide in English 
in This I Will Explain What is Switch Statement in computer programming Language ? and how we can make a simple calculator using c programming Language full Guide in English language if you are a computer student and learning programming language then you must know how to make calculator with the help of  switch statement in programming language.


How to create calculator in c programming??

So first of all you know the switch statement because in program we use the switch statement.

switch statement means Tests the values of a variable and compares the multiple cases.

so next we come to the program we use the code block you use the anther software like  

turbo c++ or dvc++.

so first i will write the program than i will explain Cleary step by step

program


#include<stdio.h>
#include<conio.h>
main()
{
 float num1;
 float num2;
 char op;
 float result;

printf("enter the first number:");
scanf("%f",&num1);

printf("enter the operation:");
scanf("%c",&op);

printf("enter the second number:");
scanf("%f",&num2);

switch(op)
{
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();

out put

enter the first number : 10
enter the operation : +
enter the second number: 10
20.0000

enter the first number:17
enter the operation: -
enter the second number:16
1.00000
 
So like that . so first we include the header file #include<stdio.h> and anther one is #include<conio.h>
so next we write the main function. so after that we include variables right. so float num1,and float num2, these are main two variable. so next one char op;

because we choose the operation like addition ,subscription, and multiplication or division so like that we choose operation. so next we write the float result .result means display .

next we print enter the first number and scanf %f and print the num1,
next we print the operation %c ,and print the second number and we write the scanf %f&num2

here we use the switch statement . in switch we use the CASE  so our first case is - ,in this we 
write num1-num2 like that .  
so like this we use anther +,*.\ in multiplication we use the star mark. its remember.

So lastly we add default : next we print the operation is not vailed :
so complete our calculator program. so i hope you like it . in any dotes in the  program you can comment the comment section .I will replay earliest.

So thanks for watching .like share subscribe to bca expert channel .Learn to more.  

thanks visit again 




 

0 Comments