Upcoming SlideShare
×

# Calculator using C language

7,775 views
7,379 views

Published on

5 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
7,775
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
138
0
Likes
5
Embeds 0
No embeds

No notes for slide

### Calculator using C language

1. 1. TO DESIGN A CALCULATOR USING C LANGUAGEBY- SAURABH KHETAN 1 2 3 + 4 5 6 - 7 8 9 * 0 = % /
2. 2.  Hello friends, my name is Saurabh Khetan. This time i am here with a presentation showing you to design your own calculator using a console application. The calculator over here is designed using a basic programming language i.e C language. Programming of the calculator is tested on the Microsoft visual C++ express. It is a software use to code the C programs. As I have mentioned in my earlier presentation of prime numbers, the same program can be coded, compiled and executed in turbo C++ as well.
3. 3.  Our calculator is a simple calculator capable of performing operations on two numbers. The numbers might be decimal or non-decimal. User is allowed to enter the desired numbers and the result will be displayed on the screen. The calculator will perform four basic operations of addition, subtraction, multiplication and division. The students interested in software engineering and want to learn basic programming and build their logic may find this program interesting. The program is constructed using switching method in C language.
4. 4.  The switching method in C language provides an option to the user which operation he desires to perform. Thus, a program wherein there are too many options listed, the user can select a particular option and obtain the result of that operation. The switch case in C programming can be done using a very simple set of syntaxes. Now we move to our first switch case program in C language. It will clarify our doubts about the design of our C program.
5. 5. #include<stdio.h>int main(){/*This is a calculator programme. Calculator is able to perform the operation of two numbers*/int num;float a,b,c;printf("Hello friends this is a calculator "); printf("nchoose a number from the menu to operate the desired function");printf("npress 1 for additionnpress 2 for subtractionnpress 3 for multiplicationnpress 4 for division");scanf("%d",&num);/*The operation is performed using the switch case method*/switch(num){case 1:printf("enter two numbers");scanf("%f%f",&a,&b);c= a+b;printf("the addition of two numbers is %f",c);break;case 2:printf("enter two numbers");scanf("%f%f",&a,&b);c=a-b;printf("the subtraction of two numbers is %f",c);break;case 3:printf("enter two numbers");scanf("%f%f",&a,&b);c=a*b;printf("the multiplication of two numbers is %f",c);break;case 4:printf("enter two numbers");scanf("%f%f",&a,&b);c=a/b;printf("the division of two numbers is %f",c);}}
6. 6.  The previous slide is the exact program to design our own calculator. The program had been written in a single slide to avoid the confusion of the readers. The program as I said had been tested and works efficiently. The text entered within /**/ are the comments in the program to clarify the usage and construction. All you need to know about this program is the basic use of the header files, basic functions and the syntax. You can just copy this program from the slide or instead write it in the editor of the software of your choice.
7. 7.  To learn about the C language and more of it, you may go for the book named: Let us C by Mr. Yashavant Kanetkar. Or the more efficient course offered by him with the help of Dvds namely Quest course would be much better. After you written the program in the editor, build it and run it. The moment you run it you will experience the fun while programming. This program might develop your interest in the software area.
8. 8.  So friends just enjoy this program and do feed me with your comments after seeing this presentation. And do wait for my next upload. For any other queries u can mail me on this address saurabh.khetan53@gmail.com Any problem regarding this program and any kind of query would be resolved.