C- Functions Question and Answer
C- Functions Question and Answer
102. Find the output.
void main ( )
{
int x, y=5;
x=come (y);
y=go (x);
printf("%d",x);
printf ("%d", y);
}
come (int x)
{
if (x)
return x++;
else
return x--;
}
go (int y)
{
if (y)
return y++;
else
return y--;
}
void main ( )
{
int x, y=5;
x=come (y);
y=go (x);
printf("%d",x);
printf ("%d", y);
}
come (int x)
{
if (x)
return x++;
else
return x--;
}
go (int y)
{
if (y)
return y++;
else
return y--;
}
- 55
- 67
- 43
- None of these
103. Find the output.
void main ( )
{
char *p="cite";
char *q="good";
if (strcmp (p,q))
printf ("equal");
else
printf("not equal");
}
void main ( )
{
char *p="cite";
char *q="good";
if (strcmp (p,q))
printf ("equal");
else
printf("not equal");
}
- equal
- not equal
- Compilation error
- None of these
104. Find the output
void main ( )
{
char c [ ] = "rama";
put (c);
}
put (char *p)
{
while (++*p)
printf("%c", *p);
}
void main ( )
{
char c [ ] = "rama";
put (c);
}
put (char *p)
{
while (++*p)
printf("%c", *p);
}
- rama
- ama
- ama\0
- none of these
105. Find the output.
int a [ ] = {a, 3, 5, 7};
int count;
add ( )
{
return ++count;
}
void main ( )
{
a [count++]=add ( );
pintf ("%d", a[count]);
}
int a [ ] = {a, 3, 5, 7};
int count;
add ( )
{
return ++count;
}
void main ( )
{
a [count++]=add ( );
pintf ("%d", a[count]);
}
- 3
- 4
- 5
- None of these
106. Find the output
void main ( )
{
int a [ ] = {1, 2, 3, 4, 5}, i=0;
while (a[i])
callme (a[i++]);
for (i=0;i<5;i++)
printf("%d", a [i]);
}
callme (int x)
{
*(&x)=x+1;
}
void main ( )
{
int a [ ] = {1, 2, 3, 4, 5}, i=0;
while (a[i])
callme (a[i++]);
for (i=0;i<5;i++)
printf("%d", a [i]);
}
callme (int x)
{
*(&x)=x+1;
}
- 1 2 3 4 5
- 2 3 4 5 6
- No output
- None of these
107. The function strcat( ) append what value at the end of the string ?
- NULL
- '\0'
- Nothing
- None of these
108. Find the output
void main( )
{
void rev (int);
rev (3);
}
void rev (int v)
{
if (n>0)
rev (--n);
printf("%d",n);
}
void main( )
{
void rev (int);
rev (3);
}
void rev (int v)
{
if (n>0)
rev (--n);
printf("%d",n);
}
- 0012
- 123
- 012
- None of these
109. Find the output
void main ( )
{
int i=1;
do
{
printf("%d",i);
}
while (end (i));
}
end (int i)
{
i--;
}
void main ( )
{
int i=1;
do
{
printf("%d",i);
}
while (end (i));
}
end (int i)
{
i--;
}
- 1
- Print 1 infinite time
- Error, function should return a value
- None of these
110. Find the output
void main ( )
{
f ( );
f ( );
}
f ( )
{
static i=1;
printf("%d", i++);
}
void main ( )
{
f ( );
f ( );
}
f ( )
{
static i=1;
printf("%d", i++);
}
- 11
- 12
- 13
- None of these