0% found this document useful (0 votes)
10 views

Multidimensional Array

The document discusses multidimensional arrays in C, including their syntax and how to initialize and print them. It also covers strings in C - how they are stored in memory, common functions like gets(), puts(), and string handling functions from the string.h library like strlen(), strcpy(), strrev(), strcmp(), and strcat(). Examples are provided to demonstrate initializing and accessing 2D arrays, getting user input into strings, calculating string lengths, and reversing strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Multidimensional Array

The document discusses multidimensional arrays in C, including their syntax and how to initialize and print them. It also covers strings in C - how they are stored in memory, common functions like gets(), puts(), and string handling functions from the string.h library like strlen(), strcpy(), strrev(), strcmp(), and strcat(). Examples are provided to demonstrate initializing and accessing 2D arrays, getting user input into strings, calculating string lengths, and reversing strings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

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))

You might also like