Practice Question and Answer
8Q: How would you eliminate the warning generated on complaining the following program? main() { char far *scr; scr = 0xB8000000; *scr = 'A'; } 874 05b5cc7dde4d2b419777515dc
5b5cc7dde4d2b419777515dc- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
Use the typecast scr = (char far *) 0xB8000000;
Q: How would you obtain segment and offset addresses from a far address of a memory location? 2242 05b5cc7dde4d2b419777515db
5b5cc7dde4d2b419777515db- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
#include "dos.h" main() { Char far *scr = ( char far *) 0xB8000000; Char *seg, *off; Seg = (char *) FP_SEG ( scr ); Off = ( char *) FP_OFF ( scr ); }
Q: What would be the output of the following program? main() { char a[] = "Visual C++"; char *b = "Visual C++"; printf ("\n%d %d", sizeof (a), sizeof (b)); printf ("\n%d %d", sizeof (*a), sizeof (*b)); } 1553 05b5cc7dde4d2b419777515da
5b5cc7dde4d2b419777515da- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
11 2 1 1
Q: What would be the output of the following program, if the array beigns at address 65486? main() { int arr[] = {12,14,15,23,45}; printf ("%u %u", arr, &arr); } 1060 05b5cc7dde4d2b419777515d9
5b5cc7dde4d2b419777515d9- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
65486 65486
Q: What would be the output of the following program? main() { char ch ='A'; printf ("%d%d", sizeof (ch), sizeof ('A')); } 829 05b5cc7dde4d2b419777515d8
5b5cc7dde4d2b419777515d8- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
1 2
Q: How would you find the length of each string in the following Program? main() { char *str[] = { "Frogs", "Do", "Not" , "Die" , "They" , "Croak!"}; printf ("%d%d", sizeof (str), sizeof (str[0])); } 1765 05b5cc7dde4d2b419777515d7
5b5cc7dde4d2b419777515d7- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
main() { char *str[] = { "Frogs", "Do", "Not", "Die." , "They", "Croak!" }; int i; for ( i = 0;i<=5;i++) printf ("\n%s%d", str[i], strlen( str[i])); }
Q: Point out the error, ifany, in the followingb code? typedef struct { int data; NODEPTR link; } *NODEPTR; 1688 05b5cc7dde4d2b419777515d6
5b5cc7dde4d2b419777515d6- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
A typedef defines a new name for a type, and in simpler cases like the one shown below you can define a new structure type and a typedef for it at the same time. typedef struct { char name[20]; int age; } emp; However, in the structure defined in this question, there is an error because a typedef declaration cannot be used until it is defined. In the given code fragment the typedef declaration is not yet defined at he point where the link field is declared.
Q: If the following structure is written to a file using fwrite(), can fread() read it back successfully? struct emp { char *n; int age; }; struct emp e = { "Sujay",15}; FILE *fp; fwrite (&e, sizeof (e), 1, fp); 986 05b5cc7dde4d2b419777515d5
5b5cc7dde4d2b419777515d5- Show AnswerHide Answer
- Workspace
- SingleChoice
Answer :
Explanation :
No, since the structure contains a char pointer while writing the structure to the disk using fwrite() only the value stored in the pointer n would get written. When this structure is read back the address would be read back but it is quite unlikely that the desired string would be present at this address in memory

