Array & String

Array & String

Programming Multiple Choice Question -Array & String

This section focuses on the “Array & String” of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. How many keywords are there in c ?

A. 31
B. 64
C. 32
D. 63

Ans : C
Explanation: It will give compile time error because a is not declared.

2. Which of the following is true for variable names in C?

A. Reserved Word can be used as variable name
B. Variable can be of any length
C. They can contain alphanumeric characters as well as special characters
D. Variable names cannot start with a digit

Ans : A
Explanation: Variable names cannot start with a digit in C Programming language.

3. Find out the output of following program? if input a is 3 and b is 4

A. 3
B. 2
C. runtime error
D. compile time error

Ans : B
Explanation: In C, scanf returns the number of inputs it has successfully read it means here is two variable 3 and 4 so scanf return 2(successfully read)

4. What is the output of this program?

void main()
{
int x = 10;
float x = 10;
printf(“%d”, x)
}

A. 10,10
B. 10
C. Compilations Error
D. 10.1

Ans : C
Explanation: Since the variable x is defined both as integer and as float, it results in an Compilations Error

5.What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = printf(“alfatechlab”);
i = printf(“%d “, i);
printf(“%d “, i);
return 0;
}

A. Alfatechlab 11 3
B. Alfatechlab 14 2
C. Alfatechlab 12 3
D. Compilation Error

Ans : A
Explanation: In C, printf() returns the number of characters successfully written on the output. Here Alfatechlab contain 11 character therefore i = 11 and then i is printed now again value of printf is assign but this time it print 3 since it contain 3 character %,d and space.
i = printf(“alfatechlab”); // print 11
i = printf(“%d “, i);// 3

6. Output of this statement is :

printf ( “%d” , printf ( “Alfatechlab” ) );

A. Syntex Error
B. Alfatechlab11
C. gives garbage value
D. print hello and terminates

Ans : B
Explanation: Firstly inner printf executes and will print Alfatechlab now this return the number of character printed that is 11 and this will be printed by outer printf . Hence output is Alfatechlab11

7. What is the output of this program?

#include <stdio.h>
# define scanf “%s Learn Coding “
main()
{
printf(scanf, scanf);
return 0;
}

A. %s Learn Coding Learn Coding
B. %s Learn Coding, %s Learn Coding
C. Invalid Syntex
D. Run time error

Ans : B
Explanation: printf statement will become printf(“%s Learn Coding, %s Learn Coding “);

8. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, main);
return 0;
}

A. Goes in infinite loop
B. Compilation Error
C. Gives garbage value
D. Gives Address of function main

Ans : D
Explanation: Name of the function is actually a pointer variable to the function and prints the address of the function.

9. What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = 4, 5, 6;
printf(“%d”, i);
return 0;
}

A. 4
B. 5
C. 6
D. Invalid Syntax


Ans : A
Explanation: Associativity of comma operator is from left to right, but = operator has higher precedence than comma operator.Therefore the statement i = 4, 5, 6 is treated as i = 4 .

10. Comment on the given statment:

scanf(“%d”,i);

A. Will give Segmentation fault
B. Will execute without any error
C. Will give Compilation Error
D. None of the above

Ans : A
Explanation: A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed.So as we can see segmentation fault occurs because program attempts to access a memory location that it is not allowed to access.

11. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
printf(“%d,%d”, x, y);
return 0;
}

A. 12
B. 1,2
C. Compilation Error
D. Garbage Value

Ans : A
Explanation: Printf function print all %d value of passing variable

12. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 3, y = 5;
printf(“%*d”, x, y);
return 0;
}

A. 3
B. 5
C. Compilation Error
D. Garbage Value

Ans : B
Explanation: the “*” above means or is used to specify the length of space required to print the integer and printf now takes two arguments one for space and other for integer so printf(“%*d”, x, y); will be print 5

13. What is the output of this program?

#include <stdio.h>
int main()
{
char str[25];
printf(” %d “,printf(“c-hello”));
return 0;
}

A. 7 c-hello
B. 9 c-hello
C. c-hello 9
D. c-hello 7

Ans : D
Explanation: Inner printf() will print first and then outer printf will display the length of the inner printf’s string.

14. What is the output of this program?

#include <stdio.h>
# define loop while(true)
int main()
{
loop;
printf(“c-alfatechlab”);
return 0;
}

A. Compilation error
B. c-alfatechlab
C. program never ends
D. None of the above

Ans : A
Explanation: error: ‘true’ undeclared (first use in this function)

15. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, 5.00);
return 0;
}

A. Compilation error
B. 5.00
C. 5
D. Garbage value

Ans : D
Explanation: The output will be garbage value.

16. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”,5.25);
return 0;
}

A. Compilation error
B. Garbage value
C. 5
D. 0

Ans : B
Explanation: Give Garbage value becausse 5.25 is neitheir a pure integer number(5) nor impure integer number(5.00).

17. What is the output of this program?

#include <stdio.h>
int main()
{
int a = 3;
printf(“%d”);
return 0;
}

A. Garbage value
B. Compilation error
C. 3
D. Runtime error

Ans : A
Explanation: As there is no declaration of variable a in printf function, a standard C compiler printf some garbage value as an output. This program is tested under Dev cpp and in standard online c compiler.

18. What is the output of this program?

#include <stdio.h>
int main()
{
char *ptr = “Welcome”;
printf(ptr+2);
return 0;
}

A. pointer cannot be initialized
B. lcome
C. Runtime error
D. Welco

Ans : B
Explanation: In printf, initial address of *ptr is incremented by 2 , thus it neglect “We” to welcome

19. What is the output of this program 32 bit c compiler ?

#include <stdio.h>
int main()
{
int x = 1;
printf(“%d %p”,x,x);
return 0;
}

