Counting occurrence of numbers in C

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2005
Posts: 6
Reputation: stabule is an unknown quantity at this point 
Solved Threads: 0
stabule stabule is offline Offline
Newbie Poster

Counting occurrence of numbers in C

 
0
  #1
Nov 13th, 2005
Hi all.

I need help creating a prog. in C that can count the occurrence of numbers. The prog. should go like this:

Enter input 1 = 223335
Enter input 2 = 2

Output = The number 2 appears twice in "223335".

The first input can be any 6 numbers and the second input should only be 1 number.

Could someone help me out?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Counting occurrence of numbers in C

 
0
  #2
Nov 13th, 2005
You can take a char array and store the number in it and then take another character variable to hold the number for which u want to find the occurence.
Then take a for loop and compare the entered character with each element of char array
.....and count the total occurence in that for loop
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 6
Reputation: stabule is an unknown quantity at this point 
Solved Threads: 0
stabule stabule is offline Offline
Newbie Poster

Re: Counting occurrence of numbers in C

 
0
  #3
Nov 13th, 2005
I'm still a beginner, don't really know how to write the coding. Could you help me out?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: Counting occurrence of numbers in C

 
0
  #4
Nov 13th, 2005
Originally Posted by stabule
I'm still a beginner, don't really know how to write the coding. Could you help me out?
In that case you need study your books first and then post in forums(if you are stuck somewhere)....see the rules....i could have posted the code for you but that would not help you much....show some effort.....
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 6
Reputation: stabule is an unknown quantity at this point 
Solved Threads: 0
stabule stabule is offline Offline
Newbie Poster

Re: Counting occurrence of numbers in C

 
0
  #5
Nov 13th, 2005
I've been working on this for 2 weeks and have done my share of studying. The reason I'm posting here is because I really need help. I understand the logic and the sequence in which it must be written in, but I'm really stuck with the coding.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,047
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 139
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: Counting occurrence of numbers in C

 
4
  #6
Nov 13th, 2005
Which part of the logic and the sequence do you not know how to do?
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 466
Reputation: winbatch is on a distinguished road 
Solved Threads: 18
winbatch's Avatar
winbatch winbatch is offline Offline
Posting Pro in Training

Re: Counting occurrence of numbers in C

 
0
  #7
Nov 13th, 2005
Originally Posted by stabule
I've been working on this for 2 weeks and have done my share of studying. The reason I'm posting here is because I really need help. I understand the logic and the sequence in which it must be written in, but I'm really stuck with the coding.
Basically, you're going to have to post your existing code to show that you've put in some effort.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC