Ask Question
19 January, 08:44

Write a C+ + Program to generate the following output using a loop structure (s). (Do not hardcode the output values!) Include sufficent comments

8 6 4 2 0

6 4 2 0

4 2 0

2 0

0

+2
Answers (1)
  1. 19 January, 10:48
    0
    Following are the program in the C+ + Programming Language.

    #include / / header file

    using namespace std; / / namespace

    int main () / / main function

    {

    int n=8; / /variable declaration

    for (int k=n; n>=0; n-=2) / / iterating over the loop to print the format

    {

    int n1=n;

    for (int j=n1; n1>=0; n1-=2)

    {

    cout<
    }

    cout<
    }

    return 0;

    }

    Output:

    8 6 4 2 0

    6 4 2 0

    4 2 0

    2 0

    0

    Explanation:

    Following are the description of the program.

    Set an integer type variable "n" and initialize in it to 8. Set two for loop, the first loop iterate from the variable "n" that is 8 to 0 with decrement by 2 and next for loop also iterate from 8 to 0 then, print the value of the variable "n1". Finally, we break line after the second for loop.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a C+ + Program to generate the following output using a loop structure (s). (Do not hardcode the output values!) Include sufficent ...” 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