RejinpaulPlacement
Search

Declarations and Initializations - C Programming Questions and Answers - RejinpaulPlacement

@ : Home > C Programming > Declarations and Initializations


Find us on Facebook



Follow us on Google+


Google+

1.
When we mention the prototype of a function ?
Answer & Solution
Answer: (B) Declaring
Solution: 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.
close
2.
Identify the type(s) if data type.
Answer & Solution
Answer: (D) All Of Above
Solution: All are the type of data type. Scalar include integer, float, double, char. Derived include structure, union, array/string. Pointer is also data type.
close
3.
What will be output when you will execute following c code ?

#include
int main(){
printf("%d\t",sizeof(6.5));
printf("%d\t",sizeof(90000));
printf("%d",sizeof('A'));
return 0;
}

Answer & Solution
Answer: (C) 8 4 2
Solution: Kindly, Compile the program in Turbo C and check the output.
close
4.
What is the output of the program ??

#include
int main()
{
struct emp
{
char name[20];
int age;
float sal;
};
struct emp e = {"Tiger"};
printf("%d, %f\n", e.age, e.sal);
return 0;
}

Answer & Solution
Answer: (A) 0, 0.000000
Solution:  When an automatic structure is partially initialized remaining elements are initialized to 0(zero).
close
5.
The value of automatic variable that is declared but not initialized will be ??
Answer & Solution
Answer: (C) Unpredictable
Solution:
close
6.
How to comment in C language ?
Answer & Solution
Answer: (D) A & B
Solution:
close
7.
Which of the following special symbol allowed in a variable name ?
Answer & Solution
Answer: (D) _ (underscore)
Solution:   Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted. Names must not begin with a digit.

Examples of valid (but not very descriptive) C variable names:

=> foo
=> Bar
=> BAZ
=> foo_bar
=> _foo42
=> _
=> QuUx
close
8.
Is the following statement a declaration or definition? extern int i;
Answer & Solution
Answer: (A) Declaration
Solution: 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".
close
9.
Which of the following is correct about err used in the declaration given below ?
Answer & Solution
Answer: (A) It is a typedef for enum error.
Solution: A typedef gives a new name to an existing data type.
So err is a new name for enum error.
close
10.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
Answer & Solution
Answer: (C) rem = fmod(3.14, 2.1);
Solution: fmod(x,y) - Calculates x modulo y, the remainder of x/y.

This function is the same as the modulus operator. But fmod() performs floating point divisions.
close