Home
About
Desclaimer
Privacy Policy
Terms of Services
Python
C/C++
Java
HTML/CSS
Home
About
Desclaimer
Privacy Policy
Term of Services
Python
C/C++
Java
HTML/CSS
Ad Code
Responsive Advertisement
Categories
C Program
(10)
c++ Programs
(3)
Search This Blog
Powered by Blogger
December 2022
13
Report Abuse
About Me
Universal Programmers
View my complete profile
Home
C Program
Write a program in C to read 7 integer values from the user in an array and display the frequency of each element in that array.
Write a program in C to read 7 integer values from the user in an array and display the frequency of each element in that array.
Universal Programmers
December 30, 2022
Answer
Copy
#include
#include
int main(void) { / Declare an array to store the integers int arr[7]; / Read the integers from the user printf("Enter 7 integers: "); for (int i = 0; i < 7; i+ +) { scanf("%d", &arr[i]); }/ Print the frequency of each element in the array for (int i = 0; i < 7; i++) { / Count the number of occurrences of the current element int count = 0; for (int j = 0; j < 7; j+ +) { if (arr[i] == arr[j]) { count++; } }/ Print the frequency of the current element printf("Frequency of %d: %d\n", arr[i], count); } return 0; }
OUTPUT
C Program
Post a Comment
0 Comments
Social Plugin
Popular Posts
Subscribe Us
Facebook
Tags
Close Menu
0 Comments