id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

norm.krumpe@muohio.edu lab8warmup > count3
prev  |  next  |  chance

Given a non-negative integer, count how many of its digits are 3. Here are some suggestions for this and several other problems where you have to process all the digits of a number. Suggestion #1: You can look at the last digit of a number using num % 10 Suggestion #2: You can cut off the last digit of a number by assigning num = num / 10 Suggestion #3: As long as num is still positive, you know there are still digits left in it that need to be processed.


count3(73) → 1
count3(3534) → 2
count3(8) → 0

...Save, Compile, Run (ctrl-enter)

int count3(int num) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy