Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Learn More

C Program to Add Two Integers | add two numbers in c

1 min read

 In this example, the user is asked to enter two integers. Then, the sum of these two integers is calculated and displayed on the screen.


To understand this example, you should have the knowledge of the following C programming topics:


  • C Data Types
  • C Variables, Constants and Literals
  • C Input Output (I/O)
  • C Programming Operators

Program to Add Two Integers



#include <stdio.h>
int main() {    

    int number1, number2, sum;
    
    printf("Enter two integers: ");
    scanf("%d %d", &number1, &number2);

    // calculating sum
    sum = number1 + number2;      
    
    printf("%d + %d = %d", number1, number2, sum);
    return 0;
}

Labels : #c ,#code ,

You may also like these Posts

Post a Comment