Post Page Advertisement [Top]

C-Programming

Write a program in c to find a binary number ?

Home /Write a program in c to find a binary number ?
Write a program in c to find a binary number ?
in C-programming

Write a program in c to find a binary number ?

steps of programming:-
01.Initialize a variable(e.g num,i,h;)
02.Again use printf() and scanf() function;
03.Now use %d for integer value(e.g "%d",&num);
04.use the for loop for find the binary number;(e.g for(i=15;i>=0;i--) );
05.Start a loop for (if,else;)
06.And again check h>>1;
07.again use((h&1));
08.In this loop first we use if statement for print a ("1");
09.In this loop second we use if statement for print a ("0");




Code:-
#include<stdio.h>
#include<conio.h>

void main()
{
int num,i,h;
clrscr();
    printf("\n enter the number:-");
scanf("%d",&num);
printf("\n enter the binary code of number:-");
    for(i=15;i>=0;i--)
{
h>>1;
if(h&1)
    printf("1");
else
   printf("0");
}
getch();
}

DizIT_Operators
Thank-You

tage:-blog.dizitoperators.com

No comments:

Post a Comment

Bottom Ad [Post Page]