It is a stupid code. Ask the question who wrote this code. The code has no any sense. It simply outputs 12 lines consisting of 13 occurenses of a letter entered by the user.
I suppose it's possible, it just seems a little too bad for someone to have published it. Even as an example of "what not to do", it's missing a return statement so it won't even compile with strict warnings enabled.
That's fine, most of the time you don't even assign a meaning to the return statement. But that doesn't invalidate what I said about strict warnings preventing this from compiling.
That's fine, most of the time you don't even assign a meaning to the return statement. But that doesn't invalidate what I said about strict warnings preventing this from compiling.
I have not totally understood why you need that the valid program (that is without the return statement in main) will not be compiled.
I guess it doesn't actually matter vlad, if the code didn't come from OP then it is too messed up of an example to try to explain to someone who is still learning so this entire thread should just be allowed to die. If I don't respond to your next post here then don't take it personally, it's just that this is starting to feel like a game of "Who Can Get The Last Word In".
it should be like this...put a break there..then u will get wat u wan i guess..the result will be:
TTTT
TTTT
TTTT
if u want the result be three T per row..u jus delete the line cout alphabet before the inner loop..
#include <iostream>
using namespace std;
int main()
{
char alphabet = 'D';
int count;
cout << "Please enter an alphabet: ";
cin >> alphabet;
switch (alphabet)
{
case 'T' : count = 3;
break;
case 'S' : count = 6;
break;
case 'N': count = 9;
break;
default: count = 12;
}
for (int i = 0; i < count; i++) // outer loop
{
cout << alphabet ;
for (int j = 0 ; j < count; j++) // inner loop
cout << alphabet ;
cout << endl;
}
}//main