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 |
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What are the uses of a pointer?
Explain the use of function toupper() with and example code?
what is the code to display color fonts in the output?
Write a program to find given number is even or odd without using any control statement.
Explain how do you list files in a directory?
What is the result main() { char c=-64; int i=-32 unsigned int u =-16; if(c>i){ printf("pass1,"); if(c<u) printf("pass2"); else printf("Fail2");} else printf("Fail1); if(i<u) printf("pass2"); else printf("Fail2") } a)Pass1,Pass2 b)Pass1,Fail2 c)Fail1,Pass2 d)Fail1,Fail2 e)none
the constant value in the case label is followed by a a) semicolon b) colon c) braces d) none of the above
please give me some tips for the selection in TCS.
What is the use of clrscr?
which operator having lowest precedence?? a.)+ b.)++ c.)= d.)%
Differentiate between null and void pointers.