Write a program to find the sum of the given numbers and print.
Answers
Answer:
Explanation:
Pictorial Presentation:
Sample Solution:
C Code: #include <stdio.h> void main() { int i,n,sum=0; float avg; printf("Input the 10 numbers : \n"); for (i=1;i<=10;i++) { printf("Number-%d :",i); scanf("%d",&n); sum +=n; } avg=sum/10.0; printf("The sum of 10 no is : %d\nThe Average is : %f\n",sum,avg); } ...
Flowchart:
import java.util.Scanner;
public class main
{
public static void main (String args[])
{
Scanner in = new Scanner (System.in);
int a, b, sum;
System.out.println("Write any two numbers");
System.out.print.ln("Please put comma between two number to avoid error");
a = in.nextInt();
b = in.nextInt();
sum = a+b;
System.out.println("The sum of two numbers is..." +sum);
if (a==0&&b==0)
{
System.out.println("Error! Cannot be displayed");
System.exit(0);
}
else if (a==0llb==0)
{
System.out.println("Error! Cannot be displayed");
System.exit(0);
}
}
}