C Concept PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

by eduzip.

com

C Programming: C Basic Concepts


Total Questions: 29

For Answers Click Here: http://www.eduzip.com/c-programming/c-basic-concepts.html

1: The value of automatic variable that is declared but not initialized will be?

A. 0
B. 1
C. Unpredictable
D. None of above

2: Choose the correct statement

A. An identifier may start with an underscore


B. An identifier may end with an underscore
C. IF is a valid identifier
D. All of above

3: The const feature can be applied to?

A. An identifier
B. An array
C. An array argument
D. All of above

4: The expression 5-2-3*5-2 will evaluate to 18 if ?

A. - is left associative and * has precedence over -


B. - is right associative and * has precedence over -
C. - is right associative and - has precedence over *
D. - if left associative and - has precedence over *

5: C language has been developed by ?

A. . Dennis Ritchie
B. Peter Norton
C. Ken Thompson
D. Martin Richards

6: Smallest element of Array Index is called

A. Lower Bond
B. Upper Bond
C. Extraction
D. Rang

7: Cons feature can be applied on

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 ?

Page 1/5. Copyright 2012-2015 eduzip.com. All Rights Reserved


by eduzip.com

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.

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.

9: What are the types of linkages?

A. Internal and External


B. External and None
C. External, Internal and None
D. Internal

10: 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

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

12: By default a real number is treated as a

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-

Page 2/5. Copyright 2012-2015 eduzip.com. All Rights Reserved


by eduzip.com

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.)

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

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;

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

Explanation: - During declaration we tell the datatype of the Variable. - During definition the value is initialized.

17: When we mention the prototype of a function?

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

Page 3/5. Copyright 2012-2015 eduzip.com. All Rights Reserved


by eduzip.com

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.

24: A float is 4 bytes wide, whereas a double is 8 bytes wide.

A. True
B. False

Explanation: True, float = 4 bytes. double = 8 bytes.

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)

Page 4/5. Copyright 2012-2015 eduzip.com. All Rights Reserved


by eduzip.com

A. True
B. False

Explanation: False, The range of double is -1.7e-308 to 1.7e+308.

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.

29: Range of float id -2.25e-308 to 2.25e+308

A. True
B. False

Explanation: False, The range of float is -3.4e-38 to 3.4e+38.

Page 5/5. Copyright 2012-2015 eduzip.com. All Rights Reserved

Powered by TCPDF (www.tcpdf.org)

You might also like