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
Which header file is used for clrscr?
How does normalization of huge pointer works?
What is a loop?
What is output redirection?
Explain heap and queue.
What is pointer & why it is used?
What is null in c?
write a program to print the consecutive repeated character from the given string... input string is : hhhhjkutskkkkkggggj output should be like this: hhhhkkkkkgggg anyone help me...
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What is function what are the types of function?
What are pointers in C? Give an example where to illustrate their significance.
int i[2], j; int *pi;i[0] = 1; i[1] = 5; pi = i; j = *pi + 1 + *(pi + 1)Value of j after execution of the above statements will be a) 7 b) 6 c) 4 d) pointer
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Why do we use pointer to pointer in c?