C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 21)
21.
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
int main()
{
int i, n;
char *x="Alice";
n = strlen(x);
*x = x[n];
for(i=0; i<=n; i++)
{
printf("%s ", x);
x++;
}
printf("\n", x);
return 0;
}
Answer: Option
Explanation:
If you compile and execute this program in windows platform with Turbo C, it will give "lice ice ce e".
It may give different output in other platforms (depends upon compiler and machine). The online C compiler given in this site will give the Option C as output (it runs on Linux platform).
Discussion:
59 comments Page 6 of 6.
Sahitya said:
8 years ago
I executed this and I got option c.
Kittu said:
1 decade ago
How option d can any one explain?.
Nadeem said:
1 decade ago
In gcc giving segmentation fault.
Jakir said:
1 decade ago
Its giving segmentation fault.
Sandhya said:
9 years ago
Guys tell me in a simple way.
Aparna said:
2 decades ago
Can you please explain this ?
Sagar said:
9 years ago
Thanks for the explanation.
Aishwarya said:
1 decade ago
Can anyone explain this?
Frank said:
2 decades ago
Please explain.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers