PPS Question Bank With Unitwise MCQ
PPS Question Bank With Unitwise MCQ
Unit 1
3. For 16-bit compiler allowable range for integer constants is ______ ? [CLO 1] [PLO 2]
A. -3.4e38 to 3.4e38
B. -32767 to 32768
C. -32768 to 32767
D. -32668 to 32667
4. C programs are converted into machine language with the help of [CLO 1] [PLO 1]
A. An Editor
B. A compiler
C. An operating system
D. None of the above
5. A C variable cannot start with [CLO 1] [PLO 1]
A. An alphabet
B. A number
C. A special symbol other than underscore
D. both (b) and (c)
A. object code
B. machine code
C. source program
D. interactive programs
9. Data types are differed on the basis of [CLO 1] [PLO 1]
10. Loop statement which is repeated for some given number of times is classified as [CLO 1]
A. FOR loop
B. GO loop
C. REPEAT loop
D. GO REPEAT loop
11. Type of statement written in sequence and is repeated until the specific condition met is
classified as [CLO 1] [PLO 1]
A. format
B. loop
C. case
D. condition
A. programmer
B. program users
C. software
D. declared automatically
A. formula translator
B. formula translation
C. free translator
D. free translation
14. Functions that are used in the programs and are defined by the programmers are called
[CLO 1] [PLO 2]
A. program layout
B. program procedure
C. built-in functions
D. user-defined function
15. An assembler translates [CLO 1] [PLO 1]
16. Name given by a programmer to any particular data is classified as [CLO 1] [PLO 1]
A. identifier
B. identification
C. exponent
D. mantissa
17.When variable used in program is whole number, the variable is stored as [CLO 1] [PLO 2]
A. fixed string
B. integers
C. negative whole numbers
D. positive whole numbers
19. Variable which uses the same name in whole program and in its all routines thus best classified
as [CLO 1] [PLO 2]
A. middle variable
B. default variable
C. local variable
D. global variable
20. Statement which is used to make choice between two options and only option is to be performed
is written as [CLO 1] [PLO 2]
A. if statement
B. if else statement
C. then else statement
D. else one statement
21. The__________ statement is used to transfer the control to the end of statement block in a loop:
24. Which of the following is true for variable names in C? [CLO 1] [PLO 2]
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names cannot start with a digit
d) Variable can be of any length
25. The format identifier ‘%i’ is also used for _____ data type? [CLO 1] [PLO 2]
a) char
b) int
c) float
d) double
1. #include <stdio.h>
2. int main()
3. {
4. signed char chr;
5. chr = 128;
6. printf("%d\n", chr);
7. return 0;
8. }
a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned
a) 10 b) 11
c) Compile time error d) 0
Explanation : j is not belongs to any data type
30. The keyword ‘break’ cannot be simply used within: [CLO 1] [PLO 3]
a) do-while b) if-else
c) for d) while
31. Which keyword is used to come out of a loop only for that iteration? [CLO 1] [PLO 3]
a) break b) continue
c) return d) none of the mentioned
32. The first step in problem solving is --------------- [CLO 1] [PLO 2]
a) Understand the problem c)Identify the problem
b) Developing algorithm/Flowchart d)Listing the possible outcome
33. The solutions which has series of actions to solve a problem are called ------ [CLO 1] [PLO 2]
a) Heuristic solutions
b) Algorithmic solutions
34. The solution can be reached by completing the actions in steps. These steps are called [CLO 1]
[PLO 2]
a) Sequence c)Algorithm
b) Flowchart d)Steps
35. Solutions that cannot be reached through a direct set of steps are called --------- [CLO 1][PLO 2]
a)Algorithmic solutions b) Heuristic solutions
36. ----------- means the outcome or the completed computer-assisted answer. [CLO 1][PLO 1]
a) Solution b) Result c) Program
37. The field of computer that deals with the problem of heuristic solution is called-----[CLO 1]
[PLO1]
a) Artificial Intelligence
b) Expert System c) Computer Management
38. ----------------- means the set of instructions that make up the solution after they have been coded
into a programming language. [CLO 1] [PLO1]
a) solution b) result c) program d) error
40. A language applied for wide range of application is called as ______language[CLO 1][PLO 2]
41. Compiler converts the source code into ______ [CLO 1][PLO 4]
a. C code b. Byte code c. Object code d. Executable code
42. ___________ converts source code to machine language one line at a time. [CLO 1][PLO 4]
a. Compiler b. Interpreter c. Assembler d.CPU
43. The program that converts high level language to a machine language is called __________
[CLO 1] [PLO 1]
a. Interpreter b. Linker c. Compiler d. Loader
45. A _______ is a notational system for describing computations in both machine and human
readable form [PLO 1] [CLO 1]
a. Programming language c.Machine language
b. High-level language d.Assembly language
46. ----------------- program converts assembly language into machine language [PLO 2] [CLO 1]
a. compiler b. interpreter c. assembler d. preprocessor directive
47. which symbol is been used for processing in flowchart? Ans: a [CLO 1] [PLO 3]
a) b) c) d)
48. which symbol is been used for input/output in flowchart? Ans: c [PLO 3] [CLO 1]
a) b) c) d)
49. which symbol is been used for decision making in flowchart? Ans: d [PLO 3] [CLO 1]
a) b) c) d)
a) b) c) d)
53.A character variable can store how many characters at a time? [PLO 2][CLO 1]
(a) 1 character
(b)8 characters
(c)255 character
54.Which of the following is the correct way of writing comments? [PLO 2] [CLO 1]
(a)*/comments/*
(b)/*comment*/
(c)**comment** (
d){comment}
56.The memory space taken for a char type data is [PLO 2] [CLO 1]
(a)2 bytes
(b)4 bytes
(c)8 bytes
(d)1bytes
57 .The memory space taken for a int type data is [PLO 2] [CLO 1]
(a) 2 bytes
(b) 4 bytes
(c) 8 bytes
(d)10bytes
58.The memory space taken for a float type data is [PLO 2] [CLO 1]
(a) 2 bytes
(b) 4 bytes
(c) 8 bytes
(d)10bytes
59. What is the only function all programs must contain ? [PLO 2] [CLO 1]
(a)start()
(b)system()
(c)main()
(d)program
60.For 16-bit compiler allowable range for integer constants is ________? [PLO 2] [CLO 1]
(a) -3.4e38 to 3.4e38
(b) -32767 to 32768
(c) -32668 to 32667
(d) -32768 to 32767
63.The memory space taken for a long int type data is [PLO 2] [CLO 1]
(a) 2 bytes
(b) 4 bytes
(c) 8 bytes
(d)10bytes
64. which of the following will not valid expressions in C? [PLO2] [CLO 1]
(a) a=2+(b=5);
(b) a=11%3
(c) a=b=c=5
(d) b+5=2
65. The --------------------- operator is true only when both the operands are true. [PLO 2][CLO 1]
a) &&
b) b) ||
c) c)!
d) d) ?:
66. The ---------------------- statement when executed in a switch statement causes immediate exit
from the structure. [CLO 1] [PLO 2]
a)goto
b) default
c) break
d) switch
66. The ternary conditional expression using the operator?: could be easily coded using ----------------
- statement [CLO 1][PLO 2]
a)Nested if b) if-else
c) if d) for
4 Marks :
Unit-1 CLO-1
12 Marks:
7) Write down the algorithm to find the largest number among three given numbers and
outline the steps in the algorithm with the inputs 5, 17, 3. [CLO-1][PLO 2][PLO3]
8) Draw flowchart to compute the salary of an employee in a company. Assume that there are
two types of employees in the company daily wages and regular. Salary is calculated as
number of hours worked* wages per hour for daily wagers and basic pay +(% of DA * basic
pay)/100 + HRA + medical allowance for regular employees. Sketch the flow of your design
for a regular employee with basic pay = 5000, % of DA = 75 % and HRA = 500. (8)
[CLO-1][PLO 2][PLO3][PLO4]
1. The --------------------- operator is true only when both the operands are true.
e) && b) || c)! d) ?:
Answer: a
2. The ---------------------- statement when executed in a switch statement causes immediate exit
from the structure.
a)goto b) default c) break d) switch
Answer: c
3. The ternary conditional expression using the operator?: could be easily coded using ----------------
- statement
a)Nested if b) if-else c) if d) for
Answer: b
4. What will be the output when the following segment is executed?
Char ch=’a’;
Switch(ch)
{
case ‘a’:
Printf(“A”);
case ’b’:
Printf(“B”);
Default:
printf(“C”);
}
a)10 b) 20 c) 15 d)5
Answer: a
6. The ----------------------- statement is used to skip a part of the statements in a loop.
a) Continue b) break c) goto d)switch
Answer: a
7. A for loop with no test condition is known as --------------- loop
a) Infinite b) time delay c) for d) Incrementing
Answer: a
8. The sentinel –controlled loop is also known as -----------------------loop
a) Indefinite repetition loop c) time delay
b) Definite repetition loop d) infinite
Answer: a
9. In an exit controlled loop the body of the loop is always executed minimum number of ------------
a) 1 time b)2 times c) 3 times d)n times
Answer:a
10. The while is an --------------------- loop statement.
a) Entry-controlled b)exit-controlled c)indefinite repetition
d)definite repetition
Answer: a
11. The ------------------specification is used to read or print integers
a)h b)l c)L d)c
Answer: a
12. To print the data left-justified, must use -------------- in the field specification
a) - b) + c) / d) *
Answer: a
13. By default, the real numbers are printed with a precision of --------------- decimal.
a)6 b)2 c)4 d)0
Answer:a
14. The expression !(x!=y) can be replaced by the expression--------------------
a) x!=y b) x==y c)x=!y d)!x=!y
Answer:c
15. In a counter controlled loop, variable known as -----------------is used to count the loop
operations.
a) Counter b)sentinel c)i d)n
Answer: a
B. &&
C. ||
D. !
21 Which of the following cannot be checked in a switch-case statement?
A. Character
B. Integer
C. Float
D. enum
22. What is the output of this C code?
int main()
{
int a = 0, i = 0, b;
for (i = 0;i < 5; i++)
{
a++;
continue;
}
}
A. 2 B. 3
C. 4 D. 5
void main()
{
int i = 0, j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
break;
}
printf("Hi \n");
}
}
A. Hi is printed 5 times B. Hi is printed 9 times
C. Hi is printed 7 times D. Hi is printed 4 times
24. What is the output of this C code?
void main()
{
int i = 0;
int j = 0;
for (i = 0;i < 5; i++)
{
for (j = 0;j < 4; j++)
{
if (i > 1)
continue;
printf("Hi \n");
}
}
}
A. Hi is printed 9 times B. Hi is printed 8 times
C. Hi is printed 7 times D. Hi is printed 6 times
void main()
{
int i = 0;
for (i = 0;i < 5; i++)
if (i < 4)
{
printf("Hello");
break;
}
}
A. Hello is printed 5 times B. Hello is printed 4 times
C. Hello D. Hello is printed 3 times
int main()
{
int i = 0;
char c = 'a';
while (i < 2){
i++;
switch (c) {
case 'a':
printf("%c ", c);
break;
break;
}
}
printf("after loop\n");
}
A. a after loop B. a a after loop
C. after loop D. None of the mentioned
28. int main()
{
printf("before continue ");
continue;
printf("after continue\n");
}
int main()
{
printf("%d ", 1);
goto l1;
printf("%d ", 2);
l1:goto l2;
printf("%d ", 3);
l2:printf("%d ", 4);
}
A. 1 4 B. Compilation error
C. 1 2 4 D. 1 3 4
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = b + c == a;
printf("%d", d);
}
A. Syntax error
B. 1
C. 5
D. 10
int main()
{
int a = 10, b = 5, c = 3;
b != !a;
c = !!a;
printf("%d\t%d", b, c);
}
A. 5 1
B. 0 3
C. 5 3
D. 1 1
d) Array of sixe 20
a) char name[6]={‘I’,’N’,’D’,’I’,’A’,’\0’}
b) char name[6]={“I”,”N”,”D”,”I”,”A”}
c) char name[6]={‘I’,’N’,’D’,’I’,’A’}
c) int n{6}={2,4,12};
d) int n(6)={2,4,12,5,45,5};
a) 3, 2,15
b) 2, 3, 20
c)2, 1, 15
d) 1, 2, 5
Answer: Option A
Solution:
>> int a[5] = {5, 1, 15, 20, 25}; The variable arr is declared as an integer array with a size of 5 and it is initialized to
a[0] = 5, a[1] = 1, a[2] = 15, a[3] = 20, a[4] = 25.
>> m = a[i++]; becomes m = a[2]; Hence m = 15 and i is incremented by 1(i++ means 2++ so i=3)
>> printf("%d, %d, %d", i, j, m); It prints the value of the variables i, j, m
a) 5
b) 6
c) 9
d) Error
a) sequential
b) Random
options:
a) I and II
c) II and III
d) I, III and IV
e) III and IV
Answer: Option D
Solution: int x[10]; * x will store the base address of array. *
Statement I, III and IV is invalid.
Statement I and III : ++x and x++ are throwing en error while compile (lvalue required as increment operand )
Since, x is storing in the address of the array which is static value which cannot be change by the operand.
Statement IV : x*2 is also throw an error while compile (invalid operands to binary * (have 'int *' and 'int') )
Statement II : x+1 is throw a warning: assignment makes integer from pointer without a cast [enabled by
default]
a) 2
b) 8
c) 20
d)50
e) theoretically no limit. the only practical limits are memory size and compilers
b) it's a declaration
c) it is a formal parameter
d) All of these
b) Unequal
c) Error
d) None of these
Answer: Option B
Solution:
Strings are compared using strcmp() function defined under string.h header file.
45)
Unit-2 PART -B
int main()
{
int ch; printf("enter a value between 1 to 2:");
scanf("%d", &ch);
switch (ch, ch -1){
case 1: printf("1\n"); break;
case 2: printf("2"); break;
} return 0; }
8. Explain the limitations of arrays.
9. Give the steps of looping process.
10.Brief the use of continue, goto, break statement and give the syntax.
11.What are loop control structures? Explain for loop, while loop and do-while
loop with their syntax.
12.What do you mean by infinite loop? Give suitable of any infinite loop in a C
program.
13. Explain break and continue statements with examples.
14. Determine the output of the following program justify your answer in a few words.
int main() {
float f = 1.0;
switch(f) {
case 1.0: printf("one"); break;
case 2.0: printf("two"); break;
default: prinf("%f", f);
}}
15.Write a program to print series of number divisible by 3 from 1 to 100 using for
loop.
16.Write a C program to print 1, 2, 4, 8, 16, 32, 64 …..N using do….while loop
(Read N from user).
17.What are Arrays in C programming? Give the importance of Array in C
language
13. What are the rules to declare one dimensional array?
14. What do you mean by compile time initialization? Give suitable example of
Compile time initialization of C Array.
15. Describe the array index out of bound error in context of C array program.
PART C
1) Lucy is celebrating her 15th birthday. Her father promised her that he will buy her a new computer
on her birthday if she solves the question asked by him. He asks Lucy to find whether the year on
which she had born is leap year or not. Help her to solve this puzzle so that she celebrates her
birthday happily. If her birth year is 2016 and it is a leap year display 2016 is a leap year.? Else
display 2016 is not a leap year and check with other leap year conditions
2) Write a C program to print the multiplication table of an integer n upto m rows using a while loop
INPUT
5
4
OUTPUT
1*5=5
2*5=10
3*5=15
4*5=20
4) Write a program that determines a student’s grade. The program will read three scores and
determine the grade based on the following rules: score =90% =>grade=A , score >= 70%
and <90% => grade=B, score>=50% and <70% =>grade=C, score<50% =>grade=F
a)
b)
c)
d)
e)
8) write c Program for Student mark list generation by using control and looping statements
9) write c program for digit rotation. "For any positive integer, we define a digit rotation as either
moving the first digit to the end of the number (left digit rotation), or the last digit to the front of the
number (right digit rotation). For example, the number 12345 could be left digit rotated to 23451, or right
digit rotated to 51234.
11) write c program for palindrome strings , two strings A and B, each consisting of lower case alphabets.
UNIT III
PART A
1 ) Which of the following is not possible statically in C?
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array
a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
d) Run time error
#include <stdio.h>
int main()
{
int arr[5];
return 0;
}
a) 2002
b) 2004
c) 2020
d) lvalue required
4 ) Predict the output of below program:
#include <stdio.h>
int main()
{
int arr[5];
// Assume base address of arr is 2000 and size of integer is 32 bit
printf("%u %u", arr + 1, &arr + 1);
return 0;
}
i. 2004 2020
iv. The program fails to compile because address of operator cannot be used with
array name
6) While passing an array as an actual argument, the function call must have the array name
A. with empty brackets
A.call by value
B.call by value-result
C.call by reference
D.none of these
8) Under which of the following conditions, the size of an one-dimensional array need not be
specified?
A.when initialization is a part of definition
B.when it is a declaration
B.It is a collection of items that share a common name and occupy consecutive memory location
C.It is a collection of items of the same type and storage class that share a common name and
occupy consecutive memory locations
D.None of the above
1. #include <stdio.h>
2. void main()
3. {
4. int a[2][3] = {1, 2, 3, 4, 5};
5. int i = 0, j = 0;
6. for (i = 0; i < 2; i++)
7. for (j = 0; j < 3; j++)
8. printf("%d", a[i][j]);
9. }
a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
d) Run time error
Answer: a
1. #include <stdio.h>
2. void main()
3. {
4. int a[2][3] = {1, 2, 3, , 4, 5};
5. int i = 0, j = 0;
6. for (i = 0; i < 2; i++)
7. for (j = 0; j < 3; j++)
8. printf("%d", a[i][j]);
9. }
a) 1 2 3 junk 4 5
b) Compile time error
c) 1 2 3 0 4 5
d) 1 2 3 3 4 5
Answer: b
15. What is the output of this C code?
1. #include <stdio.h>
2. void f(int a[][3])
3. {
4. a[0][1] = 3;
5. int i = 0, j = 0;
6. for (i = 0; i < 2; i++)
7. for (j = 0; j < 3; j++)
8. printf("%d", a[i][j]);
9. }
10. void main()
11. {
12. int a[2][3] = {0};
13. f(a);
14. }
a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: a
1. #include <stdio.h>
2. void f(int a[][])
3. {
4. a[0][1] = 3;
5. int i = 0, j = 0;
6. for (i = 0;i < 2; i++)
7. for (j = 0;j < 3; j++)
8. printf("%d", a[i][j]);
9. }
10. void main()
11. {
12. int a[2][3] = {0};
13. f(a);
14. }
a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: c
1. #include <stdio.h>
2. void f(int a[2][])
3. {
4. a[0][1] = 3;
5. int i = 0, j = 0;
6. for (i = 0;i < 2; i++)
7. for (j = 0;j < 3; j++)
8. printf("%d", a[i][j]);
9. }
10. void main()
11. {
12. int a[2][3] = {0};
13. f(a);
14. }
a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
Answer: c
int (*a)[7];
a) An array “a” of pointers.
b) A pointer “a” to an array.
c) A ragged array.
d) None of the mentioned
Answer: b
1. int *a1[8];
2. int *(a3[8]);
3. P. Array of pointers
4. Q. Pointer to an array
a) a1 is P, a2 is Q
b) a1 is P, a2 is P
c) a1 is Q, a2 is P
d) a1 is Q, a2 is Q
Answer: b
Answer: a
21. What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)
a) func(a);
b) func(&a);
c) func(*a);
d) func(**a);
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. int ary[2][3];
5. foo(ary);
6. }
7. void foo(int *ary[])
8. {
9. int i = 10, j = 2, k;
10. ary[0] = &i;
11. ary[1] = &j;
12. *ary[0] = 2;
13. for (k = 0;k < 2; k++)
14. printf("%d\n", *ary[k]);
15. }
a) 2 2
b) Compile time error
c) Undefined behaviour
d) 10 2
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. int ary[2][3];
5. foo(ary);
6. }
7. void foo(int (*ary)[3])
8. {
9. int i = 10, j = 2, k;
10. ary[0] = &i;
11. ary[1] = &j;
12. for (k = 0;k < 2; k++)
13. printf("%d\n", *ary[k]);
14. }
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. foo(ary);
5. }
6. void foo(int **ary)
7. {
8. int i = 10, k = 10, j = 2;
9. int *ary[2];
10. ary[0] = &i;
11. ary[1] = &j;
12. printf("%d\n", ary[0][1]);
13. }
a) 10
b) 2
c) Compile time error
d) Undefined behaviour
Answer: d
1. #include <stdio.h>
2. int main()
3. {
4. int ary[2][3][4], j = 20;
5. ary[0][0] = &j;
6. printf("%d\n", *ary[0][0]);
7. }
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. int ary[2][3];
5. ary[][] = {{1, 2, 3}, {4, 5, 6}};
6. printf("%d\n", ary[1][0]);
7. }
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. void foo();
5. printf("1 ");
6. foo();
7. }
8. void foo()
9. {
10. printf("2 ");
11. }
a) 1 2
b) Compile time error
c) 1 2 1 2
d) Depends on the compiler
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. void foo(), f();
5. f();
6. }
7. void foo()
8. {
9. printf("2 ");
10. }
11. void f()
12. {
13. printf("1 ");
14. foo();
15. }
Answer: b
1. #include <stdio.h>
2. int main()
3. {
4. void foo();
5. void f()
6. {
7. foo();
8. }
9. f();
10. }
11. void foo()
12. {
13. printf("2 ");
14. }
a) 2 2
b) 2
c) Compile time error
d) Depends on the compiler
Answer: d
Explanation: Even though the answer is 2, this code will compile fine only with gcc. GNU C supports nesting of functions in C
as a language extension whereas standard C compiler doesn’t.
31. What is the output of this C code?
1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo();
6. foo();
7. return 0;
8. }
9. void foo()
10. {
11. printf("2 ");
12. }
a) Compile time error
b) 2
c) Depends on the compiler
d) Depends on the standard
Answer: b
1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo(int);
6. foo(1);
7. return 0;
8. }
9. void foo(int i)
10. {
11. printf("2 ");
12. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
Answer: a
1. #include <stdio.h>
2. void foo();
3. int main()
4. {
5. void foo(int);
6. foo();
7. return 0;
8. }
9. void foo()
10. {
11. printf("2 ");
12. }
a) 2
b) Compile time error
c) Depends on the compiler
d) Depends on the standard
Answer: b
1. include <stdio.h>
2. void m()
3. {
4. printf("hi");
5. }
6. void main()
7. {
8. m();
9. }
a) hi
b) Run time error
c) Nothing
d) Varies
Answer: a
1. #include <stdio.h>
2. void m();
3. void n()
4. {
5. m();
6. }
7. void main()
8. {
9. void m()
10. {
11. printf("hi");
12. }
13. }
a) hi
b) Compile time error
c) Nothing
d) Varies
Answer: b
Answer: c
Answer: d
38. What is the output of this code having void return-type function?
1. #include <stdio.h>
2. void foo()
3. {
4. return 1;
5. }
6. void main()
7. {
8. int x = 0;
9. x = foo();
10. printf("%d", x);
11. }
a) 1
b) 0
c) Runtime error
d) Compile time error
Answer: d
39. What will be the data type returned for the following function?
1. #include <stdio.h>
2. int func()
3. {
4. return (double)(char)5.0;
5. }
a) char
b) int
c) double
d) multiple type-casting in return is illegal
Answer: b
Answer: d
1. #include <stdio.h>
2. void main()
3. {
4. int k = m();
5. printf("%d", k);
6. }
7. void m()
8. {
9. printf("hello");
10. }
a) hello 5
b) Error
c) Nothing
d) Junk value
Answer: a
1. #include <stdio.h>
2. int *m()
3. {
4. int *p = 5;
5. return p;
6. }
7. void main()
8. {
9. int *k = m();
10. printf("%d", k);
11. }
a) 5
b) Junk value
c) 0
d) Error
Answer: a
1. #include <stdio.h>
2. int *m();
3. void main()
4. {
5. int *k = m();
6. printf("hello ");
7. printf("%d", k[0]);
8. }
9. int *m()
10. {
11. int a[2] = {5, 8};
12. return a;
13. }
a) hello 5 8
b) hello 5
c) hello followed by garbage value
d) Compilation error
Answer: c
Part B
1. What is the need for user defined function?
2. Write a multi function program
3. List the Elements of user defined function
4. Give short note on 2-D array processing.
5. Write a C program to find the length of a string.
6. HELLO encode it as IFMMP using array
7. Show the difference between actual and formal parameter in function with piece of code
int main(){
inta[][]={{1,2},(3,4}};
int i,j;
for (i=0;i<2;i++)
for(j=0;j<2;j++)
printf(“%d”,a[i][j]);
retorn 0;
}
15. Why array index starts from zero?
16. Contrast function declaration vs function definition.
17. List the advantages of functions.
nd
18. Program to Find the 2 Largest Elements in an Array.
19. Write a program to convert the given string (srm university) Lower to upper case
b. Write a program to perform Matrix addition and Multiplication using 2-D arrays
12. i) State the importance of functions. List out the different types of Function
ii) Write a swap function using call by value and call by reference
iii) Write a C program to concatenate two strings.
iv) Write a program to read to strings and compare them and print a message that the first string
is equal, less or greater than the second one accordingly.
13. Write c program for Matrix addition and Matrix Transpose using multi dimensional array
14. Given a number , find whether it is a power of 2 or not
15. Write a C program to swap elements in cyclic order using call by reference.
UNIT 4
1. #include <stdio.h>
2. void foo(int*);
3. int main()
4. {
5. int i = 10;
6. foo((&i)++);
7. }
8. void foo(int *p)
9. {
10. printf("%d\n", *p);
11. }
a) 10
b) Some garbage value
c) Compile time error
d) Segmentation fault/code crash
Answer: c
1. #include <stdio.h>
2. void foo(int*);
3. int main()
4. {
5. int i = 10, *p = &i;
6. foo(p++);
7. }
8. void foo(int *p)
9. {
10. printf("%d\n", *p);
11. }
a) 10
b) Some garbage value
c) Compile time error
d) Segmentation fault
Answer: a
3. What is the output of this C code?
1. #include <stdio.h>
2. void foo(float *);
3. int main()
4. {
5. int i = 10, *p = &i;
6. foo(&i);
7. }
8. void foo(float *p)
9. {
10. printf("%f\n", *p);
11. }
a) 10.000000
b) 0.000000
c) Compile time error
d) Undefined behaviour
Answer: b
1. #include <stdio.h>
2. int main()
3. {
4. int i = 97, *p = &i;
5. foo(&i);
6. printf("%d ", *p);
7. }
8. void foo(int *p)
9. {
10. int j = 2;
11. p = &j;
12. printf("%d ", *p);
13. }
a) 2 97
b) 2 2
c) Compile time error
d) Segmentation fault/code crash
Answer: a
a) 2 2
b) 2 97
c) Undefined behaviour
d) Segmentation fault/code crash
Answer: a
1. #include <stdio.h>
2. int main()
3. {
4. int i = 11;
5. int *p = &i;
6. foo(&p);
7. printf("%d ", *p);
8. }
9. void foo(int *const *p)
10. {
11. int j = 10;
12. *p = &j;
13. printf("%d ", **p);
14. }
1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. int *p = &i;
6. foo(&p);
7. printf("%d ", *p);
8. printf("%d ", *p);
9. }
10. void foo(int **const p)
11. {
12. int j = 11;
13. *p = &j;
14. printf("%d ", **p);
15. }
a) 11 11 11
b) 11 11 Undefined-value
c) Compile time error
d) Segmentation fault/code-crash
Answer: b
1. #include <stdio.h>
2. int main()
3. {
4. int i = 10;
5. int *const p = &i;
6. foo(&p);
7. printf("%d\n", *p);
8. }
9. void foo(int **p)
10. {
11. int j = 11;
12. *p = &j;
13. printf("%d\n", **p);
14. }
a) 11 11
b) Undefined behaviour
c) Compile time error
d) Segmentation fault/code-crash
Answer: a
9. Which of the following are correct syntaxes to send an array as a parameter to function:
a) func(&array);
b) func(#array);
c) func(*array);
d) func(array[size]);
Answer: a.
1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. printf("%d%d%d\n", k, *p, **m);
8. }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Run time error
Answer: a
1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. printf("%d%d%d\n", k, *p, **p);
8. }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: d.
13. What is the output of this C code?
1. #include <stdio.h>
2. void main()
3. {
4. int k = 5;
5. int *p = &k;
6. int **m = &p;
7. **m = 6;
8. printf("%d\n", k);
9. }
a) 5
b) Compile time error
c) 6
d) Junk
Answer: c
1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. int *r = &p;
7. printf("%d", (**r));
8. }
a) 1
b) Compile time error
c) Address of a
d) Junk value
Answer: b
1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. int **r = &p;
7. printf("%p %p", *r, a);
8. }
Answer: d
1. #include <stdio.h>
2. int main()
3. {
4. int a = 1, b = 2, c = 3;
5. int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
6. int **sptr = &ptr1; //-Ref
7. *sptr = ptr2;
8. }
a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) None of the mentioned
Answer: b
1. #include <stdio.h>
2. void main()
3. {
4. int a[3] = {1, 2, 3};
5. int *p = a;
6. int **r = &p;
7. printf("%p %p", *r, a);
8. }
Answer: c
PART B
PART C
1) i) c program to read array elements and print the values with their address
ii) what is Pointers and address operator, explain with an example of Size of Pointer Variable and
Pointer, Operator
2) Explain in details with an example Pointer Declaration and dereferencing, pointers, Void Pointers and
size of Void Pointers
3) write program for Arithmetic Operations, Incrementing Pointers
4) what is Constant Pointers, Pointers to array elements and strings
6write the c program for Accessing Array of Function Pointers, Null Pointers
7) Justify and explain the different size of data types using pointer variables with example program.
ii) Write call by reference and call by value with an example program
UNIT 5
Part A
Answer: d
Answer: c
Answer: b
Answer: d
1. #include <stdio.h>
2. struct student
3. {
4. int no;
5. char name[20];
6. }
7. void main()
8. {
9. struct student s;
10. s.no = 8;
11. printf("hello");
12. }
Answer: a
1. #include <stdio.h>
2. struct student
3. {
4. int no = 5;
5. char name[20];
6. };
7. void main()
8. {
9. struct student s;
10. s.no = 8;
11. printf("hello");
12. }
a) Nothing
b) Compile time error
c) hello
d) Varies
Answer: b
1. #include <stdio.h>
2. struct student
3. {
4. int no;
5. char name[20];
6. };
7. void main()
8. {
9. student s;
10. s.no = 8;
11. printf("hello");
12. }
a) Nothing
b) hello
c) Compile time error
d) Varies
Answer: c
1. #include <stdio.h>
2. void main()
3. {
4. struct student
5. {
6. int no;
7. char name[20];
8. };
9. struct student s;
10. s.no = 8;
11. printf("%d", s.no);
12. }
a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: d
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int main()
9. {
10. struct p x = {.c = 97, .f = 3, .k = 1};
11. printf("%f\n", x.f);
12. }
a) Yes
b) No
c) Depends on the standard
d) Depends on the platform
Answer: c
1. #include <stdio.h>
2. void main()
3. {
4. struct student
5. {
6. int no;
7. char name[20];
8. };
9. struct student s;
10. no = 8;
11. printf("%d", no);
12. }
a) Nothing
b) Compile time error
c) Junk
d) 8
Answer: b
1. #include <stdio.h>
2. struct test
3. {
4. int k;
5. char c;
6. };
Answer: a
1. #include <stdio.h>
2. struct
3. {
4. int k;
5. char c;
6. };
7. int main()
8. {
9. struct p;
10. p.k = 10;
11. printf("%d\n", p.k);
12. }
1. #include <stdio.h>
2. struct
3. {
4. int k;
5. char c;
6. } p;
7. int p = 10;
8. int main()
9. {
10. p.k = 10;
11. printf("%d %d\n", p.k, p);
12. }
Answer: a
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. };
7. int p = 10;
8. int main()
9. {
10. struct p x;
11. x.k = 10;
12. printf("%d %d\n", x.k, p);
13. }
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int p = 10;
9. int main()
10. {
11. struct p x = {1, 97};
12. printf("%f %d\n", x.f, p);
13. }
Answer: b
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int main()
9. {
10. struct p x = {.c = 97, .f = 3, .k = 1};
11. printf("%f\n", x.f);
12. }
a) 3.000000
b) Compile time error
c) Undefined behaviour
d) 1.000000
Answer: a
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int main()
9. {
10. struct p x = {.c = 97, .k = 1, 3};
11. printf("%f \n", x.f);
12. }
a) 3.000000
b) 0.000000
c) Compile time error
d) Undefined behaviour
Answer: b
1. #include <stdio.h>
2. struct p
3. {
4. int k;
5. char c;
6. float f;
7. };
8. int main()
9. {
10. struct p x = {.c = 97};
11. printf("%f\n", x.f);
12. }
a) 0.000000
b) Somegarbagevalue
c) Compile time error
d) None of the mentioned
Answer: a
PART B
PART C
1) explain in details about Bit Manipulation to structure and Pointer, to structure, Union Basic and
declaration with an example
2) explain in details about Accessing Union Members Pointers to Union, Dynamic memory allocation,
mallaoc, realloc, free with an example
3) explain in details about Allocating Dynamic Array, Multidimensional array using dynamic memory
allocation with an example
4) Explain in details about array of structures and accessing elements in a structure array.
18) a) i) Explain in details about array of structures and accessing elements in a structure array.
19) i) write a program to copy the content from one file to another file
ii) explain and write the program for library management system using union
SRM Institute of Science and Technology, Ramapuram
Department of Computer Science and Engineering
UNIT 1 MCQ
a) Rectangle
b) Diamond
c) Circle
d) Parallelogram
Ans B
4. In the below mentioned operators, which of the following has the highest precedence?
a) Unary +
b) *
c) >=
d) ==
Answer: a
counter = 2
while counter < 68
puts counter
counter**=2
end
a) 2 4 16 64
b) 2 4 16
c) 2 4 16 256
d) None of the mentioned
Answer: b
#include <stdio.h>
void main()
{
int x = 4;
int *p = &x;
int *k = p++;
int r = p - k;
printf("%d", r);
}
a) 4
b) 8
c) 1
d) Run time error
Answer: c
10. Among the following options, which is not a valid representation in bits?
a) 8-bit
b) 24-bit
c) 32-bit
d) 64-bit
Answer: b
11. Name the entities whose values can be changed?
a) Constants
b) Variables
c) Modules
d) Tokens
Answer: b
15. Name the correct ways to set a value as 3.14 in a variable pi such that it cannot be modified?
a) float pi = 3.14F;
b) #define pi 3.14F;
c) const float pi = 3.14F;
d) const float pi; pi = 3.14F;
e) pi = 3.14F;
Answer: C
16. why the variable names beginning with underscore is not encouraged?
a) It is not standard form
b) To avoid conflicts since assemblers and loaders use such names
c) To avoid conflicts since library routines use such names
d) To avoid conflicts with environment variables of an operating system
Ans:c
18. Which among the following options is true for the variable names in C?
a) They can contain alphanumeric characters as well as special characters
b) It is not an error to declare a variable to be one of the keywords(like goto, static)
c) Variable names can’t start with a digit
d) Variable can be of any length
Ans:c
int main()
{
char chr;
chr = 128;
printf("%d\n", chr);
return 0;
}
a) 128
b) – 128
c) Depends on the compiler
d) None of the mentioned
Answer: Option B
Answer: A
Ans: d
29. Scope of which of these in C is not local to the block in which it is defined
a) automatic storage class
b) register storage class
c) static storage class
d) external storage class
Ans d
34. Name the method which uses a list of well-defined instructions to complete a task
a) Algorithm
b) Flowchart
c) Programs
d) Functions
Ans C
a) Debugging
b) Refixing
c) Error Checking
d) Problem Solving
Ans a
39. Many features of C were derived from an earlier language called _____.
a) FORTRAN
b) BASIC
c) B
d) PASCAL
Ans C
1. Does rational operators in the C language are calculated with the short circuit?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
Answer: a
Answer: b
#include <stdio.h>
int main()
{
int a = 20, b = 10, c = 10;
int d;
d = b + c == a;
printf("%d", d);
}
a)Syntaxerror
b1
c)5
d) 10
Answer: b
4. What will be the output of the following C program.
#include<stdio.h>
int main()
{ int a=-1, b=1, c, d;
c = !a && b;
d = !a || b;
printf("%d %d %d %d",a,b,c,d);
return 0;
}
a) -1 1 1 0
b) -1 1 0 0
c) -1 1 1 1
d) -1 1 0 1
Ans:- d
Answer: d
6. Relational operators will not be used in ____________
a) structure
b) long
c) strings
d) float
Answer: a
7. Which are the operators used to relate the values of operands to create logical value in C
language?
a) Logical operator
b) Relational operator
c) Assignment operator
) None of the above
Answer: b
8. In the following operators which one performs processes on data in binary level?
a)Logical operator
b)Bitwise operator
c) Additional operators
d)None of the above
Answer: b
9. How many number of operands needed to unary operator logical not (!)?
a)4
b)3
c)2
d)1
Answer: d
Answer: d
11. Which group has higher priority between (>,<=,<,<==) and (==,!=)?
Answer: b
12. The || and && operators
Answer: C
13. Increment operators need L-value Expression What will be the output of the following
program?
#include<stdio.h>
int main()
{ int i = 10;
printf("%d", ++(-i));
return 0;
}
A) 11
B) 10
C) -9
D) None – l-value required
Answer: D
14. What will be the output of the following C program?
#include <stdio.h>
int main()
{ int a = 3, b = -8, c = 2;
printf("%d", a % b / c);
return 0; }
A) 1
B) 15
C) -9
D) 12
Answer: A
#include <stdio.h>
void main()
{ double x = 123828749.66;
int y = x;
printf("%d\n", y);
printf("%lf\n", y);}
a) 0, 0.0
b) 123828749, 123828749.66
c) 12382874, 12382874.0
d) 123828749, 0.000000
Answer: d
16. Which of the following selection statement test only equality?
a) if
b) switch
c) if & switch
d) none of the mentioned
Answer: b
17. Which of the following will execute the body of loop condition is false?
a) do-while
b) while
c) for
d) none of the mentioned
Answer: a
Answer: b
19. The break statement is used to quite from:
a. DO loop
b. FOR loop
c. SWITCH SATEMENT
d. All of above.
Answer: d
Answer: b
Answer: a
a. To permit two dissimilar expressions to appear in condition where only one expression
would ordinarily use.
b. to dismiss loops or to exit from a switch.
c. an unconditional transfer of control to a named label.
d. to carry out a logical test and then take one of two possible actions, depending upon the
outcome of a test.
Answer: c
23. What is an Array in C language?
Answer :d
24. An array Index starts with?
A) -1
B) 0
C) 1
D) 2
Answer :b
Answer : A
Answer: c
Answer: d
28. What are the disadvantages of arrays?
Answer: b
Answer: a
int main()
{char str[]={"C","A","T","\0"};
printf("%s",str);
return 0;}
A) C
B) CAT
C) CAT\0
D) Compiler error
Answer: D
int main()
{ char *p1 = "GOAT";
char *p2;
p2 = p1;
p2="ANT";
printf("%s", p1);
}
A) ANT
B) GOAT
C) G
D) A
Answer: B
34. In an array starting from the beginning and inspecting each element one after other for
finding an object, until the object is found is called as
A. Linear search algorithm
B. Searching
C. Inspecting
D. All of them
Answer: A
38. Array comprising elements are numbered as 0,1,2,3? These numbers are called as
A. Subscripts of the array
B. Index values
C. Members of an array
D. Both A and B
Answer: d
#include<stdio.h>
void main()
{
int m[5]={10,20,30,40,50);
int a,b,c;
a=++m[1];
b=m[1]++
c=m[i++];
printf(“%d,%d,%d”,a,b,c);
}
A. 21,20,30
B. 20,21,30
C. 22,21,30
D. 20,21,40
Answer : C
40. What will be the resulting array after rotating arr[]={2, 4, 6, 8, 10} by 2?
A. 4, 6, 8, 10, 2
B. 10, 2, 4, 6, 8
C. 8, 10, 2, 4, 6
D. 6, 8, 10, 2, 4
Answer : D
Answer : C
Answer : B
Answer : A
44. Maximum number of dimensions an array have
A. 8
B. 4
C. No limit
D. 50
Answer : C
Answer : A
UNIT 3 MCQ
3. Two compare the two strings which of the following one is used
(A) Strcmp ()
(B) Strcpy ()
(C) Stcp()
(D) Stcmp()
Answer: A
8. ---------- character type is used for indicating the terminator of the string.
(A) Float
(B) Int
(C) Null
(D) String
Answer: C
#include <stdio.h>
int main()
ARRAY1(ary);
int *ary[2];
ary[0] = &i;
ary[1] = &j;
printf("%d\n", ary[0][1]);
a.22
c. Undefined behavior
d.102
Answer: c
#include <stdio.h>
int main()
int ary[2][3];
printf("%d\n", ary[1][0]);
return 0;
a. 4
c.2
d.1
Answer: a
c. A ragged array
Answer: b
int *x1[8];
int *(x2[8]);
M. Array of pointers
N. Pointer to an array
A) x1 is M x1 is N
B) x1 is M, x2 is M
C) x1 is N, x2 is M
D) x1 is N, x2 is N
Answer: b
a. Jagged array
b. Rectangular array
c. Cuboidal array
d. Multidimensionl Array.
Answer:D
void main()
int i = 0, j = 0;
printf("%d", a[i][j]);
a.135790
b.13579junk
c.135799
Answer: a
#include <stdio.h>
int main()
printf("equal");
else
printf("unequal");
a.equal
b.Unequal
c.Compilation errot
Answer: b
#include <stdio.h>
int main()
printf("%d", strlen(str));
a. Compilation error
b. Undefined behavior
c.12
d.11
Answer: c
a. strcmp()
b. strcat()
c. strcpy()
d. strrev()
Answer: b
Answer: a
c. int[][] code={1,2,
3,4,5};
d. all
Answer: A
23. The function function1 is called __________ if it calls the same function function1.
A. indirect recursive
B. direct recursive
C. Both A and B
D. None of the above
Answer : B
A. TRUE
B. FALSE
C. Can be true or false
D. Can not Say
Answer : A
#include<stdio.h>
main()
int n;
n=f1(3);
printf("%d",n);
f1(int x)
int b;
if(x==1)
return 1;
else
b=x*f1(x-1);
return b;
a.6
b.4
c.12
d.10
Answer: a
f(int a,int b)
{
int b;
a = 20;
return a;
}
c. Redeclaration if b
d. No error
Answer:c
27. It is essential to declare the sort of a function within the calling program on the off chance that
the function
a.Returns an integer
d.None of these.
Answer:b
Answer: A
29. If the two strings are not identical, then strcmp() function returns
a. -1
b. 0
c. 1
d. Yes
Answer: c
30.What is the Format specifier used to print a integer array in C Printf or Scanf function.?
A) %c
B) %C
C) %s
D) %d
Answer:D
int main()
printf("%s",ary);
return 0;
}
A) S
B) SRM
C) SRMIST
D) SRM IST
Answer : D
char str[]={'g','o','o','d'};
A) str[4] = 0;
B) str[4] = '\0'
C) str[]={'g','o','o','d','\0'};
Answer : D
int main()
char str[]={"G","O","D","\0"};
printf("%s",str);
return 0;
A) Compiler error
B) GOD
C) GOD\0
D)G
Answer : A
int main()
char str[100];
scanf("%s", str);
printf("%s",str);
return 0;
A) WEST
B) WEST INDIES
C)W
D) Compiler error
Answer : D
int main()
FUN();
printf("LTD ");
return 0;
}
void FUN()
printf("HDFC ");
A) HDFC LTD
B) LTD HDFC
C) LTD
D) Compiler error
Answer : D
D) Maximum of 8 values
Answer: A
A) Library Functions
D) None
Answer: C
A) 12
B) 24
C) 56
D) No limit
Answer: D
A) 1
B)3
C) 4
D) 2
Answer: A
A) main()
B) show()
C) scanf()
D) printf()
Answer: A
UNIT 4 MCQ
1. How will you declare the function which is intended to receive an array as an argument
a. return_type function(type arrayname[])
b. return_type function(type arrayname[SIZE])
c. return_type function(type *arrayname)
d. All of the above
Ans: d
2. To store the array returned from the function, we can define a ______ which points to
that array.
a. Structure
b. Array
c. Pointer
d. List
Ans: c
3. The difference between Actual Parameters and Formal Parameters is that Actual
Parameters are the values that are ________ the function when it is invoked while Formal
Parameters are the variables defined by the function that _________ values when the
function is called.
a. Passed to, receives
b. Received by, pass
c. Prints, process
d. Process, prints
Ans: a
Ans: d
Ans: a
Ans: d
Ans: b
13. Identify the value that gets printed in the following program
#include <stdio.h>
int main()
{
int a=10; //variable declaration
int *p; //pointer variable declaration
p=&a; //store address of variable a in pointer p
printf("Address stored in a variable p is:%x\n",p); //accessing the address
printf("Value stored in a variable p is:%d\n",**p); //accessing the value
return 0;
}
a. 10 10
b. 10, 60ff08
c. 60ffd, 10
d. None of the above
Ans: a
Ans: c
15. A pointer to void means a ________ pointer that can point to any data type.
a. Specific
b. Generic
c. Exact
d. Null
Ans: b
16. Select the possible arithmetic operations are applicable on the pointer in C language:
a. Increment, Decrement
b. Addition, Subtraction
c. Comparison
d. All of the above
Ans: d
#include<stdio.h>
void main ()
{
int arr[5] = {1, 2, 3, 4, 5};
int *p = arr;
int i;
printf("printing array elements...\n");
for(i = 0; i< 5; i++)
{
printf("%d ",*(p+i));
}
}
a. 1, 2, 3, 4, 5
b. 5, 4, 3, 2, 1
c. 1, 2, 3, 5, 8
d. None of the above
Ans: a
Ans: d
#include<stdio.h>
int addition ();
int main ()
{
int result;
int (*ptr)();
ptr = &addition;
result = (*ptr)();
printf("The sum is %d",result);
}
int addition()
{
int a=5, b=2;
return a+b;
}
a. 10
b. 3
c. 7
d. 25
Ans: c
20. A ______ pointer in C cannot change the address of the variable to which it is pointing
a. Fixed
b. Null
c. Void
d. Constant
Ans: d
21. An array of pointers to strings is an array of character pointers where each pointer points
to the ________ of the string or the __________ of the string.
a. first character, base address
b. last character, last address
c. middle character, middle address
d. None of the above
Ans: a
22. A function pointer points to _____, not ____.
a. data, code
b. code, data
c. type, const
d. None of the above
Ans: b
23. Identify the correct function pointer declaration:
a. int * foo(int)
b. int (*foo)(int);
c. int (int)(*foo)
d. None of the above
Ans: b
24. What is the output of the given program:
#include <stdio.h>
void Hi_function (int times); /* function */
int main() {
void (*function_ptr)(int); /* function pointer Declaration */
function_ptr = Hi_function; /* pointer assignment */
function_ptr (3); /* function call */
return 0;}
void Hi_function (int times) {
int k;
for (k = 0; k < times; k++) printf("Hi");}
a. Hi HiHiHiHiHi
b. Hi HiHiHiHi
c. Hi HiHiHi
d. Hi HiHi
Ans. d
25. What is the output of the given program:
#include <stdio.h>
void* cube (const void* num);
int main() {
int x, cube_int;
x = 4;
cube_int = cube (&x);
printf("%d cubed is %d\n", x, cube_int);
return 0;}
Ans. d
a) newtonalanalan
b) run tiime error
c) alanalan newton
d) no error
Answer: a
Answer: D
Answer:D
a)0
b10 20
c) 10 0
d) (Garbage Value) 10
Answer:C
a) s1 = s2;
b) s1 =! s2;
c) (*s1).number = 50;
d) None of the mentioned
Answer: D
6. Which operation is illegal in structures?
a) Typecasting of structure
b) none
c) Dynamic allocation of memory for structure
d) All
Answer: A
a) Syntax Error
b) Structure
c) float data type
d) variable name
Answer:B
Answer:C
9. What will be the output of the program?
#include <stdio.h>
struct point
{
int x;
int y;
};
int main()
{
struct point p = {1};
struct point p1 = {1};
if(p == p1)
printf("equal\n");
else
printf("not equal\n");
}
Answer: a
Answer: a
Answer: a
Answer: a
Answer: a
Answer: a
a) Compiletime error
b) alan
c) Run time error
d) code crash
Answer: b
17. What is the correct syntax to access the member of the ith structure?
Assuming: struct temp
{
int b;
}s[50];
a) s.b.[i];
b) b[i].s;
c) b[i];
d) s[i].b;
Answer: d
Answer: a
Answer:D
20. What is the correct syntax to declare a function foo() which receives an array of structure in
function?
a) void foo(struct *var);
b) void foo(struct.var);
c) void(struct(var));
d) none
Answer: a
a) 8
b) 12
c)30
d) Can’t be estimated
Answer: b
a) alanalanalanturing
b) alanturingturing
c) alanturingturing
d) run time error
Answer: a
a)Runtime error
b) Compile time error
c) Varies
d) None
Answer: b
24. What is the output of the program?
#include <stdio.h>
struct student
{
char *name;
};
void main()
{
struct student s[2], r[2];
s[1] = s[0] = "alan";
printf("%s%s", s[0].name, s[1].name);
}
a) alanalan
b) None
c) Compile time error
d) Runtime error
Answer: c
a) 1
b) 8
c) 10
d) 0
Answer: d
Answer: b
#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4};
foo(p1);
}
void foo(struct point p[])
{
printf("%d\n", p->x);
}
a) 1
b) 2
c) 4
d) Run time error
Answer: a
a) 2 4
b) 2 2
c) Compile time error
d) Undefined
Answer: b
a) 1 0
b) Run time error
c) garbage value
d) Undefined
Answer: a
Answer: c
Answer: a
32. What is the output of the program?
#include <stdio.h>
struct point
{
int x;
int y;
};
void foo(struct point*);
int main()
{
struct point p1[] = {1, 2, 3, 4, 5};
foo(p1);
}
void foo(struct point p[])
{
printf("%d %d\n", p->x, (p + 2)->y);
}
a) Runtime error
b) 1 0
c) garbagevalue
d) undefined
Answer: b
Answer: d
34. What is the output of the program?
#include <stdio.h>
struct p
{
int x;
char y;
};
int main()
{
struct p p1[] = {1, 92, 3, 94, 5, 96};
struct p *ptr1 = p1;
int x = (sizeof(p1) / 3);
if (x == sizeof(int) + sizeof(char))
printf("%d\n", ptr1->x);
else
printf("falsen");
}
Answer: d
Answer: c
36. What is the output of the program?
#include <stdio.h>
struct p
{
int x;
char y;
};
typedefstruct p* q*;
int main()
{
struct p p1[] = {1, 92, 3, 94, 5, 96};
q ptr1 = p1;
printf("%d\n", ptr1->x);
}
Answer: a
Answer: a.
Answer: a
Answer: d