Write a C C++ program to find sum of two entered numbers

Write a C C++ program to find sum of two entered numbers

C Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C

C++ Language के बारे में अधिक जानने के लिए देखें—Brief Introduction of C++

Flowchart to find sum of two numbers

Sum of two entered numbers flowchart

C program to find sum of two numbers

#include <stdio.h>
int main()
{
    int n1,n2,sum;
    printf("Enter number1: ");
    scanf("%d",&n1);
    printf("Enter number2: ");
    scanf("%d",&n2);
    sum=n1+n2;
    printf("Sum of numbers = %d",sum);
    return 0;
}

C++ program to find sum of two numbers

#include<iostream>
using namespace std;
int main()
{
    int n1,n2,sum;
    cout<<"Enter number1: ";
    cin>>n1;
    cout<<"Enter number2: ";
    cin>>n2;
    sum=n1+n2;
    cout<<"Sum of numbers = "<<sum;
    return 0;
}

Output of C C++ program to find sum of two numbers

Enter number1: 3
Enter number2: 4
Sum of numbers = 7
Enter number1: 50
Enter number2: 90
Sum of numbers = 140

Other sequential logic programs in C C++

  1. Average of three entered numbers
  2. Simple interest
  3. Total and Percent
  4. Swapping values of two variables
  5. Swapping without using third variable
  6. Celsius to Fahrenheit conversion
  7. Find area and circumference of circle
Share it to:

Published by

admin

I am a computer teacher, programmer and web developer