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

 

Flowchart

Sum of two entered numbers flowchart

 

Coding in C

#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;
}

 

Coding in C++

#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

Sum of two entered numbers output

 

Published by

admin

I am a computer teacher, programmer and web developer