473,467 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to find the mode of an array??

15 New Member
I dont know how to find the mode of an array.

I am to do the following.

(1) Given the following:

· A list of 11 integers; 1,2,3,3,3,2,2,1,3,4,5


(2) The program should:

· Creates an array from the source data list

· Determines the “mode” of the array (mode is a proper statistical term that is the value that occurs “most often”)

· The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


Any help is appreciated. Thanks
Nov 28 '06 #1
2 35695
Manjiri
40 New Member
I dont know how to find the mode of an array.

I am to do the following.

(1) Given the following:

· A list of 11 integers; 1,2,3,3,3,2,2,1,3,4,5


(2) The program should:

· Creates an array from the source data list

· Determines the “mode” of the array (mode is a proper statistical term that is the value that occurs “most often”)

· The program should account for the “exception” that no “mode” occurs – no value in the array occurs more than once.


Any help is appreciated. Thanks


Try out this.... U will get the ans..
#include<stdio.h>

int main()
{
int i,j,k=1,p,a[20],b[20],n,cnt=1,big;
printf("Enter the maximum number of elements\n");
scanf("%d",&n);
printf("Enter the elements\n");
for(i=1; i<=n; i++)
scanf("%d",&a[i]);
for(i=1; i<=n; i++)
{
for(j=i+1;j<=n; j++)
{
if(a[i]==a[j])
cnt++;
}
b[k]=cnt;
k++;
cnt=1;
}

big=b[1];
p=1;
for(i=2; i<=n; i++)
{
if(big<b[i])
{
big=b[i];
p=i;
}
}
printf("The element that occurs offenly is %d\n",a[p]);
printf("And it has occurred %d times\n",b[p]);
return 0;
}
Nov 28 '06 #2
ovince01o
5 New Member
i dont know how to program mode

i am given the following problem

gets the scores for user
short the scores
find the mode and how many times it is used can u help me sir?
Feb 24 '18 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: PhilC | last post by:
Hi Folks, If I have an array holding a pair of numbers, and that pairing is unique, is there a way that I can find the array index number for that pair? Thanks, PhilC
7
by: Bo Sun | last post by:
hi: please take a look at the following code fragment: char* hello = "Hello World\n"; hello = 's'; why I cannot modify hello?
5
by: zebul0n | last post by:
Hello, I have an array : Array ( '2' ='27584.10', '3' ='1008.00', '6' =11393.55, '7' =888.12 ) which i need to modify to fill missing keys from 0 to 11 with zero value. Like this : Array...
7
by: =?utf-8?B?5YiY5piK?= | last post by:
Hi, folks, Is it possible to delete an element from a sorted array with O(1) time? Best regards
1
by: shgu0501 | last post by:
hi I'm supposed to do a frequency array and find mode,median and count, but without storing the actual data in an array. I am able to build a frequency array but I can't return the mode since I am...
3
by: David C | last post by:
My brain is fried. How can I determine if the row is in edit mode when processing the RowDataBound event? Thanks. David
1
by: alfiecrosby | last post by:
Hi... this is my first time ti post here... I have a question regarding my PHP study... How do I find out if an array has values posted to each of its elements? I need to know that EVERY...
2
by: kishore2k9 | last post by:
hi, how to find in array that array keys contains special characters,punctuations only with alphabetic charaacters in each array key ex:...
2
by: scuzz88 | last post by:
i need to make a subroutine that searches an array for an item . If it finds the item it should return the array index of the item, if it does not find then the return value should be -1. if...
1
by: beulajo | last post by:
Hi, I need to calculate Mean, Median, Minimum, Maximum and Mode of DOB from a table By calculating their age based on the saved DOB I have no problem in finding out min,max,mean and median...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.