can u pls tell me whr i have gone rong------i have got 2errorz...

#include<iostream.h>
#include<conio.h>


void main()
{
cout<<"\n\n\n\tPATTERN\n\\n\n\t" ;


for(int i=1; i<=9; i++);
{for (int j=1;j<=i; j++);
cout<<i;
}


getch();
}

Recommended Answers

All 10 Replies

Remove the semicolon after the loops.
that is

#include<iostream.h>
#include<conio.h>

void main()
{
cout<<"\n\n\n\tPATTERN\n\n\n\t" ;

for(int i=1; i<=9; i++)
{
  cout<< endl;  
  for (int j=1;j<=i; j++)
    cout<<i;
}

getch();
}

Thanku ...burt wat happens if i dont include ....................cout<< endl;

i dont understand watz rong w dis.........

#include<iostream.h>
#include<conio.h>


void main()
{
cout<<"\n\n\n\tPATTERN\n\\n\n\t" ;


for(int i=1; i<=9; i++)
{


for (int j=1;j<=i; j++);
cout<<"\n\n\n\";
cout<<i;


getch();
}

else it will print 1223334445555...
to print like this
1
22
333
... i included that line.
Also u have to learn what happend if ypu put a semicolon at the end of for loop. Avoid mistakes.
You should Improve findout solutions urself.(especially if problems are so simple)

i dont understand watz rong w dis.........

Please, take some time and read the section Keep It Clean

cout<< endl;....dis s a code i havnt studied!!... s dere any substitute for this..i have just started C++ day before yesterday so i havnt learnt this....is there any way 2 print this.........
1
22
333
4444
........................without using cout<<endl;?..plz do reply...thanks alot for your haelp n sorry for any inconvinience caused by this..

cout<<endl;
cout<<"\n";
both the above statements are same. Both are used to put a new line.

wont dis one do?........................

#include<iostream.h>
#include<conio.h>


void main()
{
cout<<"\n\n\n\tPATTERN\n\n\n\t";  //Pattern is placed outside the loop


for(int i=1; i<=5;i++)


{cout<<"\n\n\t";       //cout s placed here so dat it comes1 step below
for (int j=1;j<=i; j++)
cout<<i;
}


getch();
}

oh thanks amillion!!!..............

Although the problem might be solved, I strongly suggest that you read these links:

code tags
void main()
getch()
code formatting

And last but not least: I suspect that you're using the Turbo C++ compiler? Replacing it with a 'modern' compiler would be a good idea. That way you'll learn C++ the standard way, not the turbo way. Turbo was a good compiler back in the day, but that day was a few years back...
Here are some newer (free) compilers:

Visual Studio (my personal fav)
Bloodshed Dev-c++
code::blocks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.