Professional Documents
Culture Documents
Intro to C
1. What is the correct value to return to the operating system upon the successful completion of a
program?
A. -1
B. 1
C. 0
D. Programs do not return a value.
3. What punctuation is used to signal the beginning and end of code blocks?
A. { }
B. -> and <-
C. BEGIN and END
D. ( and )
If statement
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)
Programming in C (CPR)
11. Which of the following shows the correct syntax for an if statement?
A. if expression
B. if{ expression
C. if( expression)
D. expression if
12. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
A. 10
B. 9
C. 0
D. 1
Loop controls
Functions
17. What is the return type of the function with prototype: "int func(char x, float v, double t);"
A. char
B. int
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)
Programming in C (CPR)
C. float
D. double
18. Which of the following is a valid function call (assuming the function exists)?
A. funct;
B. funct x, y;
C. funct();
D. int funct();
switch..case
21. What is required to avoid falling through from one case to the next?
A. end;
B. break;
C. Stop;
D. A semicolon.
switch(x)
}
A. One
B. Zero
C. Hello World
D. ZeroHello World
Pointers
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)
Programming in C (CPR)
24. Which of the following is the proper declaration of a pointer?
A. int x;
B. int &x;
C. ptr x;
D. int *x;
25. Which of the following gives the memory address of integer variable a?
A. *a;
B. a;
C. &a;
D. address(a);
Structures
Arrays
35. What is the index number of the last element of an array with 29 elements?
A. 29
B. 28
C. 0
D. Programmer-defined
37. Which of the following correctly accesses the seventh element stored in foo, an array with
100 elements?
A. foo[6];
B. foo[7];
C. foo(7);
D. foo;
38. Which of the following gives the memory address of the first element in array foo, an array
with 100 elements?
A. foo[0];
B. foo;
C. &foo;
D. foo[1];
Strings
39. Which of the following is a static string?
A. Static String
B. "Static String"
C. 'Static String'
D. char string[100];
41. Which of the following reads in a string named x with one hundred characters?
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)
Programming in C (CPR)
A fgets(x, 101, stdin);
B. fgets(x, 100, stdin);
C. readline(x, 100, '\n');
D. read(x);
43. Which of the following adds one string to the end of another?
A. append();
B. stringadd();
C. strcat();
D. stradd()’
Typecasting
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)
Programming in C (CPR)
49. What variables stores the number of arguments to a program?
A. argc
B. argv
C count
D. arglen
52. In what order do the two command line variables appear in the definition of main?
A. Count then argument array
B. Argument array then count
C. They don't appear in the definition of main
D. There is only one argument.
CPR (FYIF) by Mr. Kute T. B. (Lecturer in IT, KK Wagh Polytechnic, Nashik 2007-2008)