Ask Question
17 November, 09:02

Write a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. Then the user should be asked if he or she wishes to perform the operations again.

+4
Answers (1)
  1. 17 November, 09:09
    0
    int i, j, k;

    do{

    scanf ("%d %d",&i,&j);

    k=i+j;

    printf ("%d", k);

    scanf ("%d",&k);

    }while (k==1);

    Explanation:

    First we initialize the 3 integers variables i, j, k

    The loop starts

    and we take input of numbers to be added into i and j

    k stores the sum and prints it

    Then we take an input of 0 (or) 1

    0 indicates the user does not wish to perform the operation again

    1 indicates the user wishes to perform the operation again
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. Then the user should be ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers