Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



We were required to write a program to check whether the given number was of the form 3^n. ( i.e. 3..

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

Post New Answer

More General Aptitude Interview Questions

Area if square increase by 69% find sides % increased by?

3 Answers   3D PLM,


a man sells an article at a profit of 20%. if he had bought it for 20% less but sells at the same price, find the gain %.

2 Answers   Quatrro, Student,


"what category of job are you looking for and why"asked from an mep engineer.

0 Answers   Grocon Construction Australia,


From 7:00 AM to 11:00 AM it rained 2.25 inches. At 11:00 AM the rain increased to fall at a rate of 1.25 in. every two hours. How many inches of rain landed on the ground by 5:00 PM?

9 Answers   Accenture, Patni, TCS,


There are 19 red balls and one black ball . Ten balls are put in one jar and the remaining 10 are put in another jar. what is the possibility that the black in the right jar.

0 Answers   Infosys,


There are some houses in a street back to back. And they that house behind 10 were 23. How many houses in the street?

0 Answers   Accenture,


My flight takes of at 2am from a place at 18N 10E and landed 10 Hrs later at a place with coordinates 36N70W. What is the local time when my plane landed. a) 6:00 am b) 6:40am c)7:40 d)7:00 e)8:00

2 Answers   TCS,


Two trains starting at same time, one from Bangalore to Mysore and other in opposite direction arrive at their destination 1 hr and 4 hours respectively after passing each other.How nuch faster is one train from other?

5 Answers   Caritor, Infosys, L&T,


7. A new medicine has been developed and its effectiveness has been determined by carrying out an experimental study. 30 patients were divided into groups of 20 and 10. The group having 20, were given medicine while the other group dint get any medication. The results obtained where as follows:- Medication Non-medication Improved 8 2 Unimproved 12 8 Based on data, I think medication was:-

2 Answers  


Four of the following five are alike in a certain way and so form a group. Which is the one that does not belong to that group? (a) 17 (b) 23 (c) 37 (d) 13 (e) 73

7 Answers  


ques-Input an array and prints the second minimum in an array?? Example Input:34,45,21,12,54,67,15 Output:15 I want a solution in C/C++ language

2 Answers   Nagarro,


if the value of nomo is 2,chotr is 4,meraca is 3 and wats the value of nuslasgses

5 Answers   Genpact,


Categories