write a program to find the sum of two numbers by accepting the number from users
Answers
Answer:
see explanation
Explanation:
In C :
- include <stdio.h>
- int main(){
- int num1 , num2 ,result;
- scanf("%d",&num1);
- scanf("%d",&num2);
- result = num1 + num2;
- printf("%d",result);
- }
Didn't knew what was the language requirement so did it 4 popular ones here.
Language:
Python
Program:
a=int(input("Enter a number: "))
b=int(input("Enter second number: "))
print("The sum is: ", a+b)
Language:
JAVA
Program:
import java.util.Scanner;
public class Main
{ public static void main(String[] args) {
Scanner scan =new Scanner (System.in);
System.out.println("Enter a number: ");
int a= scan.nextInt();
System.out.println("Enter another number: ");
int b= scan.nextInt();
System.out.println("The sum: "+(a+b)) ;}
}
Language:
QBASIC
Program:
INPUT "Enter a number: "; a
INPUT "Enter another number:";b
PRINT "The sum is :", a+b
Language:
C++
Program:
#include <iostream>
using namespace std;
int main(){
int a,b;
cout<<"Enter the value of a: ";
cin>> a;
cout << "Enter the value of b: "
cin>> b;
cout<< "The sum : " << a+b;
return 0;
}