C Examples

Addition of two numbers in C

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

    int n1, n2, sum;
    
    printf("Enter the two numbers to add\n ");
    scanf("%d %d", &n1, &n2);

    //addition of two numbers
    sum = n1 + n2;      
    
    printf("The sum of %d & %d = %d", n1, n2, sum);
    return 0;
}

Output

Enter the two numbers to add                                                     
7                                                             
5                                                             
The sum of 7 & 5 = 12

About the author

Castro K Joseph

Leave a Comment