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
Answers were Sorted based on User's Feedback
Answer / chandra
Answer is (c)compile error
compiler cannot initialize the string with out "". Hence any
compiler throws an error
If the string is with in "", then answer will be(a) Runtime
error.
since the string strA is used with out being initialized
Is This Answer Correct ? | 6 Yes | 0 No |
Answer / prashant
if quotes are inserted ans will be -->
d) I am O
Is This Answer Correct ? | 0 Yes | 3 No |
main() { extern out; printf("%d", out); } int out=100;
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };
Write a complete program that consists of a function that can receive two numbers from a user (M and N) as a parameter. Then print all the numbers between the two numbers including the number itself. If the value of M is smaller than N, print the numbers in ascending flow. If the value of M is bigger than N, print the numbers in descending flow. may i know how the coding look like?
main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }
main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5
main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } int i;
What are the files which are automatically opened when a C file is executed?
How can you relate the function with the structure? Explain with an appropriate example.
#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
main() { printf("%d, %d", sizeof('c'), sizeof(100)); } a. 2, 2 b. 2, 100 c. 4, 100 d. 4, 4
18 Answers HCL, IBM, Infosys, LG Soft, Satyam,
int i=10; main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); }
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }