Sum of two Integers

#include<stdio.h>
#include<conio.h>
int main()
{
int a;                                                    //first number to be entered by user
int b;                                                   //second number to be entered by user
int sum;                                               //variable in which sum will stored
printf("Enter Ist integer value :\t");
scanf("%d",&a);                                 //scanf is use to read a value "%d" is user for integer type
printf("Enter IInd integer value :     +");
scanf("%d",&b);
sum=a+b;                                                            // assign total to sum
printf("\t\t\t\t--\nSum is\t\t\t        %d",sum);           // print sum
getch();
}


The name a, b and sum are the names of variables -- location in memory where values can be stored for use by a program. These definations specify that variables a , b and sum are of type int, which means that they hold integer values, i.e. whole numbers such as 7, -22, 4534, 0 and the like.
    All variables must be defined with a name and a data type before they can be used in a program. For readers using the Microsoft Visual C++ compilers, note that we are placing our definition immediately after the left brace that begins the body of main. The C standard allow you to place each variable definition anywhere in main before that variable's first use int the code. Some compilers, such GNU gcc, have implemented this capability.
                                       This preceding definitions could have been combined into a single definition statement   as follow : 
int a, b, sum;

Popular posts from this blog

Shutdown Pc

Ellipse using OpenGl

String Comparisons