Data Types
- Which error are you likely to get when you run the following program in TC/TC++?
#include <stdio.h>
int main ( )
{
struct emp
{
char name[20];
float sal;
};
struct emp e[10];
int i ;
for (i = 0; i <= 9; i++)
{
printf ("Enter name and salary : ");
scanf ("%s %f" , e[ i ].name, &e[ i ].sal);
}
return 0 ;
}
-
View Hint View Answer Discuss in Forum
Floating point formats not linked
Just add the following function in your program. It will force the compiler to include required libraries for handling floating point linkages.static void force_fpf() /* A dummy function */
{
float x, *y; /* Just declares two variables */
y = &x; /* Forces linkage of FP formats */
x = *y; /* Suppress warning message about x */
}Correct Option: B
Floating point formats not linked
Just add the following function in your program. It will force the compiler to include required libraries for handling floating point linkages.static void force_fpf() /* A dummy function */
{
float x, *y; /* Just declares two variables */
y = &x; /* Forces linkage of FP formats */
x = *y; /* Suppress warning message about x */
}
- If the binary equivalent of 5.375 in normalized form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the following program?
#include <stdio.h>
int main ( )
{
float a =5.375 ;
char *p ;
int i ;
p = (char *) &a ;
for (i = 0 ; i <= 3 ; i++)
printf("%02 X \n" , (unsigned char) p[ i ]);
return 0 ;
}
-
View Hint View Answer Discuss in Forum
Binary equivalent of 5.375 in normalized form is
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
Since the PC's (Intel processors) use " LITTLE ENDIAN" byte order, the higher order byte of number is stored in lowest address. The result is written from bottom to top.Correct Option: C
Binary equivalent of 5.375 in normalized form is
0100 -> 4
0000 -> 0
1010 -> A
1100 -> C
0000 -> 0
0000 -> 0
0000 -> 0
0000 -> 0
Since the PC's (Intel processors) use " LITTLE ENDIAN" byte order, the higher order byte of number is stored in lowest address. The result is written from bottom to top.