Powered By Blogger

Friday 11 January 2013

A Simple Program to add two numbers

There are many compilers available to run C programs, some compilers come with some IDE (Integrated Development Enviroment ).
I'm using here is C-Free(Software for creating and Compiling C programs), you can use any of these like: Turbo C++, Turbo C, DJGPP ,Dev C, Dev C++, etc..
 
 
#include<stdio.h>
main()
{
int a, b, c;
printf("Enter your First Numer:\n");
scanf("%d",&a);
printf("Enter your Second Number:\n");
scanf("%d",&b);
c = a + b;
printf("Result/Addition is:\%d n",c);
}

scanf("%d",&a):- is used here to store and to refer the integer value to a variable, fro example here whatever the value is entered by the user ,stored in the variable name : a, %d is defining which type of data type is going to store in the variable 'a'. &a is used to refer that particular value, tells the compiler to store the value into the variable 'a'.
 
So what is happening here is :
 

So when you run this program it will show an output like above

No comments:

Post a Comment