main ( )
{
char s1[6]; \\ A
char s2[6];
char ch;
int cnt = 0;
s1 = “Hello”; \\ B
printf (“%s \n”, s1); \\ C
s2 = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’} \\ D
printf(“%s \n”, s2); \\ E
while ( (ch = getchar() )! = ‘#’ && (cnt < 6-1) ) \\ F
s1[cnt++] = ch; \\ G
s1[cnt] = ‘\0’; \\ H
}
--------------------------------------------------
main ( )
{
char * s1 = “abcd”; \\ A
char s2[] = “efgh”; \\ B
printf( “%s %16lu \n, s1, s1); \\ C
printf( “%s %16lu \n, s2, s2); \\ D
s1 = s2; \\ E
printf( “%s %16lu \n, s1, s1); \\ F
printf( “%s %16lu \n, s2, s2); \\ G
}
----------------------------------------------
main ( )
{
char s1[6] = “abcde ”;
int cnt = 0;
cnt = cnt_str(s1); \\ A
printf( “ total characters are %d \n”, cnt);
}
int cnt_str(char s1[]); \\ B
{
int cn = 0;
while ( (cn < 6) && s1[cn]! = ‘\0’)
cn++;
return(cn);
}
-----------------------------------------------------------
{
char s1[6]; \\ A
char s2[6];
char ch;
int cnt = 0;
s1 = “Hello”; \\ B
printf (“%s \n”, s1); \\ C
s2 = {‘H’, ‘e’, ‘l’, ‘l’, ‘o’} \\ D
printf(“%s \n”, s2); \\ E
while ( (ch = getchar() )! = ‘#’ && (cnt < 6-1) ) \\ F
s1[cnt++] = ch; \\ G
s1[cnt] = ‘\0’; \\ H
}
--------------------------------------------------
main ( )
{
char * s1 = “abcd”; \\ A
char s2[] = “efgh”; \\ B
printf( “%s %16lu \n, s1, s1); \\ C
printf( “%s %16lu \n, s2, s2); \\ D
s1 = s2; \\ E
printf( “%s %16lu \n, s1, s1); \\ F
printf( “%s %16lu \n, s2, s2); \\ G
}
----------------------------------------------
main ( )
{
char s1[6] = “abcde ”;
int cnt = 0;
cnt = cnt_str(s1); \\ A
printf( “ total characters are %d \n”, cnt);
}
int cnt_str(char s1[]); \\ B
{
int cn = 0;
while ( (cn < 6) && s1[cn]! = ‘\0’)
cn++;
return(cn);
}
-----------------------------------------------------------
0 Comments