Monday, 8 December 2014

C program to add records of students by using string(2D array Passing)
#include<stdio.h>
void addrec(char (*p)[2][20],int);
main()
{
char arr[5][2][20];
int i,j;
printf("enter string of 2D_Array\n");
for(i=0;i<5;i++)
for(j=0;j<2;j++)
scanf(" %[^\n]s",arr[i][j]);
addrec(arr,5);
}
void addrec(char (*p)[2][20],int n)
{
int i,j;
for(i=0;i<n;i++)
{
for(j=0;j<2;j++)
printf("%s\t",p[i][j]);
printf("\n");
}
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ ./a.out
enter string of 2D_Array
well
come
madan
reddy
hyd    
andhra
india
500082
hello
gud morning
well come 
madan reddy 
hyd andhra 
india 500082 
hello gud morning