हिंदी माध्यम नोट्स
Categories: C Language in hindi
Calculator project in c language in hindi कैलकुलेटर का c भाषा में प्रोजेक्ट का प्रोग्राम कैसे बनता है हिंदी में सीखे
कैलकुलेटर का c भाषा में प्रोजेक्ट का प्रोग्राम कैसे बनता है हिंदी में सीखे Calculator project in c language in hindi :-
Calculator C language का बहुत basic और easy प्रोजेक्ट है | इसके source code को बनाने के लिए सभी mathematical operation के basic लॉजिक पता चलेगा |
Explanation
इस प्रोग्रम को छोटे subprogram मे डिवाइड करते है ये void add(),void sub(),void mul(),void div(),void mod(),void power(),void fac() और void cal_op() होते है |’
int main();
ये function प्रोग्रम्म का heart है क्योकि यूजर द्वारा दिए गये input के आधार कोनसा operation perform करना है |इसका decision होता है |इस function मे void cal_op(); से input लिया जाता है |
इसमें 10 operation हो सकते है :-
1. addition के लिए input ‘+’ होगा |
2.subtraction के लिए ‘-‘ होगा |
3.multiplication के लिए ‘*’ होगा |
4.division के लिए के ‘/’ होगा |
5.reminder के लिए के ‘%’ होगा |
6.power के लिए ‘^’ होगा |
7.factorial के लिए ‘!’
8.Quite करने के लिए ‘Q’ को choose करना होता है जिससे exit(0) का statement perform होता है |और प्रोग्राम close हो जाता है |exit(0), stdlib.h का एक sepecial function है जिससे application या आउटपुट screen terminate हो जाती है |
9. display के लिए ,input ‘H’ होगा |इसको choose करने पर cal_op(); perform हो जाता है |
10. clear screen करने के लिए ,input ‘C’ होगा |इसो choose करने पर आउटपुट स्क्रीन clear हो जाती है |
इन सभी input को switch statement मे ‘case’ बना कर ,इससे सम्बदित function को call किया गया है |
जैसे input ‘+’ होने पर add() को call किया गया है |
और input ‘*’ होने पर mul() को call किया गया है |
switch () statement को while loop मे चलाया गया है जिसकी condition always true यानि ‘1’ है जिससे की switch statement बार बार चलेगा जब तक की exit(0) या ‘Q’ input ना आये |
cal_op();
इस function मे , यूजर को general information जैसे options के बारे मे बताया गया है|
add() और mul() :
addition perform करने का लॉजिक इस function मे है |यूजर से input की number को variable ‘n’ मे store करा दिता जाता है |
फिर user से number की माग की जाती है जब यूजर number enter कर देता है ,तब उन सभी numbers को array ‘num[]’ मे read कर लिया जाता है |
फिर for loop मे i<n की condition के साथ सभी array के element को add करके sum मे स्टोर कर देते है |
multiplication function का लॉजिक भी यही होता है लेकिनoperator change हो जाता है |इसके function का नाम है mul();|
div(),sub(),mod(),pow():
इन सभी function मे यूजर से केवल दो inputs लेकर operation perform कराया गया है |
pow() मे predefine function pow() को use किया गया है जिसकी header file math.h है |
fac():
इस function मे , केवल एक input लेकर उसका factorial calculate किया गया है |
जैसे 5!=5*4*3*2*1
इसमें एक for loop चलाया गया जिसमे हर एक बार i की value को आउटपुट के साथ multiply किया गया है |जिसे
fac*i=1*1=1
fac*i=1*2=2
fac*i=2*3=6
fac*i=6*4=24
fac*i=24*5=120
factorial of 5 is 120.
Source Code:
#include<stdio.h>
#incliude<conio.h>
#incliude<conio.h>
#include<math.h>
#include<stdlib.h>
void add();
void sub();
void mul();
void div();
void mod();
void power();
void fac();
void cal_op();
int main()
{
int a=1;
int a=1;
char cal;
cal_op();
while(a)
{
cal=getche();
switch(cal)
{
case ‘+’:add();
break;
case ‘-‘:sub();
break;
case ‘*’:mul();
break;
case ‘/’:div();
break;
case ‘%’:mod();
break;
case ‘!’:fac();
break;
case ‘^’:pow();
break;
case ‘H’:cal_op();
break;
case ‘Q’:exit(0)
break;
case ‘C’:system(“cls”);
cal_op();
break;
default:system(“cls”);
printf(“Unavailable option “);
printf (“******************\n”);
printf(“Please Enter among available options”);
cal_op();
}
}
}
}
void cal_op()
{
printf(“\n Welcome Calculator \n \n”);
printf(“For Quit ,choose ‘Q’ “);
printf(For Display,Choose ‘H’ “);
printf(“For Clear Screen,choose ‘C'”);
printf(“\n\n”);
printf(“For Addition,choose ‘+'”);
printf(“For Subtraction,choose ‘-‘”);
printf(“For Multiplication,choose ‘*'”);
printf(“For Division,choose ‘/'”);
printf(“For Reminder,choose ‘%'”);
printf(“For Power,choose ‘^'”);
printf(“For Factorial,choose ‘!'”);
}
void add()
{
int n,sum=0,i=0,num[100];
int n,sum=0,i=0,num[100];
printf(“Enter Number of Values that you want to add(Maximum Limit of number is 100)\n”);
scnaf(“%d”,&n);
printf(“Enter your numbers \n”);
for(i=0;i<=n;i++)
{
scnaf(“%d”,&num[i]);
}
for (i=0;i<n;i++)
{
sum=sum+num[i];
}
printf(“Sum of your digit is %d”,sum);
}
void mul()
{
int n,i=0,num[100];
int n,i=0,num[100];
lon int mul;
printf(“Enter Number of Values that you want to multiply(Maximum Limit of number is 100)\n”);
scnaf(“%d”,&n);
printf(“Enter your numbers \n”);
for(i=0;i<=n;i++)
{
scnaf(“%d”,&num[i]);
}
for (i=0;i<n;i++)
{
mul=mul*num[i];
}
printf(“Multiplication of your digit is %d”,mul);
}
void sub()
{
int a,b,diff;
int a,b,diff;
int choice;
printf(“Enter your first digit :”)
scanf(“%d”,&a);
printf(“Enter your second digit :”)
scanf(“%d”,&b);
printf(“For ‘a-b’ , Enter ‘1’ or For ‘b-a’ , Enter ‘2’”);
scnaf(“%d”,&choice);
if(Choice==’1′)
{
diff=a-b;
printf(“Difference is %d”,diff);
}
else
{
diff=b-a;
printf(“Difference is %d”,diff);
}
}
void div()
{
int a,b,div;
int a,b,div;
printf(“Enter your first digit :”)
scanf(“%d”,&a);
printf(“Enter your second digit :”)
scanf(“%d”,&b);
if(a>b)
{
div=a/b;
printf(“Division is %d”,div);
}
else
{
diff=b/a;
printf(“Division is %d”,div);
}
}
void mod()
{
int a,b,mod;
int a,b,mod;
printf(“Enter your first digit :”)
scanf(“%d”,&a);
printf(“Enter your second digit :”)
scanf(“%d”,&b);
if(a>b)
{
mod=a%b;
printf(“Reminder of %d / %d is %d”,a,b,mod);
}
else
{
mod=b%a;
printf(“Reminder of %d / %d is %d”,b,a,mod);
}
}
void pow()
{
int a,b,pow;
int a,b,pow;
printf(“Enter base value:”)
scanf(“%d”,&a);
printf(“Enter power :”)
scanf(“%d”,&b);
pow=pow(a,b);
printf(“Power is %d”,pow);
}
void fac()
{
int a,i,fac=1;
int a,i,fac=1;
printf(“Enter number that you want to calculate factorial”);
scanf(“%d”,a);
if(a<0)
{
printf(“Please Enter a valid number”);
return 1;
}
else
{
for(i=0;i<a;i++)
{
fac=fac*i;
}
printf(“Factorial is %d”,fac);
}
Recent Posts
सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है
सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…
1 day ago
मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the
marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…
1 day ago
राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi
sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…
3 days ago
गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi
gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…
3 days ago
Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन
वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…
3 months ago
polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten
get all types and chapters polity notes pdf in hindi for upsc , SSC ,…
3 months ago