Write a C program to convert an integer into a binary
string?
Answer / vadivelt
#include<stdio.h>
char *IntToBinString(int no);
main()
{
int no;
printf("ENTER THE NO: ");
scanf("%d",&no);
printf("\nBINARY O/P STRING:\n%s",IntToBinString(no));
getch();
}
char *IntToBinString(int no)
{
char *ptr;
int i, size;
size = sizeof(int)*8;
ptr = (char *)malloc(sizeof(int)*8);
for(i = size - 1; i >= 0; i--)
{
if(no >> i & 0x01)
{
*ptr++ = 49;
}
else
{
*ptr++ = 48;
}
}
*ptr = '\0';
return (ptr - size);
}
| Is This Answer Correct ? | 9 Yes | 3 No |
What is a macro, and explain how do you use it?
in C-programming language without using printf statement can we get output r not ? if yes how and if no also how ?
What is self-referential structure in c programming?
without using arithmatic operator solve which number is greater??????????
wht is the difference between KPO and BPO ?
2 Answers Accenture, BPO, HCK, HCL, Infosys,
what is reason of your company position's in india no. 1.
When should the volatile modifier be used?
What is the use of the #include directive?
What is the size of array float a(10)?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
is compiler do read the data line by line or not. ??
6 Answers LG Soft, Satyam, Tech Mahindra,
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list