Which one is taking more time and why ?


:/home/amaresh/Testing# cat time.c
//#include <stdio.h>
#define EOF -1
int main()
{
register int c;
while ((c = getchar()) != EOF)
{
putchar(c);
} return 0;
} -------------------
WIth stdio.h:-
:/home/amaresh/Testing# time ./time_header hi hi hru? hru?

real 0 m4.202s
user 0 m0.000s
sys 0 m0.004s ------------------
Witout stdio.h and with #define EOF -1 ===================
/home/amaresh/Testing# time ./time_EOF hi hi hru? hru?

real 0 m4.805s
user 0 m0.004s
sys 0 m0.004s

-- From above two case , why 2nd case is taking more time ?


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More C Code Interview Questions

main() { extern int i; i=20; printf("%d",sizeof(i)); }

2 Answers  


Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


main() { int i=5; printf("%d",++i++); }

1 Answers  


Under linux environment can u please provide a c code for computing sum of series 1-2+3-4+5......n terms and -1+2-3+4-5...n terms..

2 Answers  


Develop a routine to reflect an object about an arbitrarily selected plane

0 Answers  






int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,


union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0

1 Answers   HCL,


main() { unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


Categories