GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Aditi Technologies
Next Question 
 Aditi Technologies  |  Question 1 of 2    Print  
how many times 3 occurs between 3 to 3333

  
Total Answers and Comments: 8 Last Update: June 13, 2007     Asked by: vijay 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: vijay
 

main() {
int i=3,temp=0,d,c=0;
for(;i<=3333;++i)
{
 temp=i;
 while(temp!=0)
 {
  d=temp%10;
  if(d==3)
   c++;
  temp=temp/10;
 }

}
printf("%d",c); }



ans: 1336 times



Above answer was rated as good by the following members:
shiv.bhaker
January 04, 2006 12:02:17   #1  
hari        

RE: how many times 3 occurs between 3 to 3333
It comes 998 times.
 
Is this answer useful? Yes | No
January 15, 2006 12:39:08   #2  
Moumita        

RE: how many times 3 occurs between 3 to 3333

I am very sorry to say that you should give the trick inspite of giving the answer only.It will help us more.


 
Is this answer useful? Yes | No
April 18, 2006 08:42:21   #3  
muthuishere Member Since: April 2006   Contribution: 1    

RE: how many times 3 occurs between 3 to 3333

Probably it may be 5 times in 3 2 3333


 
Is this answer useful? Yes | No
May 30, 2006 09:56:09   #4  
SHAILESH        

RE: how many times 3 occurs between 3 to 3333
how many times 3 occurs between 3 to 3333
 
Is this answer useful? Yes | No
June 23, 2006 10:00:00   #5  
ashish sinha        

RE: how many times 3 occurs between 3 to 3333

The number 3 never appears between 3 to 3333. The digit 3 does appear many times ... probably 998 times (or something like that as the person above has mentioned). So the answer is 0.


 
Is this answer useful? Yes | No
October 27, 2006 07:53:36   #6  
siva        

RE: how many times 3 occurs between 3 to 3333
Hi guys I have written a code (in perl) to find it out.. what it does is it takes the numbers from 3 to 3333 divide each number into digits and checks whether it's 3 or not.. and increments the count..The answer I found out is 1336.my($i $dig $tmp);my($count) 0;for($i 3;$i< 3333;$i++){$tmp $i;while($tmp! 0){$dig $tmp 10;$tmp $tmp/10;if($dig 3){$count++;}}}print $countn ;
 
Is this answer useful? Yes | No
April 20, 2007 15:33:19   #7  
ghasagar Member Since: April 2007   Contribution: 3    

RE: how many times 3 occurs between 3 to 3333

see if this perl snippet works for you..

print "how many times 3 occurs between 3 to 3333?n answer:n";

my @nums (3..3333);
foreach (@nums) {
my @tmp_counter ($_ ~ m/3/g);
$final_count + eval($#tmp_counter+1);
}
print "final : $final_count n";

output :
how many times 3 occurs between 3 to 3333?
answer:
final : 1336

sagar


 
Is this answer useful? Yes | No
June 13, 2007 03:33:40   #8  
vijay        

RE: how many times 3 occurs between 3 to 3333

main() {
int i 3 temp 0 d c 0;
for(;i< 3333;++i)
{
temp i;
while(temp! 0)
{
d temp 10;
if(d 3)
c++;
temp temp/10;
}

}
printf(" d" c); }



ans: 1336 times


 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
Related Categories
Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape