Thursday, 25 January 2018

2D Array Input/Ouput

Q :  Define a two dimensional array ‘int a[10][10]’. Write a ‘C’ program to initialize this array with numbers between 0 and 99. Then print the contents of ‘a’.

Solution : 

/*==============================
     Girfa Student Help
     Program : 2D Array Input/Ouput
     More Program :http://girfahelp.blogspot.in/p/2-d-array-programming.html
================================*/
#include<stdio.h>
#include<conio.h>
#define MAX 10
void main()
{
     int a[MAX][MAX],r,c,s;
     clrscr();
     for(r=0,s=
0;r<MAX;r++)
     {
          for(c=0;c<MAX;c++)
          {
              a[r][c]=s++;
          }
     }
     for(r=0;r<MAX;r++)
     {
          for(c=0;c<MAX;c++)
          {
              printf("\t%d",a[r][c]);
          }
          printf("\n");
     }
     getch();
}

No comments:

Post a Comment