Adsense 728 * 15


Custom Search

Program to Add Two Numbers in C, C++

Write a C, C++ program to add two numbers or you can say add two integers. This program is for beginners who are learning C, C++. To solve this program you just need basic understanding of programming.

Program to Add two numbers without using addition operator.

Print hello world without using semicolon.

Logic of Adding Two Numbers

1. Two two input numbers from users.

2. c = a +b;  Assign the sum of two numbers into third variable.

3. Print the third variable.

MCQ on C, C++ programming questions.

Program to Add Two Numbers in C

#include <stdio.h>

int main(void) {
 int a, b, c;
 printf ("Enter two integers \n");
 scanf ("%d %d", &a, &b);
 c = a + b;
 printf ("The sum of two numbers is %d", c);
 return 0;

Output :

Enter two integers :  5

The sum of two numbers is : 11

Program to Add Two Numbers in C++

#include <iostream>
using namespace std;

int main() {

 int a, b, c;
 cout << "Enter two numbers \n";
 cin >> a >> b;
 c = a + b;
 cout << "Sum of two numbers is " << c;

 return 0;

No comments:

Post a Comment