code to add numbers in c code example

Example 1: c code to add two numbers

int n,m;
printf("%d",n+m);

Example 2: add 2 numbers in c

#include
int main() {
int a, b, sum;
printf("\nEnter two no: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum : %d", sum);
return(0);

Example 3: code to add numbers in c

#include 
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;
}

Tags:

Misc Example