You are on page 1of 6

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

RAMAPURAM CAMPUS
FACULTY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Sub Code/Name : 18CSS101J/ Programming for Problem Solving
QUESTION BANK FOR UNIT IV & V
PART A

Q.No Question
Comment on the following pointer declaration?
Int *ptr, p;
1 a)ptr is a pointer to integer, p is not.
b)ptr and p, both are pointers to integer.
c)ptr is pointer to integer, p may or may not be.
d)ptr and p both are not pointers to integer.
a. A pointer variable can be
b. a) Passed to a function
2 c. b) Changed within a function
d. c) Returned by a function
e. d) Can be assigned an integer value

a. Processor Directive in C language starts with?


b. a) $ symbol (DOLLAR)
3 c. b) @ symbol (At The Rate)
d. c) & symbol (Ampersand)
e. d) # symbol (HASH)

1. What is a Pragma in C language?


2. a) A Pragma may be an instruction to build tool to process or generate comments
3. b) A Pragma may be an instruction to compiler to execute specific functions at specific times say startup or
4 exit of program.
4. c) A pragma may be an instruction to tell compiler to ignore certain warnings.
5. d) A Pragma may not be an instruction to build tool to process or generate comments

What is the limit for number of functions in a C Program?


a) 16
b) 31
5 c) No Limit
d) 32

 Arguments passed to a function in C language are called ___ arguments.


a) Formal arguments
6 b) Actual Arguments
c) Definite Arguments
d) Ideal Arguments
What is the default return value of a C function if not specified explicitly?
a) -1
7 b) 0
c) 1
d) Any value
8 Which of the following is a correct syntax to pass a Function Pointer as an argument?
a) void pass(int (*fptr)(int, float, char)){}
b) void pass(*fptr(int, float, char)){}
c) void pass(int (*fptr)){}
d) void pass(*fptr){}
Address stored in the pointer variable is of type __________.
a)char
9 b)float
c)integer
d)double
Find the output of the following program?
void main() {
char *msg = "hi";
printf(msg);
10 }
a) hi
b) h
c) hi followed by garbage value
d) No Error
What is the correct syntax to access the member of the ith structure?
Assuming: struct temp { int b; }s[50];
a) s.b.[i];
11
b) b[i].s;
c) b[i];
d) s[i].b;
Which return-type cannot be used for a function?
a) main
12 b)int
c) void
d) printf
Which of the following is not possible?
a) s1 = s2
b) s1 =! s2
13
c) (*s1).number = 50
d) s1 :s2

Which operation is illegal in structures?


a) Typecasting of structure
14 b) no Typecasting or Dynamic allocation
c) Dynamic allocation of memory for structure
d) Typecasting and Dynamic allocation
“s.t.b = 10” indicates __________
a) Syntax Error
15 b) Structure
c) float data type
d) variable name
What is the output of the program. #include struct temp { int a; int b; int c; }; main() { struct temp p[] =
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; }
a) No Compile time error, generates an array of structure of size 3
16
b) Compile time error, generates an array of structure of size 9
c) no Compile time error, illegal declaration of a multidimensional array d) illegal assignment to members
of structure
Which of the following uses structure?
a) Array
b) Binary Tree
17
c)linked list
d) Array, Binary Tree, linked list

18 What is the output of the program? #include struct student { char *c; }; void main() { struct student s[2];
printf("%d", sizeof(s)); }
a) 2
b) 3
c) 1
d) 8
What is the output of this C code?
#include <stdio.h>
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 45);
fflush(stdout);
19 fprintf(stderr, "%d", 65);
return 0;
}

a. 45 65
b. 65 45
c. 45
d. Compilation error

What will be the output of the program? #include struct student { char *name; }; void main() { struct
student s, m; s.name = "st"; m = s; printf("%s%s", s.name, m.name); }
a) Compile time error
20
b) no error
c) runtime error
d) stst

a. Consider the 32 bit compiler. We need to store address of integer variable to integer pointer. What will be
the size of integer pointer ?
b. A)10
21c. B)2
d. C)4
e. D)6

a. Prior to using a pointer variable it should be


b. a) initialized
22c. b) Declared
d. c) initialized and Declared
e. d) not initialized or Declared

a. In C, parameters are always


b. A)Passed by value
23c. B)Passed by reference
d. C)Non-pointer variables are passed by value and pointers are passed by reference
e. D)Passed by value result

241. Predict the output?


2. #include <stdio.h>
3. int main()
4. {
5. void demo();
6. void (*fun)();
7. fun = demo;
8. (*fun)();
9. fun();
10. return 0;
11. }
12. void demo()
13. {
14. printf("Quiz ");
15. }
16. A)Quiz
17. B) Quiz Quiz
18. C)compile error
19. D)Blank screen

