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
what do u mean by Direct access files? then can u explain about Direct Access Files?
Why cant I open a file by its explicit path?
What is echo in c programming?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What are the differences between Structures and Arrays?
What are the benefits of organizational structure?
Why main function is special give two reasons?
Explain what does the function toupper() do?
What is the advantage of using #define to declare a constant?
Is c easier than java?
Who is the founder of c language?
my project name is adulteration of chille powder.how can i explain it to the hr when he asks me about the project?
Can i use “int” data type to store the value 32768? Why?
Explain the difference between malloc() and calloc() function?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)