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

Nov 22, 2016 at 2:25pm
D3 D4 D5 D6 D7
E3 E4 E5 E6 E7
F3 F4 F5 F6 F7
G3 G4 G5 G6 G7


Last edited on Nov 22, 2016 at 2:25pm
Nov 22, 2016 at 2:48pm
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;
}
Nov 22, 2016 at 3:13pm
@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.
Nov 22, 2016 at 8:44pm
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) {
              ....
        }
    }

Nov 24, 2016 at 10:07am
okay Thanks for the reply @ kemort @Boilerplate @ dhyaden
i will try it out
Nov 24, 2016 at 12:24pm
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.