C Program to add two integers.

 



  • C program to add two integers using C program.

#include <stdio.h>



int main() {


int number1, number2, sum;



printf("Enter first integer: ");


scanf("%d", &number1);

printf("Enter second integer: ");


scanf("%d", &number2);



// calculating sum


sum = number1 + number2;


printf("Sum of above two integers is: %d + %d = %d", number1, number2, sum);


return 0;

}

OUTPUT

Enter first integer: 30
Enter second integer: 20
Sum of above two integers is: 30 + 20 = 50


Explanation.

  • In this program user is used to asked to enter two integers.  
  • Then this numbers are added using + operator and then the result is stored in the sum variable.
  • Atlast, printf() function is used to show the sum of numbers as output.

Comments

Popular posts from this blog

ATM solution in C language.- Codechef

MOTIVATION SOLUTION IN C LANGUAGE | CODECHEF | IMDB

APPLE AND ORANGE | HACKERRANK | PROBLEM SOLVING | SOLUTION IN C