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 / shruti
syntax error during compilation..
we cannot compare strings using if(p == "string")
so will not work..
NOTE:
while comparing string otherwise also we use 'string'
(string in single quotes ' ' not " ")..
Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
provide an example of the Group by clause, when would you use this clause
What is header file definition?
Explain what is the most efficient way to store flag values?
Can you add pointers together? Why would you?
How to write a code for reverse of string without using string functions?
Can we declare a function inside a function in c?
What does the characters “r” and “w” mean when writing programs that will make use of files?
What does the c in ctime mean?
Describe newline escape sequence with a sample program?
What is the c language function prototype?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.
What happens if you free a pointer twice?
What is a keyword?
Can you please explain the scope of static variables?