Hi:

I need some assistance in this code. I am trying to get this format.

1
.2
..3
...4
and so on.. i dont get any errors in the code but i get no o/p eitehr

#include<iostream.h>

int main()
{

int i;

cout.fill('.');

for(i=i;i<10;++i)

{
cout.width(i);
cout.fill('.');
cout<<i;


}}

>>for(i=i;i<10;++i)

should be for(i = 0 ...

I get lots of pretty output, (gcc compiler):

..-1208080203-1208080202-1208080201-1208080200-1208080199-1208080198-1208080197-
1208080196-1208080195-1208080194-1208080193-1208080192-1208080191-1208080190-
1208080189-1208080188-1208080187-1208080186-1208080185-1208080184-1208080183-
1208080182-1208080181-1208080180-1208080179-1208080178-1208080177-1208080176-
1208080175-1208080174-1208080173-1208080172-1208080171-1208080170-1208080169-
1208080168-1208080167-1208080166-1208080165-1208080164-1208080163-1208080162-
1208080161-1208080160-1208080159-1208080158-1208080157-1208080156-1208080155-
1208080154-1208080153-1208080152-1208080151-1208080150-1208080149-1208080148-
1208080147-1208080146-1208080145-1208080144-1208080143-1208080142-1208080141-
1208080140-1208080139-1208080138-1208080137-1208080136-1208080135-1208080134-
1208080133-1208080132-1208080131-1208080130-1208080129-1208080128-1208080127-...[/quote]

#include<iostream.h>

While it does not really matter if your compiler supports this, its usually a better idea to use the most recent header files

#include <iostream>

...

cout.fill('.');
for(i=i;i<10;++i)
{
    cout.width(i);
    cout.fill('.');
    cout<<i;
}

INT X: You declare a variable and do not initialize it.

FOR X = X: You copy the value of X into X,

FOR (X to 10): Well based on the value we gave X (none) this could be anywhere in the range of integer values ( -2147483648 to 2147483647, on a 32-bit system ) number of iterations.

int x = 0;
for(i = x; i<10; ++i)
   cout << "." << i;

~ or ~

for(int i=0; i<10; i++)
    cout << "." << i;

Would accomplish what you're looking for in your loop.

There is no return 0; The system needs this value to know everything went 'ok' with the system.. any other value that is returned is usually viewed as an error.

return 0;
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.