Professional Documents
Culture Documents
C Concept PDF
C Concept PDF
C Concept PDF
com
1: The value of automatic variable that is declared but not initialized will be?
A. 0
B. 1
C. Unpredictable
D. None of above
A. An identifier
B. An array
C. An array argument
D. All of above
A. . Dennis Ritchie
B. Peter Norton
C. Ken Thompson
D. Martin Richards
A. Lower Bond
B. Upper Bond
C. Extraction
D. Rang
A. identifier
B. array
C. Array Argument
D. Function
8: Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
Explanation: 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.
10: Is there any difference between following declarations? 1 : extern int fun(); 2 : int fun();
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.
11: 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)
Explanation: /* Example for ceil() and floor() functions: */ #include #include 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
A. float
B. double
C. long double
D. far double
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.
13: 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
Explanation: C data types classification are Primary data types int char float double void Secondary data types (or) User-
defined data type Array Pointer Structure Union Enum So, clearly long int l = 2.35; is not User-defined data type. (i.e.long
int l = 2.35; is the answer.)
A. Declaration
B. Definition
C. Function
D. Error
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".
15: 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
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.
16: In the following program where is the variable a getting defined and where it is getting declared? #include int main() {
extern int a; printf("%d\n", a); return 0; } int a=20;
Explanation: - During declaration we tell the datatype of the Variable. - During definition the value is initialized.
A. Defining
B. Declaring
C. Prototyping
D. Calling
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.
18: Is there any difference in the following declarations? int myfun(int arr[]); int myfun(arr[20]);
A. Yes
B. No
Explanation: Yes, we have to specify the data type of the parameter when declaring a function.
19: Suppose a program is divided into three files f1, f2 and f3, and a variable is defined in the file f1 but used in files f2
and f3. In such a case would we need the extern declaration for the variables in the files f2 and f3?
A. Yes
B. No
20: Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and
not to others.
A. Yes
B. No
Explanation: The only way this can be achieved is to define the variable locally in main() instead of defining it globally
and then passing it to the functions which need it.
21: Is it true that a global variable may have several declarations, but only one definition?
A. Yes
B. No
Explanation: Yes, In all the global variable declarations, you need to use the keyword extern.
22: Is it true that a function may have several declarations, but only one definition?
A. Yes
B. No
Explanation: Yes, but the function declarations must be identical. Example: #include void Display(); void Display(); void
Display(); void Display() { printf("Weclome to IndiaBIX.com..!"); } int main() { Display(); return 0; } //Output: Weclome to
IndiaBIX.com..!
23: A long double can be used if range of a double is not enough to accommodate a real number.
A. True
B. False
Explanation: True, we can use long double; if double range is not enough. double = 8 bytes. long double = 10 bytes.
A. True
B. False
25: If the definition of the external variable occurs in the source file before its use in a particular function, then there is no
need for an extern declaration in the function.
A. True
B. False
Explanation: True, When a function is declared inside the source file, that function(local function) get a priority than the
extern function. So there is no need to declare a function as extern inside the same source file.
26: Size of short integer and long integer can be verified using the sizeof() operator.
A. True
B. False
Explanation: True, we can find the size of short integer and long integer using the sizeof() operator. Example: #include
int main() { short int i = 10; long int j = 10; printf("short int is %d bytes.,\nlong int is %d bytes.", sizeof(i),sizeof(j)); return 0;
} Output: short int is 2 bytes. long int is 4 bytes.
27: Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)
A. True
B. False
28: Size of short integer and long integer would vary from one platform to another.
A. True
B. False
Explanation: True, Depending on the operating system/compiler/system architecture you are working on, the range of
data types can vary.
A. True
B. False