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

writte a c-programm to display smill paces

2 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  


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


How we will connect multiple client ? (without using fork,thread)

3 Answers   TelDNA,


You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.

3 Answers  






Program to find the largest sum of contiguous integers in the array. O(n)

11 Answers  


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }

1 Answers  


Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }

6 Answers  


#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }

3 Answers  


main() { int i=5; printf(“%d”,i=++i ==6); }

1 Answers  


int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  


Categories