Showing posts with label number. Show all posts
Showing posts with label number. Show all posts

Saturday, February 14, 2015

C program to convert given binary number into decimal number


C program to convert given binary number into decimal number

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
long int i,n,x=0,a;
clrscr();
printf("Enter any Binary number: ");
scanf("%ld",&n);
printf("
The Decimal conversion of %ld is ",n);


for(i=0;n!=0;++i)
{
a=n%10;
x=(a)*(pow(2,i))+x;
n=n/10;
}

printf("%ld",x);
getch();
}
Read more »

Wednesday, February 11, 2015

C Program to check whether a number is odd or even

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
int a;
cout<<"enter the number:";
cin>>a;

if(a%2==0)
cout<<"
Even number";

else
cout<<"
Odd number";

getch();
}
Read more »