i am having problem in executing the following program.........when i execute it,it's getting hanged....pls gimme a gud solution

#include<stdio.h>
main()
{
int n,x=0,y=1,z;
printf("\nEnter a number of your choice:");
scanf("%d",&n);
z=n;
do
{
x=n%8;
x=x+x*y;
y=y*10;
z=z/8;
}while(z<8);
printf("\nThe octal equivalent of the number entered is %d",x);
}

does it show any output? Check the z variable on the while loop, no manipulation on it. Could make the loop infinite...

is dere anything wronng wid my coding logic???????dis is a prog for converting a decimal to octal number.....

I meant to ask, does it execute the while loop? if so for how long?
When you say it hangs, do you mean it doesn't show anything or what?

Check the other thread. And mark this thread as solved. Both have the same question.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.