Search This Blog


Sunday, 7 July 2019

Calculator using C Programming || Easy and Fully Explained Learn C programming

Calculator using C Programming || Easy and Fully Explained Learn C programming


 Hey Guys Welcome back,So in this tutorial, We are explaining about how to make a simple calculator using C programming.

Which is Really simple to do,the code is easy and We are not using function but we are challenging you guys to send us your code.

We Will be Happy to Receive your codes.

So basically we are declaring some variables and then Asking for input from the user.

Then We have While(1) Loop which helps to make the loop continues until and unless the exit key is Pressed by the user.

Then We have Our SWITCH statements which help us to create Actions.

Here is the codes Explained video is also given below !


#include<stdio.h>
#inlcude<stdlib.h>

void main()
{
int num1,num2,ch;
clrscr();

while(1)
{
printf("1.Add");
printf("\nsub");
printf("\n mulit");
printf("\n divide");
printf("\n")
printf("enter num1=");
scanf("%d",&num1);
printf("\n enter num2=");
scanf("%d",&num2);
printf("enter choice");
scanf("%d",&ch);

    switch(ch)
     {
      case 1:answer=num1+num2;
        printf("%d",answer);
        break;


      case 2:answer=num1-num2;
        printf("%d",answer);
        break;


      case 3:answer=num1*num2;
        printf("%d",answer);
        break;

   
      case 4:answer=num2/num1;
        printf("%d",answer);
        break;

      default:exit(1);
      }

}

 

Explained Video !



s


Share this As much As Possible.

Make Sure to subscribe my Youtube channel.

No comments:

Post a Comment