IndiaBIX
IndiaBIX
Start typing & press "Enter" or "ESC" to close
  • Home
  • Jobs
  • Results
  • Current Affairs
  • GK
  • Online Test
  • HR Interview
  • BLOG

Declarations and Initializations

  • Home
  • Computer Science & Engineering
  • C Programming Questions and Answers
  • Declarations and Initializations
1. 

When we mention the prototype of a function?

A. Defining
B. Declaring
C. Prototyping
D. Calling

Answer: Option B

Explanation:

 

A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function's name, argument types and return type.

While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface.

View Answer Discuss Workspace Report

2. 

In the following program where is the variable a getting defined and where it is getting declared?

#include<stdio.h>
int main()
{
    extern int a;
    printf("%d\n", a);
    return 0;
}
int a=20;
A. extern int a is declaration, int a = 20 is the definition
B. int a = 20 is declaration, extern int a is the definition
C. int a = 20 is definition, a is not defined
D. a is declared, a is not defined

Answer: Option A

Explanation:

- During declaration we tell the datatype of the Variable.

- During definition the value is initialized.

View Answer Discuss Workspace Report

3. 

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

Answer: Option C

Explanation:

extern int x; - is an external variable declaration.

double pow(double, double); - is a function prototype declaration.

Therefore, 1 and 3 are declarations. 2 is definition.

View Answer Discuss Workspace Report

4. 

Is the following statement a declaration or definition? extern int i;

A. Declaration
B. Definition
C. Function
D. Error

Answer: Option A

Explanation:

Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i)

Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference".

View Answer Discuss Workspace Report

5. 

Which of the following is not user defined data type?

1 :

struct book
{
    char name[10];
    float price;
    int pages;
};

2 :

long int l = 2.35;

3 :

enum day {Sun, Mon, Tue, Wed};

 

A. 1
B. 2
C. 3
D. Both 1 and 2

Answer: Option B

Explanation:

C data types classification are

 

  1. Primary data types
    1. int
    2. char
    3. float
    4. double
    5. void
  2. Secondary data types (or) User-defined data type
    1. Array
    2. Pointer
    3. Structure
    4. Union
    5. Enum

 

So, clearly long int l = 2.35; is not User-defined data type.
(i.e.long int l = 2.35; is the answer.)

View Answer Discuss Workspace Report

6. 

By default a real number is treated as a

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

Answer: Option B

Explanation:

In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265...

When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float.

To extend the precision further we can use long double which occupies 10 bytes of memory space.

View Answer Discuss Workspace Report

7. 

How would you round off a value from 1.66 to 2.0?

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

Answer: Option A

Explanation:

 

/* Example for ceil() and floor() functions: */

#include<stdio.h>
#include<math.h>

int main()
{
    printf("\n Result : %f" , ceil(1.44) );
    printf("\n Result : %f" , ceil(1.66) );
 
    printf("\n Result : %f" , floor(1.44) );    
    printf("\n Result : %f" , floor(1.66) );

    return 0;
}
// Output:
// Result : 2.000000
// Result : 2.000000
// Result : 1.000000
// Result : 1.000000
View Answer Discuss Workspace Report

8. 

Is there any difference between following declarations?

1 : extern int fun();
2 : int fun();
A. Both are identical
B. No difference, except extern int fun(); is probably in another file
C. int fun(); is overrided with extern int fun();
D. None of these

Answer: Option B

Explanation:

extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file.

View Answer Discuss Workspace Report

  • 1
  • 2

Questions & Answers

Aptitude Chemical Engineering Civil Engineering Computer Science & Engineering Current Affairs Data Interpretation Electrical & Electronics Engineering Electronics & Communication Engineering General Knowledge Logical Reasoning Mechanical Engineering Non Verbal Reasoning Verbal Ability Verbal Reasoning

Interviews

HR Interview

Jobs

Sarkari Jobs

Results

Rojgar ResultSarkari Result

Admission

Admission 2023

Admit Card

Admit Card 2023

Answer Key

Answer Key 2023
copyright
Privacy Policy
© 2025 IndiaBIX. All Rights Reserved.

Report