struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above
Answers were Sorted based on User's Feedback
Answer / guest
d) printd Nothing, as after free(obj), no memory is there
containing
obj->pName & pbj->pAddress
Is This Answer Correct ? | 6 Yes | 1 No |
Answer / sankara subramanian.n
ya, free(ob); mean free(delete) a previous block of memory .so structure contained item has been deleted
Is This Answer Correct ? | 1 Yes | 2 No |
main() { printf("\nab"); printf("\bsi"); printf("\rha"); }
main() { main(); }
const int perplexed = 2; #define perplexed 3 main() { #ifdef perplexed #undef perplexed #define perplexed 4 #endif printf("%d",perplexed); } a. 0 b. 2 c. 4 d. none of the above
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().
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
main() { float f=5,g=10; enum{i=10,j=20,k=50}; printf("%d\n",++k); printf("%f\n",f<<2); printf("%lf\n",f%g); printf("%lf\n",fmod(f,g)); }
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };
/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }
#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }
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.
why java is platform independent?
#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }