Multidimensional array
Array having two or more than two dimension
Syntax:
#include<stdio.h>
int main()
int a[3][3]={1,2,3,4,5,6,7,8,9};
int i,j;
printf("The matrix is\n");
for(i=0; i<3; i++)
for(j=0; j<3; j++)
printf("%d\t",a[i][j]);
printf("\n");
return 0;
}
#include<stdio.h>
int main()
int a[3][3];
int i,j;
printf("enter any number");
for(i=0; i<3; i++)
for(j=0; j<3; j++)
scanf("%d", &a[i][j]);
printf("the matrix elements are\n");
for(i=0; i<3; i++)
for(j=0; j<3; j++)
printf("%d\t", a[i][j]);
}
printf("\n");
return 0;
String
1. String is an array of character.
2. It is stored in consecutive memory location.
3. String is collection of characters which are stored in consecutive memory location.
4. String always terminated with '/0'.
5. Each characters in string occupies one byte of memory.
char name[10]="programming"
#include<stdio.h>
void main()
char name[10];
printf("enter your name");
scanf("%s",name);
printf("Name=%s",name);
getch();
#include<stdio.h>
void main()
{
char name[10];
printf("enter your name");
gets(name);
printf("Name=%s",name);
getch();
String handling function:
#include<string.h>
1. Strelen()
2. Strcpy()
3. Strrev()
4. Strcmp()
5. Strcat()
6. Strlwrc()
7. Strupr()
#include<stdio.h>
void main()
{
int l;
char str[10];
printf("enter any string");
gets(str);
l=strlen(str);
printf("length of string=%d",l);
getch();
#include<stdio.h>
void main()
{
char str[10];
printf("enter any string");
gets(str);
printf("original string=%s",str);
strrev(str);
printf("Reverse is=%s",str);
getch();
}s
(str!=strrev(str))