JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

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>
#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;
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];
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];
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 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;
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;
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;
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;
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);
}
Sbistudy

Recent Posts

सारंगपुर का युद्ध कब हुआ था ? सारंगपुर का युद्ध किसके मध्य हुआ

कुम्भा की राजनैतिक उपलकियाँ कुंमा की प्रारंभिक विजयें  - महाराणा कुम्भा ने अपने शासनकाल के…

4 weeks ago

रसिक प्रिया किसकी रचना है ? rasik priya ke lekhak kaun hai ?

अध्याय- मेवाड़ का उत्कर्ष 'रसिक प्रिया' - यह कृति कुम्भा द्वारा रचित है तथा जगदेय…

4 weeks ago

मालकाना का युद्ध malkhana ka yudh kab hua tha in hindi

malkhana ka yudh kab hua tha in hindi मालकाना का युद्ध ? मालकाना के युद्ध…

2 months ago

कान्हड़देव तथा अलाउद्दीन खिलजी के संबंधों पर प्रकाश डालिए

राणा रतन सिंह चित्तौड़ ( 1302 ई. - 1303 ) राजस्थान के इतिहास में गुहिलवंशी…

2 months ago

हम्मीर देव चौहान का इतिहास क्या है ? hammir dev chauhan history in hindi explained

hammir dev chauhan history in hindi explained हम्मीर देव चौहान का इतिहास क्या है ?…

3 months ago

तराइन का प्रथम युद्ध कब और किसके बीच हुआ द्वितीय युद्ध Tarain battle in hindi first and second

Tarain battle in hindi first and second तराइन का प्रथम युद्ध कब और किसके बीच…

3 months ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now