C Programming MCQs

C Programming :: Declarations and Initializations MCQs

 

we’ve collected some important MCQs to help you out in your learning process of C Programming topic (Declearation and Initializations).

 

1. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
A. rem = 3.14 % 2.1;
B. rem = modf(3.14, 2.1);
C. rem = fmod(3.14, 2.1);
D. Remainder cannot be obtain in floating point division.

 

2. What are the types of linkages?
A. Internal and External
B. External, Internal and None
C. External and None
D. Internal

 

3. Which of the following special symbol allowed in a variable name?
A. * (asterisk)
B. | (pipeline)
C. – (hyphen)
D. _ (underscore)

 

4. Which of the following is correct about err used in the declaration given below?

 typedef enum error { warning, test, exception } err;
A. It is a typedef for enum error.
B. It is a variable of type enum error.
C. The statement is erroneous.
D. It is a structure.

 

5. Point out the error in the following program.

#include<stdio.h>
int main()
{
    int (*p)() = fun;
    (*p)();
    return 0;
}
int fun()
{
    printf("IndiaBix.com\n");
    return 0;
}
A. Error: in int(*p)() = fun;
B. Error: fun() prototype not defined
C. No error
D. None of these

 

6.
1 : typedef long a;
extern int a c;
2 : typedef long a;
extern a int c;
3 : typedef long a;
extern a c;
A. 1 correct
B. 2 correct
C. 3 correct
D. 1, 2, 3 are correct

 

7. Which of the structure is correct?

1 :
struct book
{
    char name[10];
    float price;
    int pages;
};
2 :
struct aa
{
    char name[10];
    float price;
    int pages;
}
3 :
struct aa
{
    char name[10];
    float price;
    int pages;
}
A. 1
B. 2
C. 3
D. All of above

 

8. Which of the following correctly represents a long double constant?
A. 6.68
B. 6.68L
C. 6.68f
D. 6.68LF

 

9. Which of the declaration is correct?
A. int length;
B. char int;
C. int long;
D. float double;

 

10. Point out the error in the following program.

#include<stdio.h>
struct emp
{
    char name[20];
    int age;
};
int main()
{
    emp int xx;
    int a;
    printf("%d\n", &a);
    return 0;
}
A. Error: in printf
B. Error: in emp int xx;
C. No error.
D. None of these.

 

11. Point out the error in the following program (if it is compiled with Turbo C compiler).

#include<stdio.h>
int main()
{
    display();
    return 0;
}
void display()
{
    printf("IndiaBIX.com");
}
A. No error
B. display() doesn’t get invoked
C. display() is called before it is defined
D. None of these

 

12. When we mention the prototype of a function?
A. Defining
B. Declaring
C. Prototyping
D. Calling

 

13. Is the following statement a declaration or definition?
extern int i;
A. Declaration
B. Definition
C. Function
D. Error
14. Identify which of the following are declarations

1 : extern int x;
2 : float square ( float x ) { … }
3 : double pow(double, double);
A. 1
B. 2
C. 1 and 3
D. 3

 

15. By default a real number is treated as a
A. float
B. double
C. long double
D. far double

Leave a comment

Your email address will not be published. Required fields are marked *