chandrasekharsahoo


{ City } bangalore
< Country > india
* Profession * student
User No # 121127
Total Questions Posted # 0
Total Answers Posted # 2

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 19
Users Marked my Answers as Wrong # 3
Questions / { chandrasekharsahoo }
Questions Answers Category Views Company eMail




Answers / { chandrasekharsahoo }

Question { 21763 }

main()

{

extern int i;

i=20;

printf("%d",sizeof(i));

}


Answer

This program throws error in compilation. Because variable i is declared but not defined anywhere. Essentially, the variable isn’t allocated any memory. And the program is trying to change the value to 20 of a variable that doesn’t exist at all.

Is This Answer Correct ?    4 Yes 3 No

Question { Vector, 9461 }

main()
{
FILE *fs;
char c[10];
fs = fopen(“source.txt”, ”r”); /* source.txt exists and
contains “Vector Institute” */
fseek(fs,0,SEEK_END);
fseek(fs,-3L,SEEK_CUR);
fgets(c,5,fs);
puts(c);
}


Answer

it prints ute.
SEEK_END moves the pointer to end of the file.
SEEK_CUR moves the pointer 3 places back(-3L). Nw the pointer is at u.
gets() tries to fetch 5 characters from the present position of pointer but can fetch only 3 characters as it reaches end of file.
puts() prints the characters i.e. ute.

Is This Answer Correct ?    15 Yes 0 No