Calculator Projects in C Programming with Source code | Projects By TechWithCode

 If you learning C programming and looking for some project then you are in the right place. This Calculator project will be very useful to boost your programming knowledge


This is a Calculator project which is developed in C programming, Today I will give you the full explanation with source code and output.


If you get helped by this article then please let's know in the comment section below and follow us on social media for regular updates.

Project Detail:-

Project Name: Calculator

Language:  C programming

Concept:     1. Functions with Argument

                   2. Switch Case

                   3. goto statement

Source Code of Calculator Project:-

#include<stdio.h>
#include<stdlib.h>
void add(int x,int y)
{
printf("sum in %d\n",x+y);
return;
}
void sub(int x,int y)
{
printf("difference in %d\n",x-y);
return;
}
void prod(int x,int y)
{
printf("product in %d\n",x*y);
return;
}
void quat(int x,int y)
{
printf("quatient in %d\n",x/y);
return;
}
void rem(int x,int y)
{
printf("remainder in %d\n",x%y);
return;
}
main()
{
int a,b,op;
start:
      printf("Enter two integer\n");
scanf("%d%d",&a,&b);
printf("What do you want to do:\n\n\nAddition-----> 1\nSubtraction----> 2\nMultiplication---> 3\nQuatient----> 4\nRemainder----> 5\nExit------> 0\n");
scanf("%d",&op);
switch (op)
{
case 1: add(a,b); break;
case 2: sub(a,b); break;
case 3: prod(a,b); break;
case 4: quat(a,b); break;
case 5: rem(a,b); break;
case 0: return 0;
defualt: printf("wrong input\n");
}
system("pause");
system("cls");
goto start;
system("pause");
return 0;
}


Explanation of the above code:-

In this program, first, we take two integer values to perform the operation, then show the option to the user and ask to chose the option. then we use a switch case to call the functions to perform the selected task. During the calling of the function, we pass the integer values which are taken from the user. we repeat the whole process using goto statement


The output of the above code:-





No comments:

Do not add any link in the comments.
For backlink, contact us.

Powered by Blogger.