Friday, January 11, 2013

C Language Example # 02 Simple Calculator Using C

C Language Example # 02

After Very First Program of Hello World, Lets do some mathematical operation on two number.


C Language Code:

//Written by Latest Technology Guide   
//Title : Example 02 : Simple Calculator Using C Language or mathematical operation on 2 variables. or Demonstrate how to store value into variable and how to use it.
 
#include <stdio.h>
#include <conio.h>
void main()
{
    clrscr();
    int a, b;

    printf("Enter No 1 :");
    scanf("%d",&a);

    printf("Enter No 2 :");
    scanf("%d",&b);

    printf("\n+ \tis :%d\n",a+b);
    printf("- \tis :%d\n",a-b);
    printf("* \tis :%d\n",a*b);
    printf("/ \tis :%d\n",a/b);

    getch();
}

Output:

Enter No 1 :10
Enter No 2 :20

+       is :30
-       is :-10
*       is :200
/       is :0

--------------------------------------------------------------------------------
Explanation of C Language Example # 02 : Simple Calculator Using C Language

* Above Example explains how to scan integer value and stored into variable.
* In above example a and b are variable name.

Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment