answersLogoWhite

0


Best Answer

Your first step is accepting input, which is done using the scanf() function:

scanf("%d", &number);

This means that you want scanf() to accept input, convert the input to a number, and store it in the memory at the address of number.

Use a for() loop, counting from 0 to 9, and an array of integers to hold the numbers. Then simply scanf("%d", &intarray[counter]);

The next step is a little tricky, but not very if you plan it out in advance.

Each integer can contain 256, 65,536 or 4,294,967,296 different numbers. Creating an array to hold the count of each of those numbers is a waste of RAM.

Instead, you'll want an "associative" array as follows:

int numcount[MAXNUM][2];

MAXNUM is 10, or the number of integers in the array you're checking. The second dimension, 2, consists of the number and its count.

Obviously, you'll want a way to keep track of how many integers you've stored in numcount. An int called numcountnuminitialized to 0 would be the fastest way.

Use a for() loop to iterate through the integers. If the integer does not exist in numcount, then set numcount[numcountnum][0] to the integer, set numcount[numcountnum][1] to 1, and increment numcountnum. Otherwise, if the integer exists, increase numcount[the integer index][1].

Once the for() loop is finished, display the results. The only thing you have left to figure out is the function that searches the numcount array for an integer, and returns its index (or -1 if it's not found).

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

write a program that takes ten integers in an array, It displays the number of occurrences of each number in the array

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program for counting and displaying occurrence of a number in an array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


A computer programmer wrote a program that adds two numbers The programmer ran the program and observed that when 5 is added to 8 the result is the character m Explain why this program is behaving?

This is happening because when the programmer is displaying the number, it is being displayed as a character with a decoding process of a = 1, b = 2, etc. 5 + 8 = 13 = m


C program to find the occurrence of an element in a number?

Let "n" is that number and "occ" is the no of occurrence of a element "el" in "n". so, <pre> i = n; occ = 0; // Initializing "occ" to zero. while(i > 0){ rem = i % 10; // This gives a digit in the number. if(rem == el) occ++; // If "rem" is same as "el" then increament "occ". i = i / 10; //By this we are extracting rem from number i. } printf("No of Occurrence of %d element is : %d", el, occ); // Printing the number of occurences </pre> that's it.


A c program for multiplication of two integers a and b?

/*PROGRAM TO ACCEPT TWO NUMBERS FROM THE USER AND PRINT THEIR MULTIPLICATION. */ #include<stdio.h> #include<conio.h> void main() { int a, b, c; // Declaration of Variables. Variables 'a' & 'b' to hold first & second number. And 'c' to hold result. clrscr(); // To clear the output screen every time program is executed. printf("\n Enter the first number : "); scanf("%d", &a); // To accept the first number. printf("\n Enter the second number : "); scanf("%d", &b); // To accept the second number. c = a*b; // Logic to get the product of the entered two numbers. printf("\n Multiplication of %d & %d = %d", a, b, c); // Displaying result. getch(); // To hold the output screen. }


Html code for displaying number of viewers?

You cannot do it directly in HTML. You need a hit counter program to record and display the actual amount of viewers of your page. The HTML just puts the counter on your page. If you do a search for hit counters, you will find lots of free ones on the internet. They will all have ways of embedding them into your page.

Related questions

Write a program that read phrase and print the number of lower-case letter in it using function of counting?

write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program


Is 7 a counting number number?

7 is a counting number. But I am not sure what a counting number number is!


If a number is a counting number or the opposite of a counting number then is it an integer?

A counting number is the numbers you lear as a little kid, counting numbers are one and up. Integers include the counting numbers, 0, and the opposite (negative) of counting numbers. So yes, a counting number or the opposite of a counting number is an integer.


If a number is a counting number or the opposite of a counting number then it is an integer?

A counting number is the numbers you lear as a little kid, counting numbers are one and up. Integers include the counting numbers, 0, and the opposite (negative) of counting numbers. So yes, a counting number or the opposite of a counting number is an integer.


Why zero is not a counting number?

The number 0 has no value.Therefore it is not a counting number.


What is the product of a counting number and itself?

That's the "square" of the number. With counting numbers, the square will always be another counting number.


When does the counting number begins and where?

counting number begins from 1 and so on .


Is every real number a counting number?

No. 3.6427 is real and rational, but not a counting number.


Is 2.5 a counting number?

yes. the number 25 is a counting number. hope this answers your question.


If a number is a counting number or the opposite of a counting number then it's an integer?

Yes, and including zero.


Can every counting number be an integer?

YES. Every counting number is an integer.


Successor of the counting number 75?

The successor to counting number 75 is 76.