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

This is on letter series like if DEFGHI: ABCDEF then NOPQRS:_______

11 Answers   EA Electronic Arts, TS,


3, 5, 8, 13, 24, 39, 72 FIND THE WRONG NUMBER

14 Answers   pusa cet, SSSB,


Find the hypotaneous of a right angle isosceles triangle whose area is 50.

0 Answers   COSL,


If in a certain code 'RANGE' is coded as 12345 and 'RANDOM' is coded as 123678, then the code for the word 'MANGO' would be

12 Answers   Cli3l, Infosys, Wipro,


One year payment to the servant is Rs. 200 plus one shirt. The servant leaves after 9 months and receives Rs. 120 and a shirt.Then find the price of the shirt.

0 Answers   Accenture,


If Log2 x - 5 Log x + 6 = 0, then what would the value / values of x be?

0 Answers   iNautix, Wipro,


I am preparing for APSRTC Officers under training,i would like to know the syllabus for this post's written test also Suggest me the reference books for Managerial Aptitude, General Knowledge, General English. Kindly send reply to my mail id pulijalasrikanth@gmail.com

2 Answers   APSRTC,


Sister's age is twice than that of the brother. If the brother's age is six, what is the sister's age after two years?

0 Answers   BPCL Bharat Petroleum, Sonata,


there are 76 persons. 53 can read hindu,46 can read times,39 can read deccan and 15 can read all.if 22 can read hindu and deccan and 23 can read deccan and times then what is the number of persons who read only times and hindu………

0 Answers   Accenture,


The following question asked at Infosys campus recruitment held at Pragathi. If 1>= y > x and xy=z.which of the following is not true? i)z>0 ii)x=z iii)y=z iv)z>y

3 Answers   Infosys, Wipro,


if a=2, b=3, c=6 Find the value of c/(a+b)-(a+b)/c

0 Answers   Accenture, HCL,


a vendor solds two things at same cost 12 RS with one item at 25%profit and other at 20%loss,by this transaction he made profit or loss by how much

0 Answers   Infosys,


Categories