You are on page 1of 7

[A] What will be the output of the following programs:

(1) #include <stdio.h>


#include<string.h>
int main( )
{
char s[] = “Rendezvous!” ;
printf (“%d\n”, *(s+stren(s) ) ) ;
return 0 ;
}

(2) #include <stdio.h>


int main( )
{
char ch[20] ;
int I ;
for(I = 0 ; I < 19 ; i++ )
*(ch +I ) = 67 ;
* (ch + i) = ‘\0’ ;
printf(“%s\n”, ch ) ;
return 0 ;

(3) #include <stdio.h>


int main( )
{
char str[20] ;
int I ;
for (I = 0 ; i< = 18 ; i++ )
i[str] = ‘C’ ;
i[str] = ‘\0’ ;
printf(“%s\n”, str) ;
return 0 ;
}

(4) #include <stdio.h>


int main( )
{
char str[20] ;
static int I ;
for( ; ; )
{
i++[str] = ‘A’ + 2 ;
if (I = =19)
break ;
}
i[str] = ‘\0’ ;
printf (“%s\n”, str ) ;
return 0 ;
}

(5) #include <stdio.h>


int main( )
{
char str[ ] = {48, 48, 48, 48,48, 48,48,48, 48 } ;
char *s ;
int I ;
s = str ;
for(I = 0 ; I < = 9 ; i++ )
{
if (*s)
printf( “%c”,s ) ;
s++ ;
}
printf(“\n” ) ;
return 0 ;
}

(6) #include <stdio.h>


int main( )
{
char str[10] = {0, 0, 0, 0, 0, 0,0, 0, 0, 0} ;
char *s ;
int I ;
s = str ;
for (I = 0 ; I <= 9 ; i++ )
{
if (*s)
printf( “%c”, *s ) ;
s++ ;
}
printf (“\n” ) ;
return 0 ;
}

(7) #include <stdio.h>


int main( )
{
char s[ ] = “C smart!!” ;
int I ;
for( I = 0 ; s[i] ;i++ )
printf(“%c %c %c\n”, s[i], *s(s + i), i[s], *(i+s )) ;
return 0 ;
}

(8) #include <stdio.h>


int main( )
{
char s[] = “Oinks Grunts and Guffaws” ;
printf (“%c\n”, *(&s[2] ) ) ;
printf (“%s\n”, (s+5 ) ) ;
printf(“%c\n”, *(s+2) ) ;
printf(“%d\n”, s) ;
}

(9) #include <stdio.h>


int main( )
{
har s [25] = “The cocaine man” ;
nt I = 0 ;
har ch ;
h = s[++i] ;
rintf(“%c %d\n”, ch, I ) ;
h = s[i++]
rintf(“%c %d\n”, ch, i) ;
h = i++[s] ;
rintf (“%c %d\n”, ch, I ) ;
h = ++i[s] ;
rintf (“%c %d\n”, ch, I ) ;
return 0 ;
}

(10) #include<stdio.h>
int main( )
{
char arr[ ] = “Pickpocketing my peace of mind..” ;
int I ;
printf(“%c\n”, *arr ) ;
arr++ ;
printf (“%c\n”, *arr) ;
return 0 ;
}

(11) #include <stdio.h>


int main( )
{
char str[] = “Limricks” ;
char *s ;
s = & str[6] -6 ;
while (*s)
printf(“%c”, *s++ ) ;
printf(“\n” ) ;
return 0 ;
}

(12) #include <stdio.h>


int main( )
{
char *s[ ] = {
“ice”
“green”
“cone”,
“please”
};
char **ptr[] = {s+3, s+2, s+1, s} ;
char***p = ptr ;
printf(“%s\n”, **++p) ;
printf (“%s\n”,*--*++p+3) ;
printf (“%s\n”, *p[-2]+3 ) ;
printf (“%s\n”, p[-1][-1]+1 ) ;
return 0 ;
}

(13) #include <stdio.h>


int main( )
{
char s[] = “C it your self” ;
int I = 0 ;
while (s[])
{
if (s[i]!= ”)
s[i] = s[i] +1 ;
i++ ;
}
printf(“%s\n”, s) ;
return 0 ;
}

(14) #include <stdio.h>


#include<string.h>
int main( )
{
char str[] = “For your eye only”
int I ;
char*p ;
for (p = str, I = 0 ; p+ I < = str+strlen (str) ; p++, i++ )
printf(“%c”, *( p+i) ) ;
printf (“\n”) ;
return 0 ;
}

(15) #include <stdio.h>


int main( )
{
char str[ ] = “MalayalaM” ;
char *s ;
while (s >= str)
{
printf(“%c”, *s ) ;
s-- ;
}
printf (“\n” ) ;
return 0 ;
}

(16) #include <stdio.h>


#include<string.h>
int main( )
{
char a[ ] = “Able was 1ere l saw elbA” ;
char *t, *s, *b ;
s=a;
b = a + strlen (a)-1 ;
t=b;
while (s!= t)
{
printf(“%c”, *s ) ;
s++ ;
printf(“%c”, *s) ;
t-- ;
}
printf (“\n” ) ;
return 0 ;
}

(17) #include<stdio.h>
int main( )
{
char str[] = “Shall we tell the Deputy Director?” ;
printf (“%s\n%s\n”, str, str +6, str +9) ;
return 0 ;
}

(18) #include <stdio.h>


int main( )
{
char s[ ] = “C is a philosophy of life” ;
char t[40] ;
char *ss, *tt ;
ss = s ;
while ( *ss )
*tt++ = *ss++ ;
*tt = ‘\0’ ;
printf(“%s\n”,t ) ;
return 0 ;
}

(19) #include <stdio.h>


int main( )
{
char s[] = “Lumps, bumps, swollen veins, new pains” ;
char t[40] ;
char*ss, *tt ;
tt = t ;
ss = s ;
while (*tt++ = *ss++ ) ;
printf(“%s\n”,t ) ;
return 0 ;
}

(20) #include <stdio.h>


#include <string.h>
int main( )
{
char str1[] = “dills” ;
char str 2[20] ;
char str 3[20] = “Daffo” ;
int l ;
l = strcmp (strcat (str3,strcpy (str2,str1 ) ), “Daffodills” ) ;
int l ;
l = strcmp (strcat (str3,strcpy (str2,str1 ) ), “Daffodills” ) ;
printf(“l = %d\n”, i) ;
return 0 ;
}

( 21) #include<stdio.h>
int main( )
{
int arr[12] ;
printf(“%d\n”, sizeof ( arr ) ) ;
return 0 ;
}
(22) #include <stdio.h>
int main( )
{
char *mess[] = {
“Some love one”
“Some love two”,
“ l love one”
“That is you”
};
printf(“%d %d\n”, sizeof (mess), sizeof (mess[1]) ) ;
return 0 ;
}

(23) #include<stdio.h>
int main( )
{
char names[3][20] ;
int I ;
for ( I = 0 ; <=2 ;i++ )
{
printf(“ENTER NAME:\n” ) ;
scanf(“%s”, names[i] ) ;
printf(“You entered %s\n”, names[i] ) ;
}
return 0 ;
}

(24) #include<stdio.h>
int main( )
{
char names[5][20] = {
“Roshni”
“Manish”,
“Mona”,
“Baiju”,
“Ritu”
};
int I ;
char*t ;
t = names[3] ;
names[3] = names[4] ;
names[4] = t ;
for ( I = 0 ; i<= 4 ; i++ )
printf(“%s\n”, names[i] ) ;
return 0 ;
}
(25) include <stdio.h>
int main( )
{
char mess[6][30] = {
“Don’t walk in front of me..”,
“I may not follow ;”
“Don’t walk behind me…” ,
“ I may not lead ;”
“just walk beside me….”,
“And be my friend.”
Printf(“%c %c\n”, *(mess[2] +9), *( *(mess +2) +9 ) ) ;
Return 0 ;
}

(26) #include <stdio.h>


int main( )
{
char mess[2][2][30] = {
{
“A chink in your aarmour”,
“A voice in your mailbox”
},
{
}
};
printf(“%s\n%s\n”, mess[1][0], mess[0][1] ) ;
return 0 ;

You might also like