#include<stdio.h>
#include<conio.h>

void main()
{
 int a[20],i;
 clrscr();
 printf("enter 20 numbers: ");
 for(i=0;i<20;i++)
    scanf("%d",&a[i]);
 for(i=0;i<20;i++)
    printf("%d\n",a[i]);

 getch();
}

Hi,
use int for main() and return 0. Then you could try if and else to break up a long print out like so:

#include<stdio.h>
#include<conio.h>

int main() {
    int a [20], i;
    int count = 0;
      //clrscr ();
      printf("enter 20 numbers:");
      for ( i = 0 ; i < 20 ; i++ ) 
        scanf( "%d", &a[i] );

      for ( i = 0 ; i < 20 ; ++i ) {
        if ( ( ++count %5 ) == 0 ) {
            printf( " %d\n", a [i] );
        }
        else 
        printf( "%d ", a [i] );
    }
    getch();

      return 0;
  }

Make your printf() format, occupy 80/number of columns you want to have including spaces between columns.

If I want 4 columns, I have my printf() format use 20 spaces, etc.

#include <stdio.h>

int main(void) {
   int n;

   for(n=0;n<200;n++) {
      printf(" %18d ",n);  //4 columns, each one 18+2 wide.
   }
   printf("\n");
   return 0;
}

how if i want it to be arranged by column? because your code is arranged by rows.

Columnar printing becomes more difficult, because all monitors print up in row order. That means you have to use more than just basic print commands for output.

I haven't seen a program to help with this, but there may be one available. What are you trying to print and what is the width of the columns?

The easy way to do this is to use a large char array to represent your "page", and then rearrange the data in the array, so it's in the column ready format, you want.

For example, you keyboard:
Now is the time for all good men to come to the aid of their country, which when rearranged, becomes:

Now is the
time for all
good men to
come to the
aid of their
country.

This question has already been answered. Start a new discussion instead.