A. Runtime error
B. 1 0x1
C. 1 00000001
D. %p is not a format specifier

Ans : B
Explanation: %p is a format specifier to print a pointer in printf or sprintf. For 64 bit c compiler, the output will be 1 0x1

20. What is the output of this program?

#include <stdio.h>
static struct student
{
int x;
int y;
}
struct_var{2,3};
int main()
{
printf(“%d %d”,struct_var.x,struct_var.y);
return 0;
}

A. Runtime Error
B. Improper representation of structure variable
C. 2 3
D. Compilation error

Ans : D
Explanation: It will give compilation error.

21. What is the output of this program?

int main() {
int i=1;
i=2+2*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behaviour, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment. Another reasonable answer is 6, if the increment is before the assignment.

22. What is the output of this program?

main ( )
{
int i;
i=1;
i=i+2*i++;
printf( “%d” , i);
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behavior, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment

23. What is the output of this program?

main()
{
int a;
a = 4+3, 4>3, 1;
printf( “%d” , a);
}

A. 7
B. 4
C. 3
D. 5

Ans : A
Explanation: 7 is the output of this program.

24. What is the output of this program?

main ()
{
int a =6;
printf( “%d %d %d ” , a,a<<2,a>>2);
}

A. 6 24 1
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans : A
Explanation: << and >> operation applied on the value of “i” and we get the output.6 24 1

25. What is the output of this program?

main ( )
{
int a=8;
printf( “%d %d %d ” , a,a<<2,a<<2);
}

A. 8 32 32
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans :A
Explanation: << operation applied on the value of “i” and we get the output.8 32 32

26. What is the output of this program?

int main()
{
int i=2;
printf( “%d %d %d ” , i,i<2,i>2);
return 0;
}

A. Compilation error
B. Garbage value
C. 5 0 1
D. 2 0 0

Ans : C
Explanation: The code will successfully compiled and give output 2 0 0

27. What is the output of this program?

int main()
{
int i=7;
printf( “%d %d %d ” , i,i&&2,i||2);
return 0;
}

A. 5 1 1
B. Compilation error
C. Garbage value
D. 7 1 1

Ans : D
Explanation: The code will successfully compiled and give output 7 1 1 .

28. What is the output of this program?

int main()
{
int i=6;
printf( “%d %d ” , i,i/2);
return 0;
}

A. 5 7
B. 6 3
C. Garbage value
D. 5 0

Ans : B
Explanation: The code will successfully compiled and give output 6 3 .

29. What is the output of this program?

int main()
{
int i=2;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 9
C. 4
D. 5

Ans : B
Explanation: The code will successfully compiled and give output 9.

30. What is the output of this program?

int main()
{
int i=-5;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. -2
B. 1
C. -1
D. 16

Ans : D
Explanation: The code will successfully compiled and give output 16.

31. What is the output of this program?

int main()
{
int k=5;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. 5 == 1 isFALSE

Ans : D
Explanation: the output of the program is 5 == 1 isFALSE

32. What is the output of this program?

int main()
{
int k=0;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 2 == 1 is TRUE
C. 0 == 1 isFALSE
D. K == 1 is FALSE

Ans : C
Explanation: the output of the program is 0 == 1 isFALSE

33. What is the output of this program?

char *str = “char *str = %c%s%c; main(){ printf(str, 2, str, 2);}”;
int main()
{
printf(str, 4, str, 4);
return 0;
}

A. char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);}
B. char *str = %c%s%c; main(){ printf(str, 4, str, 4);}
C. No output
D. Error in program

Ans : A
Explanation: char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);} is the output of this program.

34. What is the output of this program?

main ( )
{
float a=3.2547;
printf(“%2.3f”, a);
return 0;
}

A. 4
B. 4.159
C. 3.255
D. 4

Ans : C
Explanation: float a=3.2547; The variable a is declared as an float data type and initialized to value 3.2547; printf(“%2.3f “, a); The precision specifier tells .3f tells the printf function to place three number after the .(dot). Hence the output is 3.255

35. What is the output of this program?

main ( )
{
float a=6.3214;
printf(“%2.1f”, a);
return 0;
}

A. 4
B. 4.1
C. 6.3
D. 4

Ans : C
Explanation: float a=6.3214; The variable a is declared as an float data type and initialized to value 6.3214; printf(“%2.1f “, a); The precision specifier tells .1f tells the printf function to place one after the .(dot). Hence the output is 6.3

36. What is the output of this program?

int main()
{
printf(“%c”, ~(‘D’*-1));
return 0;
}

A. A
B. B
C. C
D. D

Ans : C
Explanation: The code will successfully compiled and give output C.

37. What is the output of this program?

int main()
{
printf(“%c”, ~(‘p’*-1));
return 0;
}

A. o
B. s
C. m
D. n

Ans : A
Explanation: The code will successfully compiled and give output o.

38. What is the output of this program?

int main()
{
char *p;
p=”%d”;
p++;
p++;
printf(p-2, 20);
return 0;
}

A. 11
B. 20
C. Error
D. No output

Ans : B
Explanation: The code will successfully compiled and give output 20

39. What is the output of this program?

int main()
{
printf(“%%%%%%”);
return 0;
}

A. %%%
B. %%
C. No output
D. Error

Ans : A
Explanation: The code will successfully compiled and give output %%%.

40. What is the output of this program?

int main()
{
int a=120;
printf(“%1d<0x1d>”, a);
return 0;
}

A. 1250
B. 2
C. 50
D. 120<0x1d>

Ans : D
Explanation: int a=120; The variable a is declared as an integer type and initialized to value 120. printf(“%1d<0x1d> “, a); It prints the value of variable a. Hence the output of the program is 120.

Categories C

Variables & Datatypes

Variables And Datatypes

Programming Multiple Choice Question –Variables And Datatypes

This section focuses on the “Variables and Datatypes” of the C programming. These Multiple Choice Questions (mcq) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. How many keywords are there in c ?

A. 31
B. 64
C. 32
D. 63

Ans : C
Explanation: It will give compile time error because a is not declared.

2. Which of the following is true for variable names in C?

A. Reserved Word can be used as variable name
B. Variable can be of any length
C. They can contain alphanumeric characters as well as special characters
D. Variable names cannot start with a digit

Ans : A
Explanation: Variable names cannot start with a digit in C Programming language.

3. Find out the output of following program? if input a is 3 and b is 4

A. 3
B. 2
C. runtime error
D. compile time error

Ans : B
Explanation: In C, scanf returns the number of inputs it has successfully read it means here is two variable 3 and 4 so scanf return 2(successfully read)

4. What is the output of this program?

void main()
{
int x = 10;
float x = 10;
printf(“%d”, x)
}

A. 10,10
B. 10
C. Compilations Error
D. 10.1

Ans : C
Explanation: Since the variable x is defined both as integer and as float, it results in an Compilations Error

5.What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = printf(“alfatechlab”);
i = printf(“%d “, i);
printf(“%d “, i);
return 0;
}

A. Alfatechlab 11 3
B. Alfatechlab 14 2
C. Alfatechlab 12 3
D. Compilation Error

Ans : A
Explanation: In C, printf() returns the number of characters successfully written on the output. Here Alfatechlab contain 11 character therefore i = 11 and then i is printed now again value of printf is assign but this time it print 3 since it contain 3 character %,d and space.
i = printf(“alfatechlab”); // print 11
i = printf(“%d “, i);// 3

6. Output of this statement is :

printf ( “%d” , printf ( “Alfatechlab” ) );

A. Syntex Error
B. Alfatechlab11
C. gives garbage value
D. print hello and terminates

Ans : B
Explanation: Firstly inner printf executes and will print Alfatechlab now this return the number of character printed that is 11 and this will be printed by outer printf . Hence output is Alfatechlab11

7. What is the output of this program?

#include <stdio.h>
# define scanf “%s Learn Coding “
main()
{
printf(scanf, scanf);
return 0;
}

A. %s Learn Coding Learn Coding
B. %s Learn Coding, %s Learn Coding
C. Invalid Syntex
D. Run time error

Ans : B
Explanation: printf statement will become printf(“%s Learn Coding, %s Learn Coding “);

8. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, main);
return 0;
}

A. Goes in infinite loop
B. Compilation Error
C. Gives garbage value
D. Gives Address of function main

Ans : D
Explanation: Name of the function is actually a pointer variable to the function and prints the address of the function.

9. What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = 4, 5, 6;
printf(“%d”, i);
return 0;
}

A. 4
B. 5
C. 6
D. Invalid Syntax


Ans : A
Explanation: Associativity of comma operator is from left to right, but = operator has higher precedence than comma operator.Therefore the statement i = 4, 5, 6 is treated as i = 4 .

10. Comment on the given statment:

scanf(“%d”,i);

A. Will give Segmentation fault
B. Will execute without any error
C. Will give Compilation Error
D. None of the above

Ans : A
Explanation: A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed.So as we can see segmentation fault occurs because program attempts to access a memory location that it is not allowed to access.

11. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
printf(“%d,%d”, x, y);
return 0;
}

A. 12
B. 1,2
C. Compilation Error
D. Garbage Value

Ans : A
Explanation: Printf function print all %d value of passing variable

12. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 3, y = 5;
printf(“%*d”, x, y);
return 0;
}

A. 3
B. 5
C. Compilation Error
D. Garbage Value

Ans : B
Explanation: the “*” above means or is used to specify the length of space required to print the integer and printf now takes two arguments one for space and other for integer so printf(“%*d”, x, y); will be print 5

13. What is the output of this program?

#include <stdio.h>
int main()
{
char str[25];
printf(” %d “,printf(“c-hello”));
return 0;
}

A. 7 c-hello
B. 9 c-hello
C. c-hello 9
D. c-hello 7

Ans : D
Explanation: Inner printf() will print first and then outer printf will display the length of the inner printf’s string.

14. What is the output of this program?

#include <stdio.h>
# define loop while(true)
int main()
{
loop;
printf(“c-alfatechlab”);
return 0;
}

A. Compilation error
B. c-alfatechlab
C. program never ends
D. None of the above

Ans : A
Explanation: error: ‘true’ undeclared (first use in this function)

15. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, 5.00);
return 0;
}

A. Compilation error
B. 5.00
C. 5
D. Garbage value

Ans : D
Explanation: The output will be garbage value.

16. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”,5.25);
return 0;
}

A. Compilation error
B. Garbage value
C. 5
D. 0

Ans : B
Explanation: Give Garbage value becausse 5.25 is neitheir a pure integer number(5) nor impure integer number(5.00).

17. What is the output of this program?

#include <stdio.h>
int main()
{
int a = 3;
printf(“%d”);
return 0;
}

A. Garbage value
B. Compilation error
C. 3
D. Runtime error

Ans : A
Explanation: As there is no declaration of variable a in printf function, a standard C compiler printf some garbage value as an output. This program is tested under Dev cpp and in standard online c compiler.

18. What is the output of this program?

#include <stdio.h>
int main()
{
char *ptr = “Welcome”;
printf(ptr+2);
return 0;
}

A. pointer cannot be initialized
B. lcome
C. Runtime error
D. Welco

Ans : B
Explanation: In printf, initial address of *ptr is incremented by 2 , thus it neglect “We” to welcome

19. What is the output of this program 32 bit c compiler ?

#include <stdio.h>
int main()
{
int x = 1;
printf(“%d %p”,x,x);
return 0;
}

A. Runtime error
B. 1 0x1
C. 1 00000001
D. %p is not a format specifier

Ans : B
Explanation: %p is a format specifier to print a pointer in printf or sprintf. For 64 bit c compiler, the output will be 1 0x1

20. What is the output of this program?

#include <stdio.h>
static struct student
{
int x;
int y;
}
struct_var{2,3};
int main()
{
printf(“%d %d”,struct_var.x,struct_var.y);
return 0;
}

A. Runtime Error
B. Improper representation of structure variable
C. 2 3
D. Compilation error

Ans : D
Explanation: It will give compilation error.

21. What is the output of this program?

int main() {
int i=1;
i=2+2*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behaviour, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment. Another reasonable answer is 6, if the increment is before the assignment.

22. What is the output of this program?

main ( )
{
int i;
i=1;
i=i+2*i++;
printf( “%d” , i);
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behavior, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment

23. What is the output of this program?

main()
{
int a;
a = 4+3, 4>3, 1;
printf( “%d” , a);
}

A. 7
B. 4
C. 3
D. 5

Ans : A
Explanation: 7 is the output of this program.

24. What is the output of this program?

main ()
{
int a =6;
printf( “%d %d %d ” , a,a<<2,a>>2);
}

A. 6 24 1
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans : A
Explanation: << and >> operation applied on the value of “i” and we get the output.6 24 1

25. What is the output of this program?

main ( )
{
int a=8;
printf( “%d %d %d ” , a,a<<2,a<<2);
}

A. 8 32 32
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans :A
Explanation: << operation applied on the value of “i” and we get the output.8 32 32

26. What is the output of this program?

int main()
{
int i=2;
printf( “%d %d %d ” , i,i<2,i>2);
return 0;
}

A. Compilation error
B. Garbage value
C. 5 0 1
D. 2 0 0

Ans : C
Explanation: The code will successfully compiled and give output 2 0 0

27. What is the output of this program?

int main()
{
int i=7;
printf( “%d %d %d ” , i,i&&2,i||2);
return 0;
}

A. 5 1 1
B. Compilation error
C. Garbage value
D. 7 1 1

Ans : D
Explanation: The code will successfully compiled and give output 7 1 1 .

28. What is the output of this program?

int main()
{
int i=6;
printf( “%d %d ” , i,i/2);
return 0;
}

A. 5 7
B. 6 3
C. Garbage value
D. 5 0

Ans : B
Explanation: The code will successfully compiled and give output 6 3 .

29. What is the output of this program?

int main()
{
int i=2;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 9
C. 4
D. 5

Ans : B
Explanation: The code will successfully compiled and give output 9.

30. What is the output of this program?

int main()
{
int i=-5;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. -2
B. 1
C. -1
D. 16

Ans : D
Explanation: The code will successfully compiled and give output 16.

31. What is the output of this program?

int main()
{
int k=5;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. 5 == 1 isFALSE

Ans : D
Explanation: the output of the program is 5 == 1 isFALSE

32. What is the output of this program?

int main()
{
int k=0;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 2 == 1 is TRUE
C. 0 == 1 isFALSE
D. K == 1 is FALSE

Ans : C
Explanation: the output of the program is 0 == 1 isFALSE

33. What is the output of this program?

char *str = “char *str = %c%s%c; main(){ printf(str, 2, str, 2);}”;
int main()
{
printf(str, 4, str, 4);
return 0;
}

A. char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);}
B. char *str = %c%s%c; main(){ printf(str, 4, str, 4);}
C. No output
D. Error in program

Ans : A
Explanation: char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);} is the output of this program.

34. What is the output of this program?

main ( )
{
float a=3.2547;
printf(“%2.3f”, a);
return 0;
}

A. 4
B. 4.159
C. 3.255
D. 4

Ans : C
Explanation: float a=3.2547; The variable a is declared as an float data type and initialized to value 3.2547; printf(“%2.3f “, a); The precision specifier tells .3f tells the printf function to place three number after the .(dot). Hence the output is 3.255

35. What is the output of this program?

main ( )
{
float a=6.3214;
printf(“%2.1f”, a);
return 0;
}

A. 4
B. 4.1
C. 6.3
D. 4

Ans : C
Explanation: float a=6.3214; The variable a is declared as an float data type and initialized to value 6.3214; printf(“%2.1f “, a); The precision specifier tells .1f tells the printf function to place one after the .(dot). Hence the output is 6.3

36. What is the output of this program?

int main()
{
printf(“%c”, ~(‘D’*-1));
return 0;
}

A. A
B. B
C. C
D. D

Ans : C
Explanation: The code will successfully compiled and give output C.

37. What is the output of this program?

int main()
{
printf(“%c”, ~(‘p’*-1));
return 0;
}

A. o
B. s
C. m
D. n

Ans : A
Explanation: The code will successfully compiled and give output o.

38. What is the output of this program?

int main()
{
char *p;
p=”%d”;
p++;
p++;
printf(p-2, 20);
return 0;
}

A. 11
B. 20
C. Error
D. No output

Ans : B
Explanation: The code will successfully compiled and give output 20

39. What is the output of this program?

int main()
{
printf(“%%%%%%”);
return 0;
}

A. %%%
B. %%
C. No output
D. Error

Ans : A
Explanation: The code will successfully compiled and give output %%%.

40. What is the output of this program?

int main()
{
int a=120;
printf(“%1d<0x1d>”, a);
return 0;
}

A. 1250
B. 2
C. 50
D. 120<0x1d>

Ans : D
Explanation: int a=120; The variable a is declared as an integer type and initialized to value 120. printf(“%1d<0x1d> “, a); It prints the value of variable a. Hence the output of the program is 120.

Categories C

Technical MCQ -C

C MCQ Questions

A language that doesn’t affect the way you think about programming is not worth knowing.  Alan J. Perlis

C is a general purpose, procedural programming language. C was developed by Dennis M. Ritchie at Bell Labs. C was originally first implemented on the DEC PDP-11 computer in 1972.

It was mainly developed as a system programming language to write operating system. The main features of C language include low-level access to memory, simple set of keywords, and clean style, these features make C language suitable for system programming like operating system or compiler development. C programming is highly efficient. That’s the main reason why it’s very popular despite being more than 40 years old. Standard C programs are portable. The source code written in one system works in another operating system without any change.

C is a successor of B language which was introduced around the early 1970s. The language was formalized in 1988 by the American National Standard Institute (ANSI). Today’s most popular Linux OS and RDBMS MySQL have been written in C.

Practice C MCQ Questions here on alfatechlab which will help you to clear your concepts and also to prepare for technical rounds, interviews, competitive exams etc.

Categories C

Printf & Scanf

Printf & Scanf

Programming Multiple Choice Question – Printf & Scanf

1.What is the purpose of the printf function in C?

  1. To read input from the user
  2. To write output to the screen
  3. To perform arithmetic operations
  4. To allocate memory

Answer: b) To write output to the screen

Explanation: The printf function in C is used to print output to the screen. It allows you to format the output in a specific way, such as adding new lines, tabs, or other characters.

2. What is the output of this program?

#include <stdio.h>
int main()
{
int main = 4;
printf(“%d”, main);
return 0;
}

A. 4
B. Compile time error
C. Run time error
D. give garbage value

Ans : A
Explanation: A C program can have same function name and same variable name so it will print 4

3. Find out the output of following program? if input a is 3 and b is 4

#include <stdio.h>
int main()
{
int a, b;
printf(“%d”, scanf(“%d %d”,&a,&b));
return 0;
}

A. 3
B. 2
C. runtime error
D. compile time error

Ans : B
Explanation: In C, scanf returns the number of inputs it has successfully read it means here is two variable 3 and 4 so scanf return 2(successfully read)

4. What is the output of this program?

#include <stdio.h>
void main()
{
printf(“hello\rworld\n”);
printf(“hello\b\b\bworld\n”);
}

A. world
heworld
B. hello
helloworld
C. helloworld
hellold
D. None of the mentioned

Ans : A
Explanation: ” ” for a backspace, means if u print it, cursor will print and come back 1 character . ‘ ‘ is used for carriage return to come 1 line back or in start of line.

5.What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = printf(“alfatechlab”);
i = printf(“%d “, i);
printf(“%d “, i);
return 0;
}

A. Alfatechlab 11 3
B. Alfatechlab 14 2
C. Alfatechlab 12 3
D. Compilation Error

Ans : A
Explanation: In C, printf() returns the number of characters successfully written on the output. Here Alfatechlab contain 11 character therefore i = 11 and then i is printed now again value of printf is assign but this time it print 3 since it contain 3 character %,d and space.
i = printf(“alfatechlab”); // print 11
i = printf(“%d “, i);// 3

6. Output of this statement is :

printf ( “%d” , printf ( “Alfatechlab” ) );

A. Syntex Error
B. Alfatechlab11
C. gives garbage value
D. print hello and terminates

Ans : B
Explanation: Firstly inner printf executes and will print Alfatechlab now this return the number of character printed that is 11 and this will be printed by outer printf . Hence output is Alfatechlab11

7. What is the output of this program?

#include <stdio.h>
# define scanf “%s Learn Coding “
main()
{
printf(scanf, scanf);
return 0;
}

A. %s Learn Coding Learn Coding
B. %s Learn Coding, %s Learn Coding
C. Invalid Syntex
D. Run time error

Ans : B
Explanation: printf statement will become printf(“%s Learn Coding, %s Learn Coding “);

8. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, main);
return 0;
}

A. Goes in infinite loop
B. Compilation Error
C. Gives garbage value
D. Gives Address of function main

Ans : D
Explanation: Name of the function is actually a pointer variable to the function and prints the address of the function.

9. What is the output of this program?

#include <stdio.h>
int main()
{
int i;
i = 4, 5, 6;
printf(“%d”, i);
return 0;
}

A. 4
B. 5
C. 6
D. Invalid Syntax


Ans : A
Explanation: Associativity of comma operator is from left to right, but = operator has higher precedence than comma operator.Therefore the statement i = 4, 5, 6 is treated as i = 4 .

10. Comment on the given statment:

scanf(“%d”,i);

A. Will give Segmentation fault
B. Will execute without any error
C. Will give Compilation Error
D. None of the above

Ans : A
Explanation: A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed.So as we can see segmentation fault occurs because program attempts to access a memory location that it is not allowed to access.

11. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 1, y = 2;
printf(“%d,%d”, x, y);
return 0;
}

A. 12
B. 1,2
C. Compilation Error
D. Garbage Value

Ans : A
Explanation: Printf function print all %d value of passing variable

12. What is the output of this program?

#include <stdio.h>
int main()
{
int x = 3, y = 5;
printf(“%*d”, x, y);
return 0;
}

A. 3
B. 5
C. Compilation Error
D. Garbage Value

Ans : B
Explanation: the “*” above means or is used to specify the length of space required to print the integer and printf now takes two arguments one for space and other for integer so printf(“%*d”, x, y); will be print 5

13. What is the output of this program?

#include <stdio.h>
int main()
{
char str[25];
printf(” %d “,printf(“c-hello”));
return 0;
}

A. 7 c-hello
B. 9 c-hello
C. c-hello 9
D. c-hello 7

Ans : D
Explanation: Inner printf() will print first and then outer printf will display the length of the inner printf’s string.

14. What is the output of this program?

#include <stdio.h>
# define loop while(true)
int main()
{
loop;
printf(“c-alfatechlab”);
return 0;
}

A. Compilation error
B. c-alfatechlab
C. program never ends
D. None of the above

Ans : A
Explanation: error: ‘true’ undeclared (first use in this function)

15. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”, 5.00);
return 0;
}

A. Compilation error
B. 5.00
C. 5
D. Garbage value

Ans : D
Explanation: The output will be garbage value.

16. What is the output of this program?

#include <stdio.h>
int main()
{
printf(“%d”,5.25);
return 0;
}

A. Compilation error
B. Garbage value
C. 5
D. 0

Ans : B
Explanation: Give Garbage value becausse 5.25 is neitheir a pure integer number(5) nor impure integer number(5.00).

17. What is the output of this program?

#include <stdio.h>
int main()
{
int a = 3;
printf(“%d”);
return 0;
}

A. Garbage value
B. Compilation error
C. 3
D. Runtime error

Ans : A
Explanation: As there is no declaration of variable a in printf function, a standard C compiler printf some garbage value as an output. This program is tested under Dev cpp and in standard online c compiler.

18. What is the output of this program?

#include <stdio.h>
int main()
{
char *ptr = “Welcome”;
printf(ptr+2);
return 0;
}

A. pointer cannot be initialized
B. lcome
C. Runtime error
D. Welco

Ans : B
Explanation: In printf, initial address of *ptr is incremented by 2 , thus it neglect “We” to welcome

19. What is the output of this program 32 bit c compiler ?

#include <stdio.h>
int main()
{
int x = 1;
printf(“%d %p”,x,x);
return 0;
}

A. Runtime error
B. 1 0x1
C. 1 00000001
D. %p is not a format specifier

Ans : B
Explanation: %p is a format specifier to print a pointer in printf or sprintf. For 64 bit c compiler, the output will be 1 0x1

20. What is the output of this program?

 

#include <stdio.h>
static struct student
{
int x;
int y;
}
struct_var{2,3};
int main()
{
printf(“%d %d”,struct_var.x,struct_var.y);
return 0;
}

A. Runtime Error
B. Improper representation of structure variable
C. 2 3
D. Compilation error

Ans : D
Explanation: It will give compilation error.

20. What is the output of this program?

#include <stdio.h>
static struct student
{
int x;
int y;
}
struct_var{2,3};
int main()
{
printf(“%d %d”,struct_var.x,struct_var.y);
return 0;
}

A. Runtime Error
B. Improper representation of structure variable
C. 2 3
D. Compilation error

A. Runtime Error
B. Improper representation of structure variable
C. 2 3
D. Compilation error

Ans : D
Explanation: It will give compilation error.

21. What is the output of this program?

int main() {
int i=1;
i=2+2*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behaviour, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment. Another reasonable answer is 6, if the increment is before the assignment.

22. What is the output of this program?

main ( )
{
int i;
i=1;
i=i+2*i++;
printf( “%d” , i);
}

A. 2
B. 3
C. 4
D. 5

Ans : C
Explanation: This is undefined behavior, since i is modified more than once between sequence points. For instance, this compiler gives 4 as the answer, because it puts the increment after the assignment

23. What is the output of this program?

main()
{
int a;
a = 4+3, 4>3, 1;
printf( “%d” , a);
}

A. 7
B. 4
C. 3
D. 5

Ans : A
Explanation: 7 is the output of this program.

24. What is the output of this program?

main ()
{
int a =6;
printf( “%d %d %d ” , a,a<<2,a>>2);
}

A. 6 24 1
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans : A
Explanation: << and >> operation applied on the value of “i” and we get the output.6 24 1

25. What is the output of this program?

main ( )
{
int a=8;
printf( “%d %d %d ” , a,a<<2,a<<2);
}

A. 8 32 32
B. 5 1 20
C. 5 20 20
D. 5 1 1

Ans :A
Explanation: << operation applied on the value of “i” and we get the output.8 32 32

26. What is the output of this program?

int main()
{
int i=2;
printf( “%d %d %d ” , i,i<2,i>2);
return 0;
}

A. Compilation error
B. Garbage value
C. 5 0 1
D. 2 0 0

Ans : C
Explanation: The code will successfully compiled and give output 2 0 0

27. What is the output of this program?

int main()
{
int i=7;
printf( “%d %d %d ” , i,i&&2,i||2);
return 0;
}

A. 5 1 1
B. Compilation error
C. Garbage value
D. 7 1 1

Ans : D
Explanation: The code will successfully compiled and give output 7 1 1 .

28. What is the output of this program?

int main()
{
int i=6;
printf( “%d %d ” , i,i/2);
return 0;
}

A. 5 7
B. 6 3
C. Garbage value
D. 5 0

Ans : B
Explanation: The code will successfully compiled and give output 6 3 .

29. What is the output of this program?

int main()
{
int i=2;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. 2
B. 9
C. 4
D. 5

Ans : B
Explanation: The code will successfully compiled and give output 9.

30. What is the output of this program?

int main()
{
int i=-5;
i=i+i*i++;
printf(“%d”,i);
return 0;
}

A. -2
B. 1
C. -1
D. 16

Ans : D
Explanation: The code will successfully compiled and give output 16.

31. What is the output of this program?

int main()
{
int k=5;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 1 == 1 is TRUE
C. 1 == 1 is FALSE
D. 5 == 1 isFALSE

Ans : D
Explanation: the output of the program is 5 == 1 isFALSE

32. What is the output of this program?

int main()
{
int k=0;
printf(“%d == 1 is” “%s”, k, k==1?”TRUE”:”FALSE”);
return 0;
}

A. k == 1 is TRUE
B. 2 == 1 is TRUE
C. 0 == 1 isFALSE
D. K == 1 is FALSE

Ans : C
Explanation: the output of the program is 0 == 1 isFALSE

33. What is the output of this program?

char *str = “char *str = %c%s%c; main(){ printf(str, 2, str, 2);}”;
int main()
{
printf(str, 4, str, 4);
return 0;
}

A. char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);}
B. char *str = %c%s%c; main(){ printf(str, 4, str, 4);}
C. No output
D. Error in program

Ans : A
Explanation: char *str = char *str = %c%s%c; main(){ printf(str, 2, str, 2);}; main(){ printf(str, 2, str, 2);} is the output of this program.

34. What is the output of this program?

main ( )
{
float a=3.2547;
printf(“%2.3f”, a);
return 0;
}

A. 4
B. 4.159
C. 3.255
D. 4

Ans : C
Explanation: float a=3.2547; The variable a is declared as an float data type and initialized to value 3.2547; printf(“%2.3f “, a); The precision specifier tells .3f tells the printf function to place three number after the .(dot). Hence the output is 3.255

35. What is the output of this program?

main ( )
{
float a=6.3214;
printf(“%2.1f”, a);
return 0;
}

A. 4
B. 4.1
C. 6.3
D. 4

Ans : C
Explanation: float a=6.3214; The variable a is declared as an float data type and initialized to value 6.3214; printf(“%2.1f “, a); The precision specifier tells .1f tells the printf function to place one after the .(dot). Hence the output is 6.3

36. What is the output of this program?

int main()
{
printf(“%c”, ~(‘D’*-1));
return 0;
}

A. A
B. B
C. C
D. D

Ans : C
Explanation: The code will successfully compiled and give output C.

37. What is the output of this program?

int main()
{
printf(“%c”, ~(‘p’*-1));
return 0;
}

A. o
B. s
C. m
D. n

Ans : A
Explanation: The code will successfully compiled and give output o.

38. What is the output of this program?

int main()
{
char *p;
p=”%d”;
p++;
p++;
printf(p-2, 20);
return 0;
}

A. 11
B. 20
C. Error
D. No output

Ans : B
Explanation: The code will successfully compiled and give output 20

39. What is the output of this program?

int main()
{
printf(“%%%%%%”);
return 0;
}

A. %%%
B. %%
C. No output
D. Error

Ans : A
Explanation: The code will successfully compiled and give output %%%.

40. What is the output of this program?

int main()
{
int a=120;
printf(“%1d<0x1d>”, a);
return 0;
}

A. 1250
B. 2
C. 50
D. 120<0x1d>

Ans : D
Explanation: int a=120; The variable a is declared as an integer type and initialized to value 120. printf(“%1d<0x1d> “, a); It prints the value of variable a. Hence the output of the program is 120.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.
Categories C

About History

C About & History

1. Who is the father of Programming Language C?

A. Ada Lovelace
B. Dennis Ritchie
C. Tim Berners-Lee
D. Alan Turing

Ans : B
Explanation:  C programming language was  developed by Dennis Ritchie in  1972 at the Bell Laboratories of the AT & T that is located in U.S.A. So we call  Dennis Ritchie is the founder of c language. . 

2. where was the c language developed ?

A. Stanford Lab
B. MIT Lab
C. Harvard University
D. AT & T Bell Laboratory

Ans : A
Explanation:  The C programming language was developed  at AT & T Bell laboratories during 1970-72s

3. Many features of C were derived from which language ?

A. PASCAL
B. B
C. BASIC
D. FORTRAN

Ans : B
Explanation: Richie and Thompson wanted to rewrite the operating system in B, a language they had previously developed, but B were type worthy, and therefore mixed bits / words were not well suited for address and PDP-11 type . B was a simplified version of Thompson’s BCPL, which was more ALGOL than the language.

4. What is C language?

A. C language is a structure/procedure oriented
B. C language is a middle level programming language
C. C language was invented for implementing UNIX operating system
D. All of the above

Ans : D
Explanation: C language is just a high level computer language. High level languages help Human beings to express Logic. Computers dont understand this language. So, you need a mediator. This mediator is usually a Compiler or Interpreter. In case of C, we have a compiler. The compiler translates the logic expressed in C into Machine Code which is the language of computers.

5. First version of C Programming language is ____ .

A. K&R
B. C89
C. ANSI
D. R&K

Ans : A
Explanation: In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language known as “K&R” .

6. C was initially used for

A. General purpose
B. System development work
C. Data processing
D. None of these

Ans : B
Explanation: C was initially used for system development work, particularly the programs that make-up the operating system.

7. C programming language is

A. Procedural language
B. Object Oriented language
C. Scripting languages
D. None of these

Ans : A
Explanation: C programs follow a procedure of steps written in it, called functions. It follows a top-down approach i.e. much importance is given to flow of program rather than on data on which functions operate.

8. Which Committee standardize C Programming Language ?

A. IEEE
B. ISO
C. IEC
D. ANSI

Ans : D
Explanation: American National Standards Institute.ANSI C (these days better known as C89) was the first standardized form of the C language.

9. Which year C language is developed?

A. 1970
B. 1971
C. 1972
D. 1973

Ans : C
Explanation: C programming language was developed at Bell Laboratories in 1972 by Dennis Ritchie.

10. Which of these is not an example for IDE in C?

A. Turbo
B. Pycharm
C. Code::Blocks
D. Borland

Ans : B
Explanation: Pycharm used for python While Turbo and Code:: Blocks are IDE of C

11. Which of these is true about embedded C?
i)Embedded C is the extension of C programming language
ii)Embedded C is used to develop micro controller based applications.
iii)Embedded C includes features not available in normal C like fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.

A. Only i & ii
B. Only i & iii
C. Only ii & ii
D. All of the above

