We were required to write a program to check whether the
given number was of the form 3^n. ( i.e. 3 to the power n).
I knew that it can be done by bit manipulation but couldn't
make out the logic.
i want a solution in C/C++ language
Answer / sreejesh1987
#include<stdio.h>
#include<conio.h>
void main()
{
int count=0,n,d;
clrscr();
printf("\tDigit 3powern\n");
printf("Enter a no:");
scanf("%d",&n);
d=n;
while(d%3==0)
{
d=d/3;
count++;
}
if(d==1)
printf("\nNumber %d is of 3^%d format",n,count);
else
printf("\nNumber %d is not in 3^n format",n);
getch();
}
| Is This Answer Correct ? | 17 Yes | 6 No |
a person who decided to go weekend trip should not exceed 8 hours driving in a day average speed of forward journey is 40 mph.due to traffic in sun days the return journey average speed is 30 mph.how far he can select a picnic spot.
1,2,3,4,5,6,7,8,9 station. route between any 2 station is there only if the 2 digit nob. is divisible by 3. e.g. route exist between 1 to 2 because 12 is divisible by 3 how many station have routes to 8 either direct or indirect
how can i get answers of all question.
0 Answers State Bank Of India SBI,
How much area in sqmt of 14 fit dia cirlce???
Ramesh working alone on a job takes 12 days more than what he would have taken if Suresh had worked along with him while Suresh working alone on the same job takes 27 days more than what he would have taken if Ramesh had worked along with him. Find the time that both of them would take together to do the job.
If 5+3+2=151012, 5+4+5=202504, 7+2+5=143542 then 8+6+2= ?
21 Answers DRDO, Facebook, Infosys, intract-crm, Mavensoft, Wipro,
how many numbers upto 2oo which are divisible by 2 11 ?
Four Members A, B, C, D are playing a game .A person losing a game should double the amount of others .B, C, D are losing in order after three games .The amount after 3 games are A&B having 40,D is having 16&C 80.What amount did B have?
If two cards are taken one after another without replacing from a pack of 52 cards what is the probability for the two cards be queen.
1. 10 men and 10 women are there, they dance with each other, is there possibility that 2 men are dancing with same women and vice versa? a) 22 b) 20 c) 10 d) none
3 red and 4 blue balls are in a basket. A member of PPTeam is drawing balls from the basket.What is the probablity of getting the 3 red balls simultaneously?
find missing no 5 12 23 30 17 8 ? 3