Ask 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 asked if he or she wishes to perform the operations again.

+5
Answers (1)
  1. 30 April, 21:28
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers