Search This Blog

Tuesday, 23 October 2012

The following program is used to copy content of A array to B array

#include<iostream.h>
#define max 100
void main(void)
{
char x[max],y[max];
void stringcopy(char x[],char y[]);
cout<<"enter a string and terminate with @ "<<endl;
cin.get(x,max,'@')
stringcopy(x,y);
cout<<"content a A array is "<<x<<endl;
cout<<"now I am copied to B array is "<<y<<endl;
}
void stringcopy(char a[],char b[])
{
int l;
i=0;
while (a[i]!='\0')
{
b[i]=a[i];
i++;
}
b[i++]='\0';
}

Output:
enter a string
I am a content of A array @
content of A array is I am a content of A array
now I am copied to B array is I am a content of A array

Multi-dimensional array
Multidimensional arrays are defined in the same manner as single dimensional array except, that a separate pairs of square brackets are referred for each subscript.

Example:-
int a[5];// one dimensional
int a[5][5];// two dimensional
int a[5][5][5];// three dimensinal

 
 

No comments:

Post a Comment