473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help starting program

I dont even know how to do this program can someone help me.

I am to create a program that when

(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 27 '06 #1
6 1448
DeMan
1,806 1GB
What are the specific requirements?
Do we know there will always be exactly 11 integers (or at least is there a maximum number of integers we expect)?
Do these integers have a minimum and/or maximum value?
Are these integers stored in a file or do they get passed in throught the Standard Input (eg keyboard)?
Is there any suggestion as to what the expected result should be for your 'exception' (can we return any value or do we pick a specific one, or do we give an error)?
Repeat the above for the case where two or more integers share the lead for mode.
Nov 28 '06 #2
Manjiri
40
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 29 '06 #3
My program just says to use appropriate console output to make the process user friendly.
Nov 29 '06 #4
Thank you very much majiri, but can you explain to me how u did it?? I would like to know how to do this myself for future programs. Thanks.
Nov 29 '06 #5
Manjiri
40
Thank you very much majiri, but can you explain to me how u did it?? I would like to know how to do this myself for future programs. Thanks.



See the logic is very simple.... U have to just go on checking for each element, how many times it has occured in the existing array....By comparing with other elements in the same array... And store that(The number of times that it has occured) in to other array...Store it in the respectve index only... Then now find out which is the big number in the second array.. fetch it's index value.. Now at the same index(In the first array) u will get that number which has occured oftenly.....

Thank you..
Hope you got it...
Nov 29 '06 #6
I think i followed that, thanks alot for your help.
Nov 29 '06 #7

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

Similar topics

1
by: aToaster | last post by:
Hi guys, new to the forums. I'm starting to learn python and tkinter. I started off by trying to make a simple calculator program and I need to pass the calcTotal variable in and out of the...
3
by: aToaster | last post by:
Hey guys, I'm just getting the hang of Python and Tkinter and I could use some help. I wrote most of the gui for my calculator program, well I haven't gotten around to putting in the...
0
by: Tim Clark | last post by:
We've been having a lot of event ID 37 with src W3SVC errors popping up. We have 50+ sites in medium isolation, and i ran IISstate on the two instances of DLLHOST and the one of inetinfo. Is there...
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
0
by: georges the man | last post by:
The purpose: • Sorting and Searching • Numerical Analysis Design Specification You are to write a program called “StockAnalyser”. Your program will read a text file that contains historical...
45
nemisis
by: nemisis | last post by:
Hi Everyone I have am doing an object oriented C++ program and I have no idea as to how start it................. I am not that good at coding so i tried and made an overview of what...
1
by: radskate360 | last post by:
Hi I am newer to programming and need a bit of help with this program. OK, heres the directions. The distance between two places on earth can be calculated by using their latitudes and...
3
by: majestic | last post by:
Hello, Is it possible that someone can help me with the following program? There are 500 light bulbs (numbered 1 to 500) arranged in a row. Initially they are all OFF. Starting with bulb 2, all...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.