Answer Posted / a.balraj
void main()
{
int i,n,p=0,temp,z;
int a[3];
clrscr();
printf("Enter the value of n:\n");
scanf("%d",&n);
i=n;
while(i!=1)
{
if(n%2==0)
{
temp=n%2;
}
else
{
temp=n%2;
}
a[p]=temp;
n=n/2;
i=n+2;
i--;
p++;
}
for(z=sizeof(a)/sizeof(int);z>=0;z--)
{
printf("%d",a[z]);
}
getch();
}
| Is This Answer Correct ? | 2 Yes | 4 No |
Post New Answer View All Answers
What is difference between far and near pointers?
How can I do graphics in c?
Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.
What is scope of variable in c?
When should a far pointer be used?
What standard functions are available to manipulate strings?
Can we access array using pointer in c language?
Is main a keyword in c?
What is assignment operator?
int i=10; printf("%d %d %d", i, i=20, i);
What is strcmp in c?
What is a constant and types of constants in c?
explain what is an endless loop?
How many bytes are occupied by near, far and huge pointers (dos)?
Which one would you prefer - a macro or a function?