logo

CuriousTab

CuriousTab

Discussion


Home C Programming Declarations and Initializations Comments

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


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

  • Correct Answer
  • ceil(1.66) 

    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
    

  • Declarations and Initializations problems


    Search Results


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

    • Options
    • A. Declaration
    • B. Definition
    • C. Function
    • D. Error
    • Discuss
    • 2. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1?

    • Options
    • 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.
    • Discuss
    • 3. 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;
      

    • Options
    • 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
    • Discuss
    • 4. When we mention the prototype of a function?

    • Options
    • A. Defining
    • B. Declaring
    • C. Prototyping
    • D. Calling
    • Discuss
    • 5. Is there any difference between following declarations?

      1 : extern int fun();
      2 : int fun();

    • Options
    • 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
    • Discuss
    • 6. What are the types of linkages?

    • Options
    • A. Internal and External
    • B. External, Internal and None
    • C. External and None
    • D. Internal
    • Discuss
    • 7. Identify which of the following are declarations

      1 : extern int x;
      2 : float square ( float x ) { ... }
      3 : double pow(double, double);

    • Options
    • A. 1
    • B. 2
    • C. 1 and 3
    • D. 3
    • Discuss
    • 8. By default a real number is treated as a

    • Options
    • A. float
    • B. double
    • C. long double
    • D. far double
    • Discuss
    • 9. Which of the following special symbol allowed in a variable name?

    • Options
    • A. * (asterisk)
    • B. | (pipeline)
    • C. - (hyphen)
    • D. _ (underscore)
    • Discuss
    • 10. Which of the following is the correct order if calling functions in the below code?
      a = f1(23, 14) * f2(12/4) + f3();

    • Options
    • A. f1, f2, f3
    • B. f3, f2, f1
    • C. Order may vary from compiler to compiler
    • D. None of above
    • Discuss


    Comments

    Avatar
    pharmacy drugstore online pharmacy
    pharmacy drugstore onlinepharmacy evaluating exam canada


Enter a new Comment