CPViva
CPViva
a) int number;
b) float rate;
c) int variable_count;
d) int $main;
1. #include <stdio.h>
2. void main()
3. {
4. int x = 5 * 9 / 3 + 9;
5. }
a) 3.75
b) Depends on compiler
c) 24
d) 3
Ans :c
6. How many times i value is checked in the following C program?
#include <stdio.h>
int main()
{
int i = 0;
while (i < 3)
i++;
printf("In while loop\n");
return 0;
}
a) 2
b) 3
c) 4
d) 1
Ans:c
7. What will be the output of the following C code? (Assuming that we have entered
the value 1 in the standard input)
#include <stdio.h>
void main()
{
int ch;
printf("enter a value between 1 to 2:");
scanf("%d", &ch);
switch (ch)
{
case 1:
printf("1\t");
default:
printf("2\t");
}
}
a) 1
b) 2
c) 1 2
d) Run time error
Ans: c
8. Size of an array can be evaluated by __________
(Assuming array declaration int a[10];)
a) sizeof(a);
b) sizeof(*a);
c) sizeof(a[10]);
d) 10 * sizeof(a);
Ans:a
int func(int);
double func(int);
int func(float);
a) A function with same name cannot have different signatures
b) A function with same name cannot have different return types
c) A function with same name cannot have different number of parameters
d) All of the mentioned
Ans:d
15. Which of the following is a correct format for declaration of function?
a) return-type function-name(argument type);
b) return-type function-name(argument type) { }
c) return-type (argument type)function-name;
d) all of the mentioned
Ans:a
16. The value obtained in the function is given back to main by using ________
keyword.
a) return
b) static
c) new
d) volatile
Ans:return
17. Which operator connects the structure name to its member name?
a) –
b) <-
c) .
d) Both <- and .
Ans:c
18. The correct syntax to access the member of the ith structure in the array of
structures is?
Assuming: struct temp
{
int b;
} s[50];
a) s.b.[i];
b) s.[i].b;
c) s.b[i];
d) s[i].b;
Ans:d
19. The size of a union is determined by the size of the __________
a) First member in the union
b) Last member in the union
c) Biggest member in the union
d) Sum of the sizes of all members
Ans: c
Module 4
20. Which is an indirection operator among the following?
a) &
b) *
c) ->
d) .
Ans : b
21. Which of the following are correct file opening modes in C?
a. r
b. rb
c. w
d. All of the above
Ans: d
22. A mode which is used to open an existing file for both reading and writing ______
a) w
b) w+
c) r+
d) a+
Ans:c
23. Select a function which is used to write a string to a file ______
a) puts()
b) putc()
c) fputs()
d) fgets()
Ans:c
24. What is meant by ‘a’ in the following C operation?
fp = fopen("Random.txt", "a");
a) Attach
b) Append
c) Apprehend
d) Add
Ans: b