Dremendo Tag Line

Input 2 numbers and find their sum in C

scanf() - Question 1

In this question, we will see how to input two numbers in C programming using the scanf() function and find their sum. To know more about scanf() function click on the scanf() function lesson.

Q1) Write a program in C to input two numbers and find their sum.

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    int a,b,c;
    printf("Enter 2 numbers\n");
    scanf("%d%d",&a,&b);
    c=a+b;
    printf("Sum=%d",c);
    return 0;
}

Output

Enter 2 numbers
15
26
Sum=41
video-poster