top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Write a c program that prompts the user to input five numbers and get their sum?

0 votes
240 views
Write a c program that prompts the user to input five numbers and get their sum?
posted Jul 24, 2017 by Elton Ngugi

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Its a simple problem you should have tried this himself. Please find the requested program as follows -

main()
{
        int a1, a2, a3, a4, a5;
        printf("Enter First Number\n");
        scanf("%d", &a1);
        printf("Enter Second Number\n");
        scanf("%d", &a2);
        printf("Enter Third Number\n");
        scanf("%d", &a3);
        printf("Enter Fourth Number\n");
        scanf("%d", &a4);
        printf("Enter Fifth Number\n");
        scanf("%d", &a5);

        printf("Sum of %d + %d + %d + %d + %d = %d", a1, a2, a3, a4, a5, a1+a2+a3+a4+a5);
}
answer Jul 24, 2017 by Salil Agrawal
Similar Questions
+3 votes

Given input as a string, return an integer as the sum of all numbers found in the string

Input: xyzonexyztwothreeeabrminusseven
Output : 1 + 23 + (-7) = 17

+1 vote

Write your own rand function which returns random numbers in a given range(input) so that the numbers in the given range is equally likely to appear.

...