write a program two add a number. ( by Java)
Answers
Answered by
2
Program to find sum of two numbers
#include<stdio.h>int main() {int a, b, sum;printf("\nEnter two no: ");scanf("%d %d", &a, &b);sum = a + b;printf("Sum : %d", sum);return(0);
#include<stdio.h>int main() {int a, b, sum;printf("\nEnter two no: ");scanf("%d %d", &a, &b);sum = a + b;printf("Sum : %d", sum);return(0);
Answered by
16
import java.util.*;
class Adding
{
public static void main(String args[])
{
int a,b,c;
Scanner scan = new Scanner(System.in);
System.out.println("Enter the 1st number :");
a = scan.nextInt();
System.out.println("Enter the 2nd number :");
b = scan.nextInt();
c = a + b;
System.out.println("Sum of two numbers is :" +c);
}
}
Output:
Enter the 1st number: 10
Enter the 2nd number : 20.
Sum of two numbers is : 30.
Hope it helps!
Similar questions