logo

CuriousTab

CuriousTab

Discussion


Home Technical Questions Programming Comments

  • Question
  • What would be the output of the following program? main() { extern int fun ( float ); int a; a = fun ( 3. 14 ); printf ("%d", a); } int fun ( aa ) float aa ; { return ( (int) aa ); }


  • Correct Answer
  • Error occurs because we have mixed the ANSI prototype with K & R style of function definition When we use ANSI prototype for a function and pass a float to the function it is promoted to a double When the function accepts this double into a float a type mismatch occurs hence the error The remedy for this error could be to define the function as : int fun (float aa) { } 


  • Programming problems


    Search Results


    • 1. What will be output when you will execute following c code? #include void main() { signed int a = -1; unsigned int b = -1u; if(a == b) printf( "The Lord of the Rings" ); else printf( "American Beauty" ); }

    • Options
    • A. The Lord of the Rings
    • B. American Beauty
    • C. Compilation error: Cannot compare signed number with unsigned number
    • D. Warning: Illegal operation
    • Discuss
    • 2. enum colors {BLACK,BLUE,GREEN} main() { printf( "%d..%d..%d", BLACK, BLUE, GREEN ); return(1); }

    • Options
    • A. 1..2..3
    • B. 0..1..2
    • C. 1..1..1
    • D. 0..0..0
    • Discuss
    • 3. If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000 0000, what would be the output of the following program?
      main()
      
      {
      
          float a = 5.375 ;
      
          char *p;
      
          int i;
      
          p = ( char* ) &a ;
      
          for ( i = 0; i <= 3 ; i++ )
      
                printf ( " %02x ", (unsigned char ) p[i] );
      
      }
    • Discuss
    • 4. public static void main string[] args Meaning is?
    • Discuss
    • 5. The coding or scrambling of data so that humans cannot read them, is known as _____.

    • Options
    • A. Compression
    • B. Encryption
    • C. Ergonomics
    • D. Biometrics
    • Discuss
    • 6. In programming, repeating some statements is usually called ?

    • Options
    • A. Running
    • B. Structure
    • C. Looping
    • D. Control structure
    • Discuss
    • 7. What will be output when you will execute following c code? #include void main() { int const SIZE = 5; int expr; double value[SIZE] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; expr=1|2|3|4; printf ( "%f", value[expr] ); }

    • Options
    • A. 2.000000
    • B. 4.000000
    • C. 8.000000
    • D. Compilation error
    • Discuss
    • 8. A function cannot be defined inside another function

    • Options
    • A. TRUE
    • B. FALSE
    • Discuss
    • 9. What will be output of the following c program ? #include int main() { int max-val=100; int min-val=10; int avg-val; avg-val =( max-val + min-val ) / 2; printf( "%d", avg-val ); return 0; }

    • Options
    • A. 55
    • B. 105
    • C. 60
    • D. Compilation error
    • Discuss
    • 10. SNOBOL is mainly used for

    • Options
    • A. Text Operation
    • B. String operations
    • C. List operations
    • D. Numerical operations
    • Discuss


    Comments

    There are no comments.

Enter a new Comment