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

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

1 Answers  


what is the output of following program ? void main() { int i=5; printf("%d %d %d %d %d ",i++,i--,++i,--i,i); }

10 Answers  


what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }

6 Answers   CSC, IIIT,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,






Give a oneline C expression to test whether a number is a power of 2?

25 Answers   EA Electronic Arts, Google, Motorola,


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

3 Answers  


what is oop?

3 Answers  


how to return a multiple value from a function?

2 Answers   Wipro,


Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal.

6 Answers   Fusion Systems GmbH,


Is the following statement a declaration/definition. Find what does it mean? int (*x)[10];

1 Answers  


int a = 10 + 10 .... ,... A = A * A What would be the value of A? The answer is 120!! Could anyone explain this to me.

2 Answers   Bosch, eInfochips, HCL, IHCL,


Categories