What will be the result of the following program?
main()
{
char p[]="String";
int x=0;
if(p=="String")
{
printf("Pass 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
else
{
printf("Fail 1");
if(p[sizeof(p)-2]=='g')
printf("Pass 2");
else
printf("Fail 2");
}
}
a) Pass 1, Pass 2
b) Fail 1, Fail 2
c) Pass 1, Fail 2
d) Fail 1, Pass 2
e) syntax error during compilation
Answer Posted / guest
a) Pass 1, Pass 2
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Which built-in library function can be used to match a patter from the string?
Explain how do you determine whether to use a stream function or a low-level function?
How can you avoid including a header more than once?
Explain the difference between strcpy() and memcpy() function?
What is use of #include in c?
Explain what is the benefit of using enum to declare a constant?
Multiply an Integer Number by 2 Without Using Multiplication Operator
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
can we implement multi-threads in c.
What is spaghetti programming?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
When is a “switch” statement preferable over an “if” statement?
Is it better to use malloc() or calloc()?
When should you use a type cast?
Why doesnt the call scanf work?