A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to add two numbers
Q:

C program to add two numbers

belongs to collection: C programs - Basic C Programs

0

Addition program is one of the simplest program in any programming language. This C program takes two integer numbers from the user and display their sum.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C program to add two numbers - Source code

#include<stdio.h>
 
int main() {
   int a, b, sum;
 
   printf("Enter two numbers: \n");
   scanf("%d %d", &a, &b);
 
   sum = a + b;
 
   printf("Sum : %d", sum);
 
   return(0);
}

Program Output

Case 1:

Enter two numbers:
-56
28
Sum : -28


Case 2:

Enter two numbers:
125
789
Sum : 914

Program Explanation

1. This program declares three integer variables a,b and sum.

2. Value of variables a and b variables is accepted from the user and their sum is stored in the sum variable.

3. Value of the variable sum is printed using the printf function.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C program to find sum of digits of a number... >>
<< C Program to Check if a given Number is Prime or n...