C Programming - Strings - Discussion
Discussion Forum : Strings - Find Output of Program (Q.No. 12)
12.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
static char s[] = "Hello!";
printf("%d\n", *(s+strlen(s)));
return 0;
}
Discussion:
38 comments Page 4 of 4.
Shankra said:
1 decade ago
Thanks dipankar.
Prasad said:
1 decade ago
Thanks Dipankar your answer is so clear, I understood.
Nagababu said:
1 decade ago
Thank you dipankar.
Harshada said:
1 decade ago
Thank you dipankar.
Kannan said:
1 decade ago
@Dipankar explained well.
Omkar said:
1 decade ago
Thanks Dipankar for Good explanation
Sadanand said:
1 decade ago
Thanks priyanka.
Meghana said:
1 decade ago
strlen of hello! is 6. So expression in printf statement reduces to *(s+6). *(s+6) is same as s[6], which is null character. ASCII value for null character is 0. So it prints 0.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers