//without using functions.
#include <stdio.h>
#include <conio.h>
int main()
{
int num, rem, flag=0;
printf ("\n Enter a Number: ");
scanf ("%d", &num);
while(num > 2)
{
rem = num % 2;
if( rem == 1 )
{
flag = 1;
break;
}
else
num = num/2;
}
if( flag == 1 )
{
printf("\n Number is not Power of two.");
}
else
{
printf("\n Number is Power of two");
}
}
#include <stdio.h>
#include <conio.h>
int main()
{
int num, rem, flag=0;
printf ("\n Enter a Number: ");
scanf ("%d", &num);
while(num > 2)
{
rem = num % 2;
if( rem == 1 )
{
flag = 1;
break;
}
else
num = num/2;
}
if( flag == 1 )
{
printf("\n Number is not Power of two.");
}
else
{
printf("\n Number is Power of two");
}
}
No comments:
Post a Comment