Which of the following is true about return type of functions in C?

A)Functions can return any type


25 B)Functions can return any type except array and functions
C)Functions can return any type except array, functions and union
D)Functions can return any type except array, functions, function pointer and union
What is an array Base Address in C language.?
A) Base address is the address of 0th index element.
26 B) An array b[] base address is &b[0]
C) An array b[] base address can be printed with printf("%d", b);
D) A,B & C
20. What is the output of C program.? int main() { char grade[] = {'A','B','C'}; printf("GRADE=%d, ", *grade);
printf("GRADE=%d", grade[0]); }
21. A) A A
2722. B) 65 A
23. C) 65 65
24. D) 0

25. What is the output of C Program with arrays.?


26. int main()
27. {
28. int rollno[3]=[1001,1002,1003];
29. printf("%d", rollno[1]);
2830. }
31. A) 1002
32. B) 1003
33. C) address of 1002
34. D) Compiler error

35. What is a multidimensional array in C Language.?


36. A) It is like a matrix or table with rows and columns
2937. B) It is an array of arrays
38. C) To access 3rd tow 2nd element use ary[2][1] as the index starts from 0 row or column
39. D) A,B &C

40. An entire array is always passed by ___ to a called function.


41. A) Call by value
3042. B) Call by reference
43. C) Address relocation
44. D) Address restructure

45. What does the following segment of code do? fprintf(fp, "Copying!");
46. a. It writes "Copying!" into the file pointed by fp
47. b. It reads "Copying!" from the file and prints on display
3148. c. It writes as well as reads "Copying!" to and from the file and prints it
49. d. . It does not writes or reads
50.

32 Choose the right statement for fscanf() and scanf()


a. fscanf() can read from standard input whereas scanf() specifies a stream from which to read
b. fscanf() can specifies a stream from which to read whereas scanf() can read only from standard input
c. fscanf() and scanf() has no difference in their functions
d. fscanf() and scanf() can read from specified stream

The first and second arguments of fopen() are


a. A character string containing the name of the file & the second argument is the mode
33 b. A character string containing the name of the user & the second argument is the mode
c. A character string containing file pointer & the second argument is the mode
d. A character string not containing the file, user pointer.
Which of the following true about FILE *fp
a. FILE is a keyword in C for representing files and fp is a variable of FILE type.
b. FILE is a stream
34 c. FILE is a buffered stream
d. FILE is a structure and fp is a pointer to the structure of FILE type

What will be the size of the following structure?


struct demo{
int a;
char b;
float c;
35 }
a. 12
b. 8
c. 10
d. 9

What is the output of this program?


#include <stdio.h>
int main()
{
union demo {
int x;
int y;
};
36 union demo a = 100;
printf("%d %d",a.x,a.y);
}
a. 100 0
b. 100 100
c. 0 0
d. Compilation Error

Which operator connects the structure name to its member name?


a. -
b. ->
37 c. .
d. both . and ->

Which of the following statements correct about the below code?


maruti.engine.bolts=25;
a. Structure bolts is nested within structure engine.
38 b. Structure engine is nested within structure maruti.
c. Structure maruti is nested within structure engine.
d. Structure maruti is nested within structure bolts.

39 The size of the following union, where an int occupies 4 bytes of memory is
union demo
{
float x;
int y;
char z[10];
};
a. 8 byte
b. 4 byte
c. 10 byte
d. 18 byte
What is the correct syntax to declare a function foo() which receives an array of structure in function?
a. void foo(struct *var);
40 b. void foo(struct *var[]);
c. void foo(struct var);
d. void foo()

PART B

1. Write a C program to Pass a single element of an array into a function , entire array into a function with
sample output .
2. Write a c program for Arithmetic Operations and Incrementing Pointers
3. List any 5 pre processor directives with a sample program.
4. Explain in detail about function pointer & Array of Function Pointers with an example.
5. Explain in details with an example Void Pointer, Pointer Declaration and dereferencing pointers.
6. write a c program to count vowels and consonants in a string using pointer.
7. what is Constant Pointers and null pointer explain with an example.
8. Briefly discuss about file operations in C.
9. Write a program to copy the content from one file to another file.
10. Write a c program for file: opening, defining, closing, File Modes.
11. Explain in details about Dynamic memory allocation, malloc, realloc, free with an example.
12. Write a c program to insert a line at the end of text file.
13. Explain in details about Bit Manipulation to structure with an example.

You might also like