944,191 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 3610
  • C RSS
Nov 13th, 2005
0

Counting occurrence of numbers in C

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stabule is offline Offline
6 posts
since Oct 2005
Nov 13th, 2005
0

Re: Counting occurrence of numbers in C

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
SpS
Reputation Points: 70
Solved Threads: 32
Posting Pro
SpS is offline Offline
598 posts
since Aug 2005
Nov 13th, 2005
0

Re: Counting occurrence of numbers in C

I'm still a beginner, don't really know how to write the coding. Could you help me out?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stabule is offline Offline
6 posts
since Oct 2005
Nov 13th, 2005
0

Re: Counting occurrence of numbers in C

Quote 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.....
SpS
Reputation Points: 70
Solved Threads: 32
Posting Pro
SpS is offline Offline
598 posts
since Aug 2005
Nov 13th, 2005
0

Re: Counting occurrence of numbers in C

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
stabule is offline Offline
6 posts
since Oct 2005
Nov 13th, 2005
4

Re: Counting occurrence of numbers in C

Which part of the logic and the sequence do you not know how to do?
Team Colleague
Reputation Points: 1135
Solved Threads: 173
Super Senior Demiposter
Rashakil Fol is offline Offline
2,480 posts
since Jun 2005
Nov 13th, 2005
0

Re: Counting occurrence of numbers in C

Quote 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.
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: i am a to c programing..and a doubt about pointers
Next Thread in C Forum Timeline: Binary Tree Traversal





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC