C 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. 32
C. 64
D. 63

View Answer


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

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

View Answer


3. Which of the following cannot be a variable name in C?

A. TRUE
B. friend
C. export
D. volatile

View Answer


4. What is the output of this program?

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

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

View Answer


5. What is the output of this program?

    #include <stdio.h>
    int main()
    {
        int i;
        for (i = 0;i < 5; i++)
        int a = i;
        printf("%d", a);
    }

A. Syntax error in declaration of a
B. No errors, program will show the output 5
C. Redeclaration of a in same scope throws error
D. a is out of scope when printf is called

View Answer


6. What is the output of this program?

  #include <stdio.h>
  int var = 20;
  int main()
  {
    int var = var;
    printf("%d ", var);
    return 0;
  }

A. Garbage Value
B. 20
C. Compiler Error
D. None of these

View Answer


7. What is size of int in C ?

A. 2 bytes
B. 4 bytes
C. 8 bytes
D. Depends on the system/compiler

View Answer


8. Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)

A. TRUE
B. FALSE
C. May Be
D. Can't Say

View Answer


9. Which is false?

A. Constant variables need not be defined as they are declared and can be defined later
B. Global constant variables are initialized to zero
C. const keyword is used to define constant values
D. You cannot reassign a value to a constant variable

View Answer


10. Array is ______ datatype in C Programming language.

A. Derived Data type
B. Primitive Data type
C. Custom Data type
D. None of these

View Answer


11. If you pass an array as an argument to a function, what actually gets passed?

A. Address of last element of Array
B. Value of first element
C. Base address of array
D. Value of elements in array

View Answer


12. When double is converted to float, the value is?

A. Rounded
B. Truncated
C. Depends on the standard
D. Depends on the compiler

View Answer


13. Which of the following is not a logical operator?

A. !
B. &&
C. ||
D. |

View Answer


14. Which of the following can have different meaning in different contexts?

A. &
B. *
C. Both A and B
D. None of the above

View Answer


15. Which of the following is not a valid declaration in C?
 1. short int x;    
2. signed short x; 
3. short x; 
4. unsigned short x;

A. 1 and 2
B. 2 and 4
C. 3 and 4
D. All are valid

View Answer


16. The minimum number of temporary variable needed to swap the content two variables is?

A. 2
B. 3
C. 0
D. 1

View Answer


17. What is short int in C programming?

A. The basic data type of C
B. Qualifier
C. Short is the qualifier and int is the basic datatype
D. All of the mentioned

View Answer


18. The precedence of arithmetic operators is (from highest to lowest)?

A. %, *, /, +, -
B. %, +, /, *, -
C. %, +, -, *, /
D. +, -, %, *, /

View Answer


19. Which of the following data type will throw an error on modulus operation(%)?

A. int
B. char
C. float
D. long

View Answer


20. Relational operators cannot be used on:

A. String
B. float
C. long
D. structure

View Answer


21. What is the output of this program?

int main()
{
char ch;
ch = 128;
printf("%d", ch);
return 0;
}

A. 128
B. -128
C. Depends on compiler
D. None of the above

View Answer


22. What is the output of this program?

int main()
{
float x = 'a';
printf("%f", x);
return 0;
}

A. a
B. 0.000000
C. 97.000000
D. Run time error

View Answer


23. How would you round off a value from 6.66 to 7.0?

A. ceil(6.66)
B. floor(6.66)
C. roundup(6.66)
D. roundto(6.66)

View Answer


24. What will be the output of the program in 16 bit platform ?

#include <stdio.h>
int main()
{
    extern int i;
    i = 20;
    printf("%d", sizeof(i));
    return 0;
}

A. 2
B. 4
C. 8
D. Linker Error

View Answer


25. What will be output when you will execute following c code?

#include <stdio.h>
int main()
{
    printf("%d	",sizeof(5.5));
    printf("%d	",sizeof(50000));
    printf("%d",sizeof('A')); 
    return 0;
  }

A. 4 2 1
B. 8 4 4
C. 8 4 2
D. compiler dependent

View Answer


26. What is the output of this program?

void main()
{
      int i=0, j=1, k=2, m;
      m = i++ || j++ || k++;
      printf("%d %d %d %d", m, i, j, k);
}

A. 1 1 2 3
B. 1 1 2 2
C. 0 1 2 2
D. 0 1 2 3

View Answer


27. What is the output of this program?

        
void main()
{
      int c = - -14; 
      printf("%d", c); 
}

A. 13
B. 14
C. -14
D. Compilation Error

View Answer


28. What is the output of this program?

void main()
{ 
      int i=5; 
      i = !i>10; 
      printf("%d", i); 
}

A. 5
B. 10
C. 0
D. None of the above

View Answer


29. What is the output of this program?

		 
void main()
{
      int p, q, r, s;
      p = 1;
      q = 2;
      r = p, q;
      s = (p, q);
      printf("p=%d q=%d", p, q);
}

A. p=1 q=1
B. p=1 q=2
C. p=2 q=2
D. Invalid Syntex

View Answer


30. What is the output of this program?

void main()
{
   printf("%x",-1<<4);
}

A. fff0
B. fff1
C. fff2
D. fff3

View Answer


31. What is the output of this program?

#include <stdio.h>
void main()
{
   int a=1, b=2, c=3, d;
   d = (a=c, b+=a, c=a+b+c);
   printf("%d %d %d %d", d, a, b, c);
}

A. 11 3 5 11
B. 11 1 5 11
C. 11 3 2 11
D. 11 3 3 11

View Answer


32. What is the output of this program?

void main()
{
   int a, b = 5, c;
   a = 5 * (b++);
   c = 5 * (++b);
   printf("%d %d",a,c);
}

A. 30 35
B. 30 30
C. 25 30
D. 25 35

View Answer


33. What is the output of this program?

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

A. 0
B. 1
C. -1
D. NULL

View Answer


34. What is the output of this program?

#include <stdio.h>
int main(){
    char num = '10';
	printf("%d", num);
	return 0;
}

A. 49
B. 48
C. 10
D. 8

View Answer


35. What is the output of this program?

#include <stdio.h>
int main(){
    void  num=10;
	printf("%v", num);
	return 0;
}

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

View Answer


36. What is the output of this program?

#include <stdio.h>
int main(){
    printf("%d	",sizeof(2.5));
	printf("%d	",sizeof(2));
	printf("%d",sizeof('A'));
	return 0;
}

A. 8 4 2
B. 4 4 1
C. 8 4 1
D. 4 4 2

View Answer


37. What is the output of this program?

#include <stdio.h>
int main(){
   signed a;
	unsigned b;
	a = 6u + -16 + 16u + -6;
	b = a + 1;
	if(a == b)
	printf("%d %d",a,b);
	else
	printf("%u %u",a, b);
    return 0;
}

A. Compilation error
B. 1 0
C. 0 0
D. 0 1

View Answer


38. By default a real number is treated as a

A. float
B. double
C. long double
D. far double

View Answer


39. The format identifier %i is also used for _____ data type?

A. char
B. int
C. float
D. double

View Answer


40. Variable names beginning with underscore is not encouraged. Why?

A. It is not standardized
B. To avoid conflicts since assemblers and loaders use such names
C. To avoid conflicts since library routines use such names
D. To avoid conflicts with environment variables of an operating system

View Answer






Also check :


Discussion



* You must be logged in to add comment.