Sail E0 Webinar

MCQs

Total Questions : 66 | Page 5 of 7 pages
Question 41.

By default a real number is treated as a


  1.    float
  2.    double
  3.    long double
  4.    far double
 Discuss Question
Answer: Option B. -> double

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 doubleto 

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.


Question 42.

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


  1.    ceil(1.66)
  2.    floor(1.66)
  3.    roundup(1.66)
  4.    roundto(1.66)
 Discuss Question
Answer: Option A. -> ceil(1.66)


#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


Question 43.

Which of the following special symbol allowed in a variable name?


  1.    * (asterisk)
  2.    | (pipeline)
  3.    - (hyphen)
  4.    _ (underscore)
 Discuss Question
Answer: Option D. -> _ (underscore)

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 


Question 44.

What are the types of linkages?


  1.    Internal and External
  2.    External, Internal and None
  3.    External and None
  4.    Internal
 Discuss Question
Answer: Option B. -> External, Internal and None

External Linkage-> means global, non-static variables and functions.

Internal Linkage-> means static variables and functions with file scope.

None Linkage-> means Local variables.


Question 45.

Is there any difference between following declarations?

1: extern int fun();

2: int fun();


  1.    Both are identical
  2.    No difference, except extern int fun(); is probably in another file
  3.    int fun(); is overrided with extern int fun();
  4.    None of these
 Discuss Question
Answer: Option B. -> No difference, except extern int fun(); is probably in another file

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.



Question 46.

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?


  1.    rem = 3.14 % 2.1;
  2.    rem = modf(3.14, 2.1);
  3.    rem = modf(3.14, 2.1);
  4.    Remainder cannot be obtain in floating point division.
 Discuss Question
Answer: Option C. -> rem = modf(3.14, 2.1);


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.


#include <stdio.h>
#include <math.h>
int main ()
{
printf ("fmod of 3.14/2.1 is %lf\n", fmod (3.14,2.1) );
return 0;
}


Output:
fmod of 3.14/2.1 is 1.040000


Question 47.


Point out the error in the following program.


#include<stdio.h>
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("Placementadda");
return 0;
}
  1.    Error: in int(*p)() = fun;
  2.    Error: fun() prototype not defined
  3.    No error
  4.    None of these
 Discuss Question
Answer: Option B. -> Error: fun() prototype not defined

The compiler will not know that the function int fun() exists. So we have to define the function prototype of int fun();
To overcome this error, see the below program



#include<stdio.h>
int fun(); /* function prototype */
int main()
{
int (*p)() = fun;
(*p)();
return 0;
}
int fun()
{
printf("placementadda");
return 0;
}


Question 48.
What will be output when you will execute following c code?
#include<stdio.h>
int main()
{
printf("%d\t", sizeof(6.5));
printf("%d\t", sizeof(90000));
printf("%d\t", sizeof('A'));
return 0;
}
  1.    4 2 1
  2.    8 2 1
  3.    4 4 1
  4.    8 4 1
  5.    8 4 2
 Discuss Question
Answer: Option E. -> 8 4 2

By default data type of numeric constants is:


6.5 :  double



90000: long int



‘A’: char



double is 8 byte



long int is 8 byte


Character constant is 2 byte


Question 49.

What would be the output of the program in 16 bit platform (Turbo C under DOS)?


#include<stdio.h>
int main()
{
extern int i;
i = 20;
printf("%d`setminus`n", sizeof(i));
return 0;
}
  1.    2
  2.    4
  3.    Would vary from compiler to compiler
  4.    Error, i undefined
 Discuss Question
Answer: Option D. -> Error, i undefined

Linker Error : Undefined symbol 'i'
The statement extern int i
specifies to the compiler that the memory for 'i'
is allocated in some other program and that address will be given to the
current program at the time of linking. But linker finds that no other
variable of name 'i' is available in any other program with memory space allocated for it. Hence a linker error has occurred.



Question 50.


By default a real number is treated as a



  1.    float
  2.    double
  3.    long double
  4.    far double
 Discuss Question
Answer: Option B. -> double


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.



Latest Videos

Latest Test Papers