Thursday, September 26, 2013

Second Program : Adding Two Numbers

Hey guys now that we know how to print something on the screen lets start with something more interesting ... You  can make your own calculator using C ,Lets see how
first we use the inbuilt libraries for standard input output that is stdio.h

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum;   // Variables for storing that input and output
printf("\n Enter the first number: "); // Print Enter the first number on screen
scanf("%d",&a); //Read the input using scanf (we will discuss about scanf in next post) & store it in a
printf("\n Enter the second number: "); // Print Enter second number
scanf("%d",&b);// Store second value in b
sum=a+b; // Calculate sum of a and b and put in sum
printf("\n Sum Is %d",sum); // Print the sum on screen
getch(); // Wait till any key is pressed
}

No comments:

Post a Comment