LLucent Previous Years Solved Sample Placement Papers
-
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” Ans: d. “I am O”
-
How will you print % character?
a. printf(“\%”)
b. printf(“\%”)
c. printf(“%%”) Ans: c. printf(“%%”)
d. printf(“\%%”)
-
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 Ans: c. 4
d. none of the above
-
struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. “Your Name”
b. compile error
c. “Name”
d. Runtime error Ans: d. Runtime error
-
struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
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 Ans: d. None of the above
-
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", stract(a,b));
}
a. “Hello”
b. “Hello World”
c. “HelloWorld”
d. None of the above Ans: d. None of the above
-
main()
{
char *a = "Hello ";
char *b = "World";
printf("%s", strcpy(a,b));
}
a. “Hello”
b. “Hello World”
c. “HelloWorld”
d. None of the above Ans: d. None of the above
-
void func1(int (*a)[10])
{
printf("Ok it works");
}
void func2(int a[][10])
{
printf("Will this work?");
}
main()
{
int a[10][10];
func1(a);
func2(a);
}
a. “Ok it works”
b. “Will this work?”
c. “Ok it works Will this work?” Ans: c. “Ok it works Will this work?”
d. None of the above