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 ?
Who could write how to find a prime number in dynamic array?
Write a C function to search a number in the given list of numbers. donot use printf and scanf
main() { int i=400,j=300; printf("%d..%d"); }
What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }
# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }
Is the following code legal? typedef struct a { int x; aType *b; }aType
How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.
main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O
Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }
why do you use macros? Explain a situation where you had to incorporate macros in your proc report? use a simple instream data example with code ?
How do you verify if the two sentences/phrases input is an anagram using predefined functions in string.h and by using arrays?