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?

Recommended Answers

All 6 Replies

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

I'm still a beginner, don't really know how to write the coding. Could you help me out?

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.....

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.

Which part of the logic and the sequence do you not know how to do?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.