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
d) Fail 1, Pass 2
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
Are pointers integers in c?
Which control loop is recommended if you have to execute set of statements for fixed number of times?
How can I run c program?
What is the default value of local and global variables in c?
How many header files are in c?
How will you write a code for accessing the length of an array without assigning it to another variable?
How can you avoid including a header more than once?
How can I list all of the predefined identifiers?
Why c language is called c?
What is bin sh c?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
I have seen function declarations that look like this
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What is the size of enum in bytes?