write program with two nested for loops that produces the following.

D3 D4 D5 D6 D7
E3 E4 E5 E6 E7
F3 F4 F5 F6 F7
G3 G4 G5 G6 G7


Last edited on
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

int main()
{
    for(int i = 0; i < 1; i++)
    {
        std::cout
        << "D3 D4 D5 D6 D7\n"
        << "E3 E4 E5 E6 E7\n"
        << "F3 F4 F5 F6 F7\n"
        << "G3 G4 G5 G6 G7\n";
        for (int j = 0; j < 1; j++)
            std::cout << "Thankyou\n";
    }
    
    return 0;
}
@DesmondLee - Although I prefer kemort's solution :) here's another to get you started:
Start with a string "DEFG". Loop through each element with another loop counting from 3 to 7.
The outer loop prints lines. The inner loop prints items in the line:
1
2
3
4
5
    for (char letter = 'D'; letter <= 'G'; ++letter) {
        for (int number = 3; number <= 7; ++number) {
              ....
        }
    }

okay Thanks for the reply @ kemort @Boilerplate @ dhyaden
i will try it out
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>
using namespace std;
int main()
{
	char letter;
	int number;

	for (letter = 'D'; letter <= 'G'; ++letter)
	{
        for (number = 3; number <= 7; ++number) 
		{
		cout<<letter;
		cout<<number;
        }
		cout<<endl;
	}
	system("Pause");
	return 0;
}



Thank you for the guidance. i did it.
Topic archived. No new replies allowed.