ESC-M4
ESC-M4
24 15 34
26 134 194
67 23 345
• Then the compiler will assume its all rest value as 0,which are not defined.
• Mat[0][0]=11, Mat[0][1]=0, Mat[0][2]=0
• Mat[1][0]=12, Mat[1][1]=13, Mat[1][2]=0
• Mat[2][0]=14, Mat[2][1]=15, Mat[2][2]=16
• Mat[3][0]=17, Mat[3][1]=0, Mat[3][2]=0
to a function
#include <stdio.h> void displayNumbers(int num[ ][2])
void displayNumbers(int num[2][2]); {
// code
void main( ) }
{
int num[5][5], n, m, i; OR
str[0] 1000
H
str[1] 1001
E
str[2] 1002
L
str[3] 1003
L
str[4] 1004
O
str[5] 1005
Str[6] \0
1006
READING STRINGS
If we declare a string by writing char str[100];
Then str can be read from the user by using three ways.
Note: gets() takes the starting address of the string which will hold the input. The string inputted using
gets() is automatically terminated with a null character.
The string can also be read by calling the getchar() repeatedly to read a sequence of single characters
(unless a terminating character is entered) and simultaneously storing it in a character array.
i=0;
getchar(ch);
while(ch != '*’)
{
str[i] = ch;
i++;
getchar(ch);
}
str[i] = '\0';
WRITING STRINGS
The string can be displayed on screen using three ways
● use printf() function
● using puts() function
● using putchar()function repeatedly
The string can be displayed using printf() by writing printf(“%s”, str);
The string can be displayed by writing puts(str);
The string can also be written by calling the putchar() repeatedly to print a sequence of single
characters
i=0;
while(str[i] != ‘\0’)
{
putchar(str[i]);
i++;
}