Pps - Question Bank
Pps - Question Bank
1
6. Which of the following is allowed in a C Arithmetic Instruction?
A. []
B. {}
C. ()
D. ||
Ans: C
10. Loop statement which is repeated for some given number of times is classified as ______
A. FOR loop
B. GO loop
C. REPEAT loop
D. GO REPEAT loop
Ans: A
11. Type of statement written in sequence and is repeated until the specific condition met is
classified as
A. format
B. loop
C. case
D. condition
Ans: B
2
13.______ comment is correct s about the ++ operator among the following
A.It is not an unary operator
B.The operator can come between the operands
C.operand It can be applied to an expression
D.It associates from the right
Ans: D
14. Functions that are used in the programs and are defined by the programmers are called
A. program layout
B. program procedure
C. built-in functions
D. user-defined function
Ans: D
17. The ternary conditional expression using the operator?: could be easily coded using ------------
----- statement
a) Nested if
b) if-else
c) if
d) for
Ans: b
18. The ---------------------- statement when executed in a switch statement causes immediate exit
from the structure.
a)goto
b) default
c) break
d) switch
Ans: c
19. Variable which uses the same name in whole program and in its all routines thus best
classified as
3
A. middle variable
B. default variable
C. local variable
D. global variable
Ans: D
20. Statement which is used to make choice between two options and only option is to be
performed is written as
A. if statement
B. if else statement
C. then else statement
D. else one statement
Ans: A
21. The__________ statement is used to trAnsfer the control to the end of statement block in a
loop:
a. Continue
b. Break
c. Switch
d. Goto
Ans b
25. The format identifier ‘%i’ is also used for _____ data type?
a) char
b) int
c) float
d) double
Ans: b
4
a. Will be stopped if one of its components evaluates to false
b. Will be stopped if one of its components evaluates to true
c. Takes place from right to left
d. Takes place from left to right
And: d
29. The following code ‘for( ; ; )’ represents an infinite loop. It can be terminated by
a) break
b) exit(0)
c) abort()
d) all of the mentioned
Ans: a
31. Which keyword is used to come out of a loop only for that iteration?
a) break
5
b) continue
c) return
d) none of the mentioned
Ans: b
33In C programming language, which of the following type of operators have the highest
precedence
a. Relational operators
b. Logical operators
c.Arithmetic operators
d.Equality operators
Ans: d
34. The solution can be reached by completing the actions in steps. These steps are called
a) Sequence
b)Algorithm
c) Flowchart
d)Steps
Ans: b
38. ----------------- meAns the set of instructions that make up the solution after they have been
coded into a programming language.
a) solution
b) result
c) program
d) error
Ams: c
41. ___________ converts source code to machine language one line at a time.
a. Compiler
6
b. Interpreter
c. Assembler
d.CPU
Ans: b
42. The program that converts high level language to a machine language is called __________
a. Interpreter
b. Linker
c. Compiler
d.Loader
Ans: c
44. A _______ is a notational system for describing computations in both machine and human
readable form
a. Programming language
b.Machine language
c. High-level language
d.Assembly language
Ans: a
8
56. The ---------------------- statement when executed in a switch statement causes immediate exit
from the structure.
a)goto
b) default
c) break
d) switch
Ans: c
56. The ternary conditional expression using the operator?: could be easily coded using ------------
----- statement
a)Nested if
b) if-else
c) if
d) for
Ans: b
9
UNIT I [CLO 1][CLO 6]
PART –B
4 MARKS
1. Comment “C is mid level language”?
2. What is problem solving?
3. What are the six steps of problem solving?
4. Discuss about how the problems can be solved with computers?
5. What is a program?
6. Why is problem analysis important?
7. What are the tools of problem solving available?
8. How do problem-solving tools help in leading to a solution?
9. Why it is important to test a solution before coding it?
10.What is an algorithm? Give the characteristics of the algorithm.
11.What is a flowchart? Give the symbols/shapes used in the flowchart.
12.Define pseudocode and give its importance with an example.
13.Discuss the difficulties with problem solving in detail.
14.State the use of %d and %f .Write a printf statement in C using the above mentioned symbols?
15.What is main difference between variable and constant?
16.Explain bitwise left shift operator?
17.Explain primary data types used in C?
18.Difference between formatted & unformatted statement ?
19.What is meant by storage class of variable?
20.Explain with example ++i and i++.
21. Explain about arrow operator in C.
22. What are the non-numeric data types in C ?
23. Draw a flow chart to check if a number is even.
24. What are the various data types that the scanf statement can handle
UNIT-1 [CLO 1]
PART -C
12 MARKS
1) Explain the evolution of programming languages.
2) Explain the various steps involved in problem solving with diagram.
3) Draw the flowchart and write the algorithm and c code to find the sum and to reverse the digits of
given five-digit number.
4) Write an algorithm and draw a flow chart to find the factorial and Fibonacci series of given number.
1. The --------------------- operator is true only when both the operands are true.
a) &&
b) ||
c)!
d)?
Ans: a
2. The ---------------------- statement when executed in a switch statement causes immediate exit
from the structure.
a)goto
b)default
c)break
d)switch
Ans: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
Ans:b
9. In an exit controlled loop the body of the loop is executed at least for --------
a) 1 time
b)2 times
c) 3 times
d)n times
Ans:a
12. In a counter controlled loop, variable known as -----------------is used to count the loop
operations.
a) Counter
b) sentinel
c)i
d)n
Ans: a
12
13. int a=10;
++a;
a++;
Printf(“%d”,a);
a)10
b) 11
c)12
d) 13
Ans: c
15.#include <stdio.h>
int main()
{
int i = 3;
printf("%d", (++i)++);
return 0;
}
What is the output of the above program?
a) 3
b) 4
c) 5
d) Compile-time error
Ans: d
20.int main() {
int a = 1;
int b = 0;
b = a++ + a++;
printf("%d %d",a,b);
return 0;
} Find the output of the code
a) 3 6
b) Compiler Dependent
c) 3 4
d) 3 3
Ans:b
int main()
{
int i = -5;
int k = i %4;
printf("%d\n", k);
}
a) Compile time error
b) -1
c) 1
d) Run time error
Ans: b
Ans: c
25.#include <stdio.h>
void main()
{
int a = 3;
int b = ++a + a++ + --a;
printf("Value of b is %d", b);
}
a) Value of x is 12
b) Value of x is 13
c) Value of x is 10
d) Undefined behavior
Ans:d
a.Compilation error
b.1 2 3
c.1 2
d.1 3
Ans : b
37. The Statements in the statement block are encapsulated within a ---?
a) ( )
b) { }
c)[ ]
d) < >
Ans :B
38) An array elements are always stored in ____________memory locations
a) sequential
b) Random
c) Sequential and Random
d) None of the above
Ans : a
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.
11. What do you mean by infinite loop? Give suitable of any infinite loop in a C program.
12. Explain break and continue statements with examples.
13. Determine the output of the following program justify your Answer in a few words.
int main()
{
float f = 1.1.0;
switch(f){
case 1.0: printf("one"); break;
case 2.0: printf("two"); break; default:
prinf("%f", f);
}}
14. Write a program to print series of number divisible by 3 from 1 to 100 using for loop.
15. Write a C program to print 1, 2, 4, 8, 16, 32, 64 …..N using do….while loop (Read N
from user).
16. What are Arrays in C programming? Give the importance of Array in C language
17. What are the rules to declare one dimensional array?
18. What do you mean by compile time initialization? Give suitable example of Compile
time initialization of C Array.
19. Describe the array index out of bound error in context of C array program.
20. Write a C program to calculate median of an array in C.
21. Explain about pre/post increment operator.give examples
22. Write a C program using logical operators
23. Explain about conditional and unconditional branching using FOR loop
20
24. Write a C program for Lvalue and R value in expression
25. Explain about Operator Precedence
26. Explain switch statement and give an example
27. Illustrate how the elements are accessed in one dimensional array.give an example
28. Explain about else if and nested if with an example
29. Discuss about assignment operator with an example
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
2. 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
3. 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
5. 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.
22
10) Write a program to find the sum of positive numbers in an array
11) Write c program for palindrome strings , two strings A and B, each consisting of lower case
alphabets.
23
UNIT-3 [CLO-3][CLO6]
PART – A
MULTIPLE CHOICE QUESTIONS
Ans- a
Ans-d
6. While passing an array as an actual argument, the function call must have the array name
a.with empty brackets
b.with its size
c.alone
d.none of the above
Ans-c
7. The parameter passing mechanism for an array is
a.call by value
b.call by value-result
c.call by reference
d.none of these
Ans-c
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
c.when it is a formal parameter and an actual argument
d.All of the above.
Ans-d
25
11. Choose the correct statements
a.Array stores data of the same type
b.Array can be a part of a structure
c.Array of structure is allowed
d.All of the above
Ans-d
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
Ans: b
19. What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming
declaration int a[5][4][3];)
a) funca);
b) func(&a);
c) func(*a);
d) func(**a);
Ans: a
28
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. }
a) Compile time error
b) 10 2
c) Undefined behavior
d) segmentation fault/code crash
Ans: a
a) 10
b) 2
c) Compile time error
d) Undefined behavior
Ans: d
a) 1 2
b) Compile time error
c) 1 2 1 2
d) Depends on the compiler
Ans: a
30
14. foo();
15. }
Ans: b
a) 2 2
b) 2
c) Compile time error
d) Depends on the compiler
Ans: d
Ans: b
a) hi
b) Run time error
c) Nothing
d) Varies
Ans: a
a) hi
b) Compile time error
c) Nothing
d) Varies
Ans: b
35. What is the output of this code having void return-type function? (CLO4,PLO1)
1. #include <stdio.h>
2. void foo()
3. {
4. return 1;
5. }
6. void main()
7. {
33
8. int x = 0;
9. x = foo();
10. printf("%d", x);
11. }
a) 1
b) 0
c) Runtime error
d) Compile time error
Ans: d
36. 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
Ans: b
Ans: d
34
a) hello 5
b) Error
c) Nothing
d) Junk value
Ans: a
a) 5
b) Junk value c) 0 d) Error
Ans: a
43. Which return type cannot return any value to the caller?
a. int b. float c. void d. double
Ans - c
37
UNIT-3 [CLO-3][CLO6]
PART B
4 MARKS
1. What is the need for user defined function?
2. Mention the types of functions with example C 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. Write a program in C to find the sum of all elements of the array.
7. Show the difference between actual and formal parameter in function.
8. Compare User define function with System define function.
9. List out the categories of functions with example program.
10. Explain the concept of function call by reference with a example program.
11. Explain the concept of function call by value with a sample program.
12. How a function is defined? Explain with relevant example.
13. Discuss the character of Arrays and types with example program.
14. Predict output of the following program.
int main(){
inta[][][]={{1,2},(3,4},{5,6}};
int i,j;
for(j=0;j<2;j++)
printf(“%d”,a[i][j]);
return 0; }
15. Why array index starts from zero? Explain?.
16. Differentiate function declaration and function definition..
19. Write a program to convert the given string (computer) Lower to upper case.
38
UNIT-3 [CLO-3][CLO6]
PART C
12 MARKS
1. Array construction for student mark list for 25 students. Output need to display register number,
marks of five subjects , CGPA and PASS/Fail Status.
2. Explain in details about String Functions: gets(), puts(), getchar(), putchar(), printf() with an example
programs.
3. i)Print the given pattern using 1-D array.
4789456
123544
56478
123
ii)Write a C program to divide one array into two arrays.
4. i) What are strings in C? Write a C program to read a string in lowercase and convert it to uppercase.
ii) Illustrate call by value and call by reference with example for each..
5. i) Find the factorial of 10 using function recursion.
ii) What is a string? Explain any 5 string functions..
6. Explain in details about String Functions: atoi, strlen, strcat, strcmp with an example.
7. Discuss about functions declaration and definition, Types: Call by Value & Call by Reference with
example programs..
8. Explain and write c program for Function with and without Arguments and no Return Values..
9. Explain and write c program for Passing Array to Functions with return type, Recursion Functions..
10. Write c program for Matrix Multiplication using Multi-dimensional array.
11. Write a program to perform Matrix addition and Multiplication using 2-D arrays.
12. State the importance of functions. List out the different types of Function.
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..
16. Write a C program that: i. Implements string copy operation STRCOPY(str1,str2) that copies a
string str1 to another string str2 without using library function. ii. Reads a sentence and prints
frequency of each of the vowels and total count of consonants..
17.Explain any five string manipulation library functions with examples.
18.Write a program in C to merge two arrays of same size sorted in decending order.
19. Write a swap function using call by value and call by reference. 20. 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.
39
UNIT-4 [CLO 4][CLO6]
PART-A
MULTIPLE CHOICE QUESTIONS
3. #include <stdio.h>
int main()
{
printf("%d", main);
return 0;
}
a)Address of main function
b) Compiler Error
c) Runtime Error
d) Some random value
Ans: a)
4. Output?
filter_none
edit
play_arrow
brightness_4
#include <stdio.h>
int main()
{
int (*ptr)(int ) = fun;
(*ptr)(3);
return 0;
}
int fun(int n)
{
for(;n > 0; n--)
printf("GeeksQuiz ");
return 0;
}
a)GeeksQuiz GeeksQuiz GeeksQuiz
b) GeeksQuiz GeeksQuiz
40
c) Compiler Error
d) Runtime Error
Ans: c)
15. How many number of pointer (*) does C have against a pointer variable
declaration?
a) 7
b) 127
c) 255
d) No limits
Ans: d
30. Which of the following is the correct syntax to send an array as a parameter to
function?
a) func(&array);
b) func(#array);
c) func(*array);
d) func(array[size]);
Ans: a
32.Determine output:
#include <stdio.h>
void main()
{
char *p = NULL;
char *q = 0;
if(p)
48
printf(" p ");
else
printf("nullp");
if(q)
printf("q");
else
printf(" nullq");
}
a) p q
b) Depends on the compiler
c) x nullq where x can be p or nullp depending on the value of NULL
d) nullp nullq
Ans: D
35. The operator > and < are meaningful when used with pointers, if
a) The pointers point to data of similar type
b) The pointers point to structure of similar data type.
c) The pointers point to elements of the same array
d) None of these
Ans: C
38. A function 'p' that accepts a pointer to a character as argument and returns a pointer to an
49
array of integer can be declared as
a) int(*p(char *))[]
b) int *p(char *)[]
c) int (*p) (char *)[]
d) None of these
Ans: A
39.What will be printed after compiling and running the following code?
main()
{
char *p;
printf("%d %d",sizeof(*p), sizeof(p));
}
a) 1 1
b) 1 2
c) 2 1
d) 2 2
Ans: B
41. Can you combine the following two statements into one?
char *p;
p = (char*) malloc(100);
a. char p = *malloc(100);
b. char *p = (char) malloc(100);
c. char *p = (char*)malloc(100);
d. char *p = (char *)(malloc*)(100);
Ans: c
42.How many bytes are occupied by near, far and huge pointers (DOS)?
a. near=2 far=4 huge=4
b. near=4 far=8 huge=8
c. near=2 far=4 huge=8
d. near=4 far=4 huge=8
Ans: a
UNIT – 4 [CLO 4][CLO6]
50
PART-B
4 MARKS
#include <stdio.h>
int main()
{
float arr[5] = {12.5, 10.0, 13.5, 90.5, 0.5};
float *ptr1 = &arr[0];
float *ptr2 = ptr1 + 3;
printf("%f ", *ptr2);
printf("%d", ptr2 - ptr1);
return 0;
}
15) Write a program in C to swap two numbers using call by reference and call by value.
16) Write a program to find Sum of N Numbers using Recursion.
17) Mention the types of functions with illustrations.
18) Write the syntax for function declaration with an example program
19) Classify the parts of function definition.
20) Describe the following
i) Function call
ii) Default arguments
iii) Command line arguments
51
UNIT – 4 [CLO 4][CLO6]
PART-C
12 MARKS
1) Discuss about pointers and their operations that can be performed on it.
2) Write a c program to read array elements and print the values with their address.
3) Define address operator, explain with an example of Size of Pointer Variable. Explain in detail
about Pointer Declaration and dereferencing pointers, Void Pointers and size of Void Pointers.
4) Write a program for Arithmetic Operations and Incrementing Pointers.
5) Write a program for Arithmetic Operations and Incrementing Pointers.
6) Explain function pointer & Array of Function Pointers with an example.
7) Write the c program for Accessing Array of Function Pointers.
8) Justify and explain the different size of data types using pointer variables with example program.
9) i) Write a c program to count vowels and consonants in a string using pointer.
ii) Explain call by reference and call by value with an example program.
10) Explain Constant Pointer with an example.
11) Explain in detail about Pass by Value and Pass by reference with an example program.
12) Discuss about the classification of functions depending upon their inputs and output.
13) Explain in detail about conditional compilation derivatives and pragma derivative.
14) i) Write a c- program to reverse the string using functions.
ii) Write a c- program to find the factorial of a number using functions.
52
UNIT 5
PART A
MULTIPLE CHOICE QUESTIONS
Ans: b
2.User-defined data type can be derived by
a) struct
b) enum
c) typedef
d) all of the mentioned
Ans: d
3.Which operator connects the structure name to its member name?
a) –
b) <-
c) .
d) Both <- and .
Ans :c
53
d) Varies
Ans :a
a. 5
b. 11
c. 41
d. 44
Ans :d
10. Which among the following is never possible in C when members in a structure are same as
that in a union?
int main()
{
struct Point p1 = {.y = 0, .z = 1, .x = 2};
printf("%d %d %d", p1.x, p1.y, p1.z);
return 0;
}
a) Compiler Error
b) 2 0 1
54
c) 0 1 2
d) 2 1 0
Ans: b)
12. Assume that size of an integer is 32 bit. What is the output of following program?
#include<stdio.h>
struct st
{
int x;
static int y;
};
int main()
{
printf("%d", sizeof(struct st));
return 0;
}
a) 4
b) 8
c) Compiler Error
d) Runtime Error
Ans: c)
Ans: c)
int main()
55
{
struct st temp;
temp.x = 10;
temp.next = temp;
printf("%d", temp.next.x);
return 0;
}
a) Compiler Error
b) 10
c) Runtime Error
d) Garbage Value
Ans: a)
Ans: c)
Ans d.
Ans d
struct test
{
int k;
char c;
};
a. Multiple of integer size
b. integer size+character size
c. Depends on the platform
d. Multiple of word size
Ans b
Ans c
union temp
{
int a;
float b;
char c;
};
union temp s = {1,2.5,’A'}; //REF LINE
Which member of the union will be active after REF LINE?
a. a
b. b
c. c
d. Such declaration are illegal
Ans a
union uTemp
{
double a;
int b[10];
char c;
}u;
(Assuming size of double = 8, size of int = 4, size of char = 1)
a. 4
b. 8
c. 40
d. 80
Ans c
a. struct temp{}s;
main(){}
b. struct temp{};
struct temp s;
main(){}
57
c. struct temp s;
struct temp{};
main(){}
Ans d
24. Which predefined function is used to write whole structure into a file ?
a) write()
b) fwrite()
c) swrite()
d) None of the above
Ans b
#include <stdio.h>
struct cppbuzz{
};
int main()
{
printf("%d",sizeof(struct cppbuzz));
return 0;
}
a) 0
b) 1
c) 2
d) 4.
Ans a
58
return 0;
}
a) 10 0
b) 10 GarbageValue
c) 10 10
d) 0 0
Ans : c
p = NULL;
free(p);
}
31. Consider the following program, where are i, j and k are stored in memory?
int i;
int main()
{
int j;
int *k = (int *) malloc (sizeof(int));
}
a) i, j and *k are stored in stack segment
b) i and j are stored in stack segment. *k is stored on heap.
c) i is stored in BSS part of data segment, j is stored in stack segment. *k is stored on heap.
d) j is stored in BSS part of data segment, i is stored in stack segment. *k is stored on heap.
Ans: c
35. _____removes the named file, so that a subsequent attempt to open it will fail.
a) remove(const *filename)
b) remove(filename)
60
c) remove()
d) fclose(filename)
Ans a
37. What does tmpfile() returns when it could not create the file?
a) stream and NULL
b) only stream
c) only NULL
d) does not return anything
Ans a
39. Which function will return the current file position for stream?
a) fgetpos()
b) fseek()
c) ftell()
d) fsetpos()
Ans c
Ans c
41. The______function reads atmost one less than the number of characters specified by size
from the given stream and it is stored in the string str.
a) fget()
b) fgets()
c) fput()
61
d) fputs()
Ans b
47. Which of the following header files must necessarily be included to use dynamic memory
allocation functions?
a) stdlib.h
b) stdio.h
c) memory.h
d) dos.h
Ans A
a) *my_struct.b = 10;
b) (*my_struct).b = 10;
c) my_struct->b = 10;
d) Both *my_struct.b = 10; and (*my_struct).b = 10;
Ans A
64
UNIT -5 [CLO 5][CLO6]
PART C
12 MARKS
1. Write a structure to store the name, account number and balance of customers (more than 10) and
store their information.Write a function to print the names of all the customers having balance less than
$200. .
2. Compare and contrast between Structures and Unions. .
3. Examine the differences between static and dynamic memory allocation.
4. Write a C program illustration of subscripted structure variables , arrays of structures.
5. Write a C program for Nested Structure Database Program.
6. Develop a C Program to find the largest number using dynamic memory allocation.
7. Explain in detail about unions with suitable example. .
8. What are Structures? Create a structure with data members of various types and declare two
structure variables. Write a program to read data into these and print the same. .
9. Develop a C Program to use the arrays inside union variables. .
10.Write the C coding for finding the average of number stored in sequential access file.
11.Develop a C Program to find the number of lines in a text file. .
12.Write a C Program to calculate the factorial of a number by using the command line argument.
13.Write a C Program to generate Fibonacci series by using command line arguments.
65