logo

CuriousTab

CuriousTab

Discussion


Home C Programming Declarations and Initializations See What Others Are Saying!
  • 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
    

  • More questions

    • 1. What will be the output of the program?
      #include<stdio.h>
      int fun(int(*)());
      
      int main()
      {
          fun(main);
          printf("Hi\n");
          return 0;
      }
      int fun(int (*p)())
      {
          printf("Hello ");
          return 0;
      }
      

    • Options
    • A. Infinite loop
    • B. Hi
    • C. Hello Hi
    • D. Error
    • Discuss
    • 2. Point out the error, if any in the while loop.
      #include<stdio.h>
      int main()
      {
          int i=1;
          while()
          {
              printf("%d\n", i++);
              if(i>10)
                 break;
          }
          return 0;
      }
      

    • Options
    • A. There should be a condition in the while loop
    • B. There should be at least a semicolon in the while
    • C. The while loop should be replaced with for loop.
    • D. No error
    • Discuss
    • 3. What will be the output of the program in Turbo C?
      #include<stdio.h>
      
      int main()
      {
          char str[10] = "India";
          str[6] = "CURIOUSTAB";
          printf("%s\n", str);
          return 0;
      }
      

    • Options
    • A. India CURIOUSTAB
    • B. CURIOUSTAB
    • C. India
    • D. Error
    • Discuss
    • 4. Bitwise | can be used to multiply a number by powers of 2.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 5. By default a real number is treated as a

    • Options
    • A. float
    • B. double
    • C. long double
    • D. far double
    • Discuss
    • 6. 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
    • 7. The library function used to find the last occurrence of a character in a string is

    • Options
    • A. strnstr()
    • B. laststr()
    • C. strrchr()
    • D. strstr()
    • Discuss
    • 8. Point out the error in the following program.
      #include<stdio.h>
      #include<stdarg.h>
      fun(...);
      
      int main()
      {
          fun(3, 7, -11.2, 0.66);
          return 0;
      }
      fun(...)
      {
          va_list ptr;
          int num;
          va_start(ptr, n);
          num = va_arg(ptr, int);
          printf("%d", num);
      }
      

    • Options
    • A. Error: fun() needs return type
    • B. Error: ptr Lvalue required
    • C. Error: Invalid declaration of fun(...)
    • D. No error
    • Discuss
    • 9. Which of the following function sets first n characters of a string to a given character?

    • Options
    • A. strinit()
    • B. strnset()
    • C. strset()
    • D. strcset()
    • Discuss
    • 10. If the two strings are identical, then strcmp() function returns

    • Options
    • A. -1
    • B. 1
    • C. 0
    • D. Yes
    • Discuss


    Comments

    There are no comments.

Enter a new Comment