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
Explain what is page thrashing?
What is malloc() function?
What is meant by high-order and low-order bytes?
How can a string be converted to a number?
When do we get logical errors?
Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer
Why shouldn’t I start variable names with underscores?
in iso what are the common technological language?
code for find determinent of amatrix
What is maximum size of array in c?
What is the use of getch ()?
can we have joblib in a proc ?
What is the use of typedef in c?
I have a varargs function which accepts a float parameter?
Write a program to print ASCII code for a given digit.