Write a C program to calculate sum of two numbers from user using third variable.

Function Main
    Declare Integer a
    Declare Integer b
    Declare Integer sum
    
    Output "Enter first number: "
    Input a
    Output "Enter second number: "
    Input b
    Assign sum = a + b
    Output "The sum is: " sum
End

#include <stdio.h>
int main() {
    int a;
    int b;
    int sum;
    
    printf("Enter first number: ");
    scanf("%d",&a);
    printf("Enter second number: ");
    scanf("%d",&b);
    sum = a + b;
    printf("The sum is: %d", sum);
    return 0;
}


Enter first number: 5
Enter second number: 10
The sum is: 15

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.