Showing posts with label for loop to if else statement. Show all posts
Showing posts with label for loop to if else statement. Show all posts

Tuesday, November 12, 2013

C++ For Loop Program Conversion to If Else Statement Program

Given the following C++ code:
     int j, sum = 0;     for (j = 0; j < 10; j++)     sum += j;
     cout<<sum;
Re-write the C++ statements so that they compute the same quantity but using decision statement (if-else) instead of for loop.