Add two number in C

In this article we learn how to add two number in c.

Let’s write a program which add two numbers in c.

Step 1: Let’s open turbo c and write following code:

//Code

// Adding preprocessor file

#include<stdio.h>

#include<conio.h>

void main()

{

// delcare variable

int  a,b,c;

//clear screen

clrscr();

printf(“enter value of a and b”);

// assign value in variable a and b

scanf(“%d%d”&a,&b);

// add a and b

c=a+b;

//print the result

printf(“The Result is=%d”,c);

getch();

}

Step 2: Save it by pressing F2 and name it Add.cpp and click OK.

compile

Step 3: Now, you have to compile .it means to check errors in programe for successfully run.  Click on Compile or press F9.

run

Step 4:  Run the program. Press ALT+R and see the output.

Output:

out

Happy coding.

Tags: