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 |
convert 12345 to 54321 withoutusing strig
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
Why does the call char scanf work?
macros and function are related in what aspect? a)recursion b)varying no of arguments c)hypochecking d)type declaration
12 Answers HCL, Infosys, Microsoft,
main() { int i = -3,j=2,k=0,m; m= ++i || ++j && ++k; printf("%d%d%d",i,j,k,m); }
Method Overloading exist in c ?
main() { int i,j,A; for(A=-1;A<=1;A++) prinf("%d\t",!!A); }
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
Explain what is the difference between functions abs() and fabs()?
Which is best linux os?
What does return 1 means in c?