प्रश्न और उत्तर का अभ्यास करें
8प्र: Can you suggest any other way of writing the following expression such that 30 is used only once? a <= 20 ? b = 30 : c = 30 ; 1165 05b5cc7dde4d2b419777515f0
5b5cc7dde4d2b419777515f0- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
*( ( a <= 20 ) ? &b : &c ) = 30;
प्र: In the following code in which order the functions would be called? a = ( f1 ( 23,14 ) * f2 ( 12/4) ) + f3() ; 782 05b5cc7dde4d2b419777515ef
5b5cc7dde4d2b419777515ef- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
The order may vary from compiler to compiler. Here the multiplication will happen before the addition , but in which order the functions would be called is undefined. In an arithmetic expression the parentheses tell the compiler which operands go with which operators but do not force the compiler to evaluate everything within the parentheses first.
प्र: What would be the output of the following program? main() { int i = -3, j =2, k =0, m ; m = ++j && ++i || ++k ; Printf ( "\n%d%d%d%d", i , j , k , m ); } 1749 05b5cc7dde4d2b419777515ee
5b5cc7dde4d2b419777515ee- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
-2 3 0 1
प्र: We want to round off x, a Float to an Int value. The correct way to do so would be 15806 05b5cc7dde4d2b419777515e9
5b5cc7dde4d2b419777515e9- 1Y = ( int ) ( x + 0.5 ) ;true
- 2Y = int ( x + 0.5) ;false
- 3Y = ( int ) x + 0.5;false
- 4Y = ( int ) ( ( int ) x + 0.5 )false
- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर : 1. "Y = ( int ) ( x + 0.5 ) ;"
व्याख्या :
Answer: A) Y = ( int ) ( x + 0.5 ) ; Explanation: Rounding off a value means replacing it by a nearest value that is approximately equal or smaller or greater to the given number. y = (int)(x + 0.5); here x is any float value. To roundoff, we have to typecast the value of x by using (int) Example: #include int main () { float x = 2.6; int y = (int)(x + 0.5); printf ("Result = %d\n", y ); return 0; } Result : 3
प्र: Which error are you likely to get when you run the following program? main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for ( i = 0 ; i <= 9; i++) scanf ( "%s %f" , e[i].name, &e[i].sal ); } 1904 05b5cc7dde4d2b419777515e8
5b5cc7dde4d2b419777515e8- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
Floating point formats not linked
प्र: What would be the output of the following program? main() { printf (" %d%d%d ", sizeof (3.14f), sizeof (3.14), sizeof (3. 141); } 1951 05b5cc7dde4d2b419777515e7
5b5cc7dde4d2b419777515e7- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
4 8 10
प्र: If the binary equivalent of 5.375 in normalised 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] ); } 1698 05b5cc7dde4d2b419777515e6
5b5cc7dde4d2b419777515e6- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
00 00 AC 40
प्र: What would be the output of the following program? main() { float a = 0.7; if ( a < 0.7f ) printf ( " C "); else Printf ( " C++ "); } 1546 05b5cc7dde4d2b419777515e5
5b5cc7dde4d2b419777515e5- उत्तर देखेंउत्तर छिपाएं
- Workspace
- SingleChoice
उत्तर :
व्याख्या :
C++

