Subscribe For Free Updates!

We'll not spam mate! We promise.

Wednesday, 6 April 2016

How to make a console calculator in programming in urdu

C language is a very famous language in the market. Everyone wants to learn C program because C language is an only one language which is the base of every successful programmer. Some days ago I have posted a complete course of C programming in Urdu and Hindi language. This course contains more than 25 video lectures. So you can watch this course. 

As I tell you that in the C programming course that first we learn about basic functionalities of C programming and then we will move on the projects section. So we have successfully completed our course and now the time is to move on the projects section. This is the first project of our course. In this project I will teach you that how you can easily make a console calculator. This calculator has complete functionalities like getting sum result, multiplication result, division result, and also subtraction result of any numbers.  

What is the functionalities of this calculator program

This calculator program can apply any function like plus, minus, multiply and divide. It collects three inputs from user on run time first input is “Value 1” and second input is “operation (plus minus etc)” and third is “value 2”.If the user enters the sign “+” then it will display the sum of both these values. Simply it depends on the mathematical operation which is enters by the user. If the user applies an invalid value then system performs beep sound. 

How to make this calculator?

1) Write the basic structure of C program.
2) Get three variables two integer and one character name as int value1, value2 and char operation.
3) Get input from the user by using printf() and scanf() function.
4) Start switch statement
5) Pass it the char variable “operation”.
6) Inside the curly braces write the below conditions.

switch(operation){
                                case '+':
                                                printf("The result is:%d",val1+val2);
                                break;        
                                case '-':
                                                printf("The result is:%d",val1-val2);
                                break;
                                case '*':
                                                printf("The result is:%d",val1*val2);
                                break;
                                case '/':
                                                printf("The result is:%d",val1/val2);
                                break;
                                default:
                                                printf("Invalid input!\a");
                                               
                }

After doing that compile your program and run. And your program it ready. Let’s use this program by performing different values and operation. And enjoy!

Watch This video How to make a console calculator in C programming

The source code of this program is:-

//This is a calculator program
#include<stdio.h>
#include<conio.h>
int main(){
                int val1,val2;
                char operation;
                printf("Enter value 1:");
                scanf("%d",&val1);
                printf("Enter operation:");
                scanf("%s",&operation);
                printf("Enter value 2:");
                scanf("%d",&val2);
               
                switch(operation){
                                case '+':
                                                printf("The result is:%d",val1+val2);
                                break;
                                case '-':
                                                printf("The result is:%d",val1-val2);
                                break;
                                case '*':
                                                printf("The result is:%d",val1*val2);
                                break;
                                case '/':
                                                printf("The result is:%d",val1/val2);
                                break;
                                default:
                                                printf("Invalid input!\a");
                                               
                }
getch();
}

I hope you enjoy this tutorial. If you have any question then please asks your question in comment box and we will reply you very soon. So at the end of this tutorial I will tell that please like comment and join our site for later updates and new tutorials. In some days I’m going to start a online money making course for everyone. So that’s why please join our site.

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

1 comments:

  1. Casino, Hotel and Racetrack - Mapyro
    The casino includes a casino, a restaurant, an 경상북도 출장샵 outdoor swimming pool, 동해 출장샵 and a bowling alley. A short 전라북도 출장마사지 drive from the casino, 경주 출장샵 the property offers 동두천 출장마사지 bowling,

    ReplyDelete