Question 31
The value printed by the following program is
void f(int* p, int m)
{
m = m + 5;
*p = *p + m;
return;
}
void main()
{
int i=5, j=10;
f(&i, j);
printf(\"%d\", i+j);
}
Question 32
Pick the best statement for the following program snippet:
#include <stdio.h>
int main()
{
int var; /*Suppose address of var is 2000 */
void *ptr = &var;
*ptr = 5;
printf(\"var=%d and *ptr=%d\",var,*ptr);
return 0;
}
Question 33
What does the following program print?
#include
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1;
int main()
{
f(&i, &j);
printf(\"%d %d \\n\", i, j);
getchar();
return 0;
}
Question 36
Assume that a character takes 1 byte. Output of following program?
#include<stdio.h>
int main()
{
char str[20] = \"GeeksQuiz\";
printf (\"%d\", sizeof(str));
return 0;
}
Question 37
Predict the output of following program, assume that a character takes 1 byte and pointer takes 4 bytes.
#include <stdio.h>
int main()
{
char *str1 = \"GeeksQuiz\";
char str2[] = \"GeeksQuiz\";
printf(\"sizeof(str1) = %d, sizeof(str2) = %d\",
sizeof(str1), sizeof(str2));
return 0;
}
Question 38
A language with string manipulation facilities uses the following operations.
head(s)- returns the first character of the string s
tail(s)- returns all but the first character of the string s
concat(sl, s2)- concatenates string s1 with s2.
The output of concat(head(s), head(tail(tail(s)))), where s is acbc is
Question 39
In below program, what would you put in place of “?” to print “Quiz”?
#include <stdio.h>
int main()
{
char arr[] = \"GeeksQuiz\";
printf(\"%s\", ?);
return 0;
}
Question 40
Consider the following C program segment.
# include <stdio.h>
int main( )
{
char s1[7] = \"1234\", *p;
p = s1 + 2;
*p = \'0\' ;
printf (\"%s\", s1);
}
What will be printed by the program?
There are 50 questions to complete.