Ans : D
Explanation: An Extension of C programming language with header files is known as embedded C. It provides the supportive framework to the processor functioning in the embedded devices for programs development. There are so many examples of embedded C programming, we use on the daily basis one of them is smart phone, other examples are RAM, ROM for limited resources. Embedded C is the extension of C programming language.Embedded C is used to develop micro controller based applications.Embedded C includes features not available in normal C like fixed-point arithmetic, named address spaces, and basic I/O hardware addressing

12. C can be used on?

A. Only MS-Dos operating System
B. Only Linux operating system
C. Only Windows operating system
D. All of the above

Ans : D
Explanation: C can be used on all of the above operting system.MS-Dos operating SystemLinux operating systemWindows operating system

 

13. Which is not a character Of C?

A. $
B. ^
C. –
D. |

Ans : A
Explanation: $ is not a character Of C

14. Which is true in case of ANSI C?

A. Comments are represented in /* and */
B. Nested comments are not allowed
C. Comments are not allowed within a string constant
D. Nested comments are allowed

Ans : B
Explanation: Nested comments are not allowed in case of ANSI C.

15. Identify the wrong Statement?

A. #define /* symbolic constant */ Max 100
B. int /*declaration*/ a,b;
C. char c1,c2;
D. #define MAX 25;

Ans : D
Explanation: #define MAX 25; is wrong Statement.

16. Identify the correct statement?

A. The variable names VOLUME and volume are identical
B. The variable names sun and sun are identical
C. Variables are not declared before use
D. Variable may he absent in a declaration.

Ans : D
Explanation: Variable may he absent in a declaration is the correct statement

17. An escape sequence commence with

A. \
B. /
C. ?
D. #

Ans : A
Explanation: An escape sequence commence with .

18. Identify the wrong statement?

A. # define is a preprocessor facility.
B. # define aids in modifying a constant value throughout the program.
C. # define improves the readability of the program.
D. # define uses a statement terminator.

Ans : D
Explanation: # define uses a statement terminator is the wrong statement.

19. Where does the execution of every C program starts?

A. Every C program starts in the initialize ( ) function.
B. Every C program starts in the begin ( ) function.
C. Every C program starts in the main () function.
D. Every C program starts in the start ( ) function.

Ans : C
Explanation: The execution of every C program starts from  main function – main()

20. Identify the separator(s) in C?

A. white space character
B. Comments
C. Both A and B
D. None of these 

Ans : C
Explanation: comments and white space character are the  separator(s) in C.

21. A program which translates a high level language into a machine level  language  is know as 

A. Compiler
B. Interpreter
C. Both A and B
D. none of the above

Ans : C
Explanation: A program which translates a high level language  into a machine level language is know as both Compiler and Interpreter.

22. Indicate which of the following is not true about an interpreter?

A. Interpreter generates an object program from the source program
B. Interpreter is a kind of translator
C. Interpreter analysis each source statement every time it is to be executed
D. None of the above

Ans : D
Explanation: None of the above statement is indicate not true about an interpreter

23. The errors that can be pointed out by the compiler are?

A. logical error
B. semantic error
C. Syntax errors
D. All of above

Ans : C
Explanation: The errors that can be pointed out by the compiler are syntax errors

24. Which of the following statements is not true?

A. A FORTRAN program written for the IBM-PC, is totally different from a FORTRAN program written for the execution of SUN machine.
B. FORTRAN is a high-level language
C. FORTRAN is extensively used write program for performing scientific computations
D. None of the above

Ans : A
Explanation: A FORTRAN program written for the IBM-PC, is totally different from a FORTRAN program written for the execution of SUN machine is not true.

25. The language C is

A. an assembly language
B. a machine language
C. a third generation high level language
D. none of the above

Ans : C
Explanation: The language C is a third generation high level language

26. A program that converts a high level language program to a set of instructions that can run on a machine is know as  ?

A. editor
B. debugger
C. compiler
D. All of  above

Ans : C
Explanation: A program that converts a high level language program to a set of instructions that can run on a machine is called  compiler.

27. The mapping from assembly language instructions into machine language instructions is?

A. one-one
B. many-many
C. many-one
D. one-many

Ans : A
Explanation: The mapping from assembly language instructions into machine language instructions is one to one

28. A compiler is

A. a machine-independent and OS-independent
B. machine-dependent and OS-dependent
C. machine-dependent and OS-independent
D. machine-independent and OS-dependent

Ans : B
Explanation: A compiler is machine-dependent and OS-dependent

29. Which one of the following statement is incorrect?

A. A compiler compiles the source program
B. An assembler takes an assembly program as input.
C. A compiler does the same type of function as interpreter
D. None of the above

Ans : C
Explanation: A compiler does the same type of function as interpreter is not true.

30. C compiler traps

A. logical errors
B. syntax errors
C. Both A and B
D. none of the above

Ans : B
Explanation: C compiler traps syntax errors .

31. A translator which reads an entire pro-gram written in high level and converts it into machine language code is?

A. Compiler
B. Translator
C. Assembler
D. System software

Ans : A
Explanation: A translator which reads an entire pro-gram written in high level and converts it into machine language code is Compiler.

32. Which of the following is not one of the processes that a high level language program must go through before it is ready to be executed

A. Translation
B. Controlling
C. Loading
D. Linking

Ans : B
Explanation: The following is not one of the processes that a high level language program must go through before it is ready to be executed is “Controlling”.

 

33. Which of the following is related to machine language?

A. Difficult
B. First generation to learn language
C. Machine
D. All of the above

Ans : D
Explanation: The following is related to machine language is all.

34. C is a

A. High level language with low level features
B. Completely low level language
C. Completely high level language
D. none of the above

Ans : A
Explanation: C is a High level language with low level features.

Categories C