What is wrong with the following code?
int *foo()
{
int *s = malloc(sizeof(int)100);
assert(s != NULL);
return s;
}
Answer / susie
Answer : & Explanation:
assert macro should be used for debugging and finding out
bugs. The check s != NULL is for error/exception handling
and for that assert shouldn’t be used. A plain if and the
corresponding remedy statement has to be given.
| Is This Answer Correct ? | 0 Yes | 2 No |
What is the main difference between STRUCTURE and UNION?
main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above
main() { int x=5; for(;x!=0;x--) { printf("x=%d\n", x--); } } a. 5, 4, 3, 2,1 b. 4, 3, 2, 1, 0 c. 5, 3, 1 d. none of the above
write a program for area of circumference of shapes
main() { static int var = 5; printf("%d ",var--); if(var) main(); }
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
Is this code legal? int *ptr; ptr = (int *) 0x400;
void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }
main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }
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)); }
why nlogn is the lower limit of any sort algorithm?
How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!