Is post mai calculator bnane ka bhut hi simple C program bnaya hai (Making C program for calculator). Agar app beginner hai to is c program se apke kafi doubt bhi clear ho jayege. Calculator ke liye program bnana ek useful trick hai.
Is program se ham Addition(+), Subtraction(-), Multiplication(x), Division(/) bhut asani se kar skte hai.
Calculator ke lye program ham switch statement ka use karke bnayege.
Mene yah program Dev C++ software mai bnaya hai.
C Programming for Calculator :
(1). Calculator का C Program |
Calculator ke lye program ham switch statement ka use karke bnayege.
Mene yah program Dev C++ software mai bnaya hai.
C Programming for Calculator :
This code prepared by Electronics & Technology (Rajendra singh), www.elextechnologys
#include<stdio.h>
int main()
{
int number_1, number_2; // ये integer वेरिएबल हैं
float Answer; // ये float वेरिएबल हैं
char operation; //to store operator choice, char वेरिएबल
printf("Enter first number: ");
scanf("%d",&number1);
printf("Enter second number: ");
scanf("%d",&number2);
printf("Choose operation to perform (+,-,*,/,%): ");
scanf(" %c",&operation);
result=0;
switch(operation)
{
case '+': // जोड़
Answer =number_1+number_2;
break;
case '-': // घटाना
Answer = number_1-number_2;
break;
case '*': // गुणा
Answer = number_1*number_2;
break;
case '/': // भाग
Answer = number_1/number_2;
break;
case '%': //भाग का शेषफल
Answer = number_1%number_2;
break;
default: // गलत key press होने पर
printf("Invalid operation.\n");
}
printf("Result: %d %c %d = %f\n",number_1,operation,number_2,operation);
return 0;
} // 🙏🙏🙏🙏🙏🙏🙏 प्रोग्राम खत्म हुआ
Calculator bnane ke liye apko iss code ko copy past krna hoga. Iske bad ise run krna hoga. Run hone pe apko do value print krani hogi iske bad jo bhi operation (+, -, *, /, %) krna use print krna hoga jiska result display mai show ho jayega.
Also read Make a C program for Ohm's Low
Output
First round run
Enter first number: 25
Enter second number: 15
Choose operation to perform (+, -, *, /, %): '+'
Result : 25+15 = 40.000
Second round run
Enter first number: 20
Enter second number: 5
Choose operation to perform (+, -, *, /, %): '*'
Result : 25*15 = 375.000
Upper diya huaa C program ko Switch Statement ka use krke bnana gya hai. Ye program bhut hi simple hai.
Also read
Also read
First Microprocessor of India
Electronics क्या है ?
Sensor
Different types of Measuring instruments
Dear readers if you have any question and suggestions related to my any post or My site (Electronics & Technology) so you can leave message in comment box. I will try to give answer of your questions in short time.
Sensor
Different types of Measuring instruments
Dear readers if you have any question and suggestions related to my any post or My site (Electronics & Technology) so you can leave message in comment box. I will try to give answer of your questions in short time.
Please share my post link and Follow
Thank you very much