Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 87
1-
Does there exist any way to make the command-line arguments available to other functions without passing them as arguments to the function?
A -
Yes
B -
No
2-
What will be the output of the program?
#include<stdio.h>
int get();
int main()
{
const int x = get();
printf("%d", x);
return 0;
}
int get()
{
return 20;
}
A -
Garbage value
B -
Error
C -
20
D -
0
3-
Point out the error in the program.
#include<stdio.h>
#include<stdlib.h>
int fun(const union employee *e);
union employee
{
char name[15];
int age;
float salary;
};
const union employee e1;
int main()
{
strcpy(e1.name, "A");
fun(&e1);
printf("%s %d %f", e1.name, e1.age, e1.salary);
return 0;
}
int fun(const union employee *e)
{
strcpy((*e).name, "B");
return 0;
}
A -
Error: RValue required
B -
Error: cannot convert parameter 1 from 'const char[15]' to 'char *'
C -
Error: LValue required in strcpy
D -
No error
4-
What function should be used to free the memory allocated by calloc() ?
A -
dealloc();
B -
malloc(variable_name, 0)
C -
free();
D -
memalloc(variable_name, 0)
5-
Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
struct ex
{
int i;
float j;
char *s
};
struct ex *p;
p = (struct ex *)malloc(sizeof(struct ex));
p->s = (char*)malloc(20);
return 0;
}
A -
free(p); , free(p->s);
B -
free(p->s); , free(p);
C -
free(p->s);
D -
free(p);
6-
What do the following declaration signify?
void *cmp();
A -
cmp is a pointer to an void type.
B -
cmp is a void type pointer variable.
C -
cmp is a function that return a void pointer.
D -
cmp function returns nothing.
7-
What will be the output of the program?
#include<stdio.h>
int main()
{
char huge *near *far *ptr1;
char near *far *huge *ptr2;
char far *huge *near *ptr3;
printf("%d, %d, %d\n", sizeof(**ptr1), sizeof(ptr2), sizeof(*ptr3));
return 0;
}
A -
4, 4, 4
B -
2, 2, 2
C -
2, 8, 4
D -
2, 4, 8
8-
Point out the error in the following program.
#include<stdio.h>
void display(int (*ff)());
int main()
{
int show();
int (*f)();
f = show;
display(f);
return 0;
}
void display(int (*ff)())
{
(*ff)();
}
int show()
{
printf("IndiaBIX");
}
A -
Error: invalid parameter in function display()
B -
Error: invalid function call f=show;
C -
No error and prints "IndiaBIX"
D -
No error and prints nothing.
9-
We can modify the pointers "source" as well as "target".