Thursday 15 August 2013

How To Perform Addition In C Language

//Program to perform addition in 'C' with explanation



Explanation:-

In this Program, we used some terms that are used in almost every program of C.
Let understand the meaning of these terms.

1.  int a,b,c;

int 
 Is a Integer data type whose range depends upon the compiler.
 For a 16-bit compiler like Turbo C or Turbo C++ the range is -32768 to +32767.
 For a 32-bit compiler like visual studio or gcc the range is -2147483648 to +2147483647.

 Is a variable of Integer type used to store an integer constant.



b
 Is a variable of Integer type used to store an integer constant.



 Is a variable of Integer type used to store an integer constant.


Variable:- An entity (it can be anything which exists in real world) that may vary during program execution is known as variable.
Variable names are the names given to locations in memory.

a,b,c 
 Commas between variables are used to define two or more variables  in a line. Otherwise, We have to write it like this:
 int a;
 int b;
 int c;

2.  scanf("%d",&a);
        
scanf() 
 Is used to read input from the user.

%d 
 Defines that input is of integer type.

&a 
 Defines that input is stored in variable 'a'.

3. c=a+b;
       
c=a+b 
 This statement add the value of two variables 'a' and 'b'.
 '+' perform addition.
 '==' used to store the addition in another variable called 'c'.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.