Q1: Which keyword is used to define a function that returns no value in C?
null
void
empty
none
Q2: Which symbol is used to call a function?
[]
{}
()
<>
Q3: Which statement correctly defines a function?
int add(int a, int b);
int add(int a, int b){ return a+b; }
function add(a,b)
define add()
Q4: Which statement is used to return a value from a function?
break
continue
return
exit
Q5: Which of the following is a valid function prototype?
int sum(int,int);
sum(int,int);
int sum;
function sum();
Q6: What happens if a function has no return statement but its return type is int?
Compilation error
Undefined behavior
Returns 0 automatically
Returns NULL
Q7: Which operator is used to obtain the address of a variable?
*
&
%
@
Q8: Which declaration defines a pointer to an integer?
int p;
int *p;
pointer p;
int &p;
Q9: Which operator is used to access the value pointed to by a pointer?
&
%
*
#
Q10: What is the value of p after this code?
int x=5;
int *p=&x;
5
Address of x
0
NULL
Q11: Which statement correctly changes x through pointer p?
int x=5;
int *p=&x;
p=10;
*p=10;
&p=10;
x=&p;
Q12: What is NULL pointer?
Pointer to integer 0
Pointer pointing to no valid object
Pointer to first array element
Pointer to file
Q13: Which keyword defines a structure?
record
struct
class
object
Q14: Which statement correctly declares a structure variable?
struct Student{int id;};
Student s;
struct Student s;
student s;
struct s Student;
Q15: Which operator accesses a structure member?
::
.
->
*
Q16: Which operator accesses a structure member through a pointer?
.
::
->
*
Q17: Which function opens a file in C?
fileopen()
fopen()
openfile()
readfile()
Q18: Which mode opens a text file for reading?
"w"
"a"
"r"
"rw"
Q19: Which function closes an opened file?
close()
fclose()
endfile()
finish()
Q20: Which function writes formatted data to a file?
fprintf()
fscanf()
fgets()
fread()
Q21: Which keyword allows a function to call itself?
loop
recursive
None. A function simply calls itself by name.
repeat
Q22: What is the output of the following code?
int f(int x){ return x*x; }
printf("%d", f(4));
4
8
16
20
Q23: Which statement correctly passes an integer by address?
func(x);
func(*x);
func(&x);
func(address x);
Q24: Which function declaration accepts a pointer to an integer?
void f(int x);
void f(int *x);
void f(*int x);
void f(pointer x);
Q25: What is the value of x after the following code?
void change(int *p){ *p=20; }
int x=5;
change(&x);
5
20
0
Undefined
Q26: Which declaration creates a pointer to a pointer to an integer?
int *p;
int **p;
int ***p;
pointer pointer p;
Q27: What does the expression *(p+1) access?
Previous element
Current element
Next element
Last element
Q28: Which expression is equivalent to arr[3]?
*(arr+3)
*(arr+2)
*arr+3
arr(*3)
Q29: Which statement correctly declares a pointer to a structure Student?
struct Student{int id;};
Student *p;
struct Student *p;
pointer Student p;
struct *Student p;
Q30: Which statement accesses member id through pointer p?
p.id
(*p).id
Both of the above answers
p->id
Q31: Which keyword creates an alias for a structure type?
alias
typedef
define
using
Q32: Which statement correctly defines a typedef for struct Student?
typedef Student struct;
typedef struct Student Student;
typedef Student;
struct typedef Student;
Q33: Which file mode opens a file for writing and truncates existing contents?
"r"
"w"
"a"
"r+"
Q34: Which file mode appends data to the end of a file?
"w"
"a"
"r"
"rw"
Q35: Which function reads formatted data from a file?
fprintf()
fscanf()
fputs()
fwrite()
Q36: Which function reads one line of text from a file?
fgets()
fputs()
fwrite()
fprintf()
Q37: Which function writes a string to a file?
fputs()
fgets()
fread()
fscanf()
Q38: Which function reads binary data from a file?
fread()
fprintf()
fgets()
fscanf()
Q39: Which function writes binary data to a file?
fwrite()
fprintf()
fgets()
fscanf()
Q40: Which function moves the file position indicator?
fseek()
ftell()
rewind()
feof()
Q41: Which statement correctly declares a function pointer?
int *fp(int,int);
int (*fp)(int,int);
function *fp(int,int);
pointer fp(int,int);
Q42: What is the output of the following code?
int a=10;
int *p=&a;
printf("%d", *p);
Address of a
10
0
Undefined
Q43: What is the value of x after the following code?
int x=5;
int *p=&x;
(*p)++;
4
5
6
Undefined
Q44: Which expression increments the pointer itself?
(*p)++
*p++
p++
++(*p)
Q45: Which statement correctly swaps two integers using pointers?
swap(a,b);
swap(*a,*b);
swap(&a,&b);
swap(a,&b);
Q46: Which keyword prevents modification of data through a pointer?
volatile
register
const
static
Q47: Which declaration creates a constant pointer to an integer?
const int *p;
int * const p=&x;
const int const *p;
int const const *p;
Q48: Which declaration creates a pointer to constant integer?
const int *p;
int * const p=&x;
int **p;
int *p=&5;
Q49: Which statement correctly defines a nested structure?
A structure containing another structure as a member.
A structure inside a function only.
A pointer inside a structure.
A recursive function.
Q50: Which statement passes a structure variable by value?
func(s);
func(&s);
func(*s);
func(address s);
Q51: Which statement passes a structure by address?
func(s);
func(&s);
func(*s);
func(struct s);
Q52: Which function returns the current position in a file?
fseek()
ftell()
rewind()
feof()
Q53: Which function moves the file position to the beginning of a file?
fseek()
ftell()
rewind()
remove()
Q54: Which function checks whether the end of a file has been reached?
ferror()
feof()
fclose()
fflush()
Q55: Which function deletes a file from disk?
delete()
erase()
remove()
unlinkfile()
Q56: Which function changes the name of a file?
rename()
move()
replace()
copy()
Q57: Which file mode opens a binary file for reading?
"rb"
"wb"
"ab"
"rt"
Q58: Which file mode opens a binary file for writing?
"rb"
"wb"
"ab"
"rt"
Q59: Which statement correctly writes one structure variable s to a binary file?
fwrite(&s,sizeof(s),1,fp);
fprintf(fp,"%d",s);
fputs(s,fp);
fscanf(fp,"%d",&s);
Q60: Which statement correctly reads one structure variable s from a binary file?
fread(&s,sizeof(s),1,fp);
fprintf(fp,"%d",s);
fputs(s,fp);
fscanf(fp,"%d",&s);
Q61: What is the output of the following recursive function?
int f(int n){
if(n==0) return 0;
return n+f(n-1);
}
printf("%d",f(3));
3
5
6
9
Q62: Which condition is necessary in a recursive function?
Loop condition
Base case
Switch statement
Global variable
Q63: Which statement correctly declares an array of 10 integer pointers?
int *a[10];
int a*[10];
int (*a)[10];
pointer a[10];
Q64: Which expression accesses the third element of an integer array using a pointer p?
*(p+2)
*(p+3)
p[3]
*(p+1)
Q65: What is sizeof(char)?
1
2
4
8
Q66: Which function copies one string to another?
strcmp()
strcpy()
strlen()
strcat()
Q67: Which function compares two strings?
strcmp()
strcpy()
strlen()
strcat()
Q68: Which function returns the length of a string?
strcmp()
strlen()
strcpy()
strcat()
Q69: Which operator is used to access a member of a structure variable?
.
->
::
*
Q70: Which operator is used to access a member through a structure pointer?
.
::
->
#
Q71: Which file mode allows both reading and writing without truncating the file?
r+
w
a
rb
Q72: Which function flushes an output stream?
fflush()
fclose()
fseek()
ferror()
Q73: Which function checks whether a file operation has failed?
feof()
ferror()
ftell()
rewind()
Q74: Which function reads one character from a file?
fgetc()
fgets()
getcchar()
fread()
Q75: Which function writes one character to a file?
fputc()
fputs()
fprintf()
fwrite()
Q76: Which function rewinds a file to the beginning?
rewind()
fseek()
ftell()
feof()
Q77: Which keyword defines a local variable that keeps its value between function calls?
register
static
volatile
extern
Q78: Which keyword declares a variable defined in another source file?
extern
static
register
const
Q79: Which storage class keeps a variable only inside the current source file?
extern
static
auto
register
Q80: Which keyword suggests storing a variable in a CPU register?
extern
static
register
const
Q81: Which declaration creates a pointer to a function returning void?
void *fp();
void (*fp)();
void fp*();
function void fp();
Q82: What is the output of the following code?
int a=5;
int *p=&a;
printf("%d", *p+2);
5
7
10
Address of a
Q83: What is the output of the following code?
int a=3;
int *p=&a;
printf("%d", (*p)++);
printf("%d", a);
33
34
43
44
Q84: Which expression accesses the fifth element of an array arr using pointer notation?
*(arr+5)
*(arr+4)
arr+4
*arr+4
Q85: Which statement correctly passes an array to a function?
func(arr);
func(&arr[0]);
Both A and B
func(*arr);
Q86: Which declaration is equivalent to passing an integer array to a function?
void f(int a[]);
void f(int *a);
Both A and B
void f(array a);
Q87: Which statement correctly initializes a structure?
struct Student{int id;};
struct Student s={1};
struct Student={1};
Student s(1);
Student={1};
Q88: Which statement correctly copies one structure to another?
s1=s2;
copy(s1,s2);
mem(s1,s2);
s1.copy(s2);
Q89: Which function reads a block of binary data from a file?
fscanf()
fread()
fgets()
fprintf()
Q90: Which function writes a block of binary data to a file?
fwrite()
fprintf()
fputs()
fscanf()
Q91: What is the return value of fopen() if opening the file fails?
0
EOF
NULL
-1
Q92: Which function is commonly used to detect the end of file?
feof()
ftell()
fseek()
rewind()
Q93: Which function moves the file position relative to the current position?
fseek(fp,offset,SEEK_CUR)
ftell(fp)
rewind(fp)
feof(fp)
Q94: Which constant is used with fseek() to move relative to the end of the file?
SEEK_SET
SEEK_CUR
SEEK_END
EOF
Q95: What is the output of the following code?
int a=8;
int *p=&a;
printf("%d", sizeof(p));
1
2
Depends on the system architecture
8 always
Q96: Which statement about recursion is correct?
Every recursive function must have a base case.
Recursion cannot return a value.
Recursion always uses less memory than loops.
Recursion cannot call other functions.
Q97: Which declaration is a valid function prototype for a recursive function?
int f(int n);
recursive int f(int n);
function f(int n);
int recursive f(int n);
Q98: Which statement correctly checks whether a file pointer fp is valid?
if(fp==NULL)
if(fp==0)
Both A and B
if(fp==EOF)
Q99: Which header file contains the definition of FILE?
<string.h>
<stdlib.h>
<stdio.h>
<math.h>
Q100: Which statement is true about pointers?
A pointer stores the value of another variable.
A pointer stores the address of another variable.
Pointers can only point to integers.
Pointers cannot be NULL.
Q101: What is the output of the following code?
int a=5;
int *p=&a;
int **pp=&p;
printf("%d", **pp);
0
5
Address of a
Undefined
Q102: Which declaration creates an array of 5 pointers to int?
int *p[5];
int (*p)[5];
int p(*5);
int **p[5][5];
Q103: Which declaration creates a pointer to an array of 5 integers?
int *p[5];
int (*p)[5];
int p[5];
int **p;
Q104: Which expression accesses the first element of an array through pointer p?
*p
*(p+1)
p[1]
*(p+2)
Q105: Which function parameter correctly receives a two-dimensional array with 10 columns?
void f(int a[][]);
void f(int a[][10]);
void f(int **a);
void f(array a);
Q106: Which statement about function arguments in C is correct?
Arguments are always passed by reference.
Arguments are passed by value.
Arguments are always passed by pointer.
Arguments are always global variables.
Q107: Which statement correctly modifies a variable inside a function?
Pass the variable by value.
Pass the variable's address.
Declare it as const.
Use printf().
Q108: Which operator gives the size of a variable or type?
length
sizeof
size
count
Q109: Which header file is required for malloc()?
<stdio.h>
<stdlib.h>
<string.h>
<math.h>
Q110: Which function dynamically allocates memory?
malloc()
printf()
fopen()
scanf()
Q111: Which function releases dynamically allocated memory?
delete()
free()
remove()
close()
Q112: What happens if allocated memory is not released?
Memory leak
Compilation error
Syntax error
Nothing changes
Q113: Which function allocates memory and initializes it to zero?
malloc()
calloc()
realloc()
free()
Q114: Which function changes the size of allocated memory?
malloc()
calloc()
realloc()
free()
Q115: Which statement correctly checks whether malloc() succeeds?
if(p==NULL)
if(p==0)
Both A and B
if(p==EOF)
Q116: Which keyword defines an enumeration?
enum
typedef
struct
union
Q117: Which keyword defines a union?
enum
typedef
struct
union
Q118: Which statement about a union is correct?
All members have separate memory.
All members share the same memory.
A union cannot contain integers.
A union is the same as a structure.
Q119: Which statement about a structure is correct?
All members share the same memory.
Each member has its own storage.
A structure can contain only one data type.
Structures cannot be passed to functions.
Q120: Which statement best describes a dangling pointer?
A pointer initialized to NULL.
A pointer pointing to freed memory.
A pointer to a constant.
A pointer to a file.
Bản quyền thuộc về V1Study.com. Cấm sao chép dưới mọi hình thức!