Monday, June 15, 2009

My Unforgetable C-Program

int main()
{
int c=25,i=5;
do
{
c=c/i;
c=c*i;
printf("%d",c);
}
while(i--);
}

I came across this program when i was attending an aptitude test for HCL, during my college days.
And this is the program that helped me to learn about postfix and prefix.
Hope this might help some of the readers.
thanks.

7 comments:

Suresh said...

Superb perusu.. keep up ur good work

~Suresh

Lakshmanan said...

Super na!
while(i--) na
o/p
25
24
24
24
24
0

while(--i) na

25
24
24
24
24

Periasamy said...

Lakshmanan that is wrong answer da,
answer is runtime error.

Periasamy said...

if ur work out this program means clearly u will get postfix and prefix stuffs.

Unknown said...

Great Perusu !!

Anonymous said...

hi mams i am bhaskar. can u explain about prefix postfix stuff in this..
When I execute,got the Floating Point Exception!!!

Suraj Tiwari said...

Super!