Monday, 12 September 2016

C Program to add two numbers(Integer)

This is a simple C Program to add two numbers(Integer)
I have used Code Blocks to build the program.
I also suggest you to use Code Blocks for C-Programming.
Here is a guide for beginners > How to use Code Blocks for C-Programs.

Code:

#include<stdio.h>

int main()
{
    int a,b,c;//To declare three integer variables
    printf("\t\t\tAddition of two numbers\n");
    printf("Enter two values\n");
    //To take input value of a and b from the user
    scanf("%d%d",&a,&b);

    //To perform the addition
    c=a+b;//c is assigned the value of (a+b)

    //To print the result
    //%d is used to indicate an integer
    //the value of c is printed in place of %d
    printf("The addition is %d",c);

    return 0;
}




Output :

                        Addition of two numbers
Enter two values
7
3
The addition is 10

Download the C-File

No comments:

Post a Comment