473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Frequency problem

4 New Member
Hello am a beginner in programming and I came to a problem with a question in which I need to calculate the frequency of appearance of marks.
I have used an array to store the marks but can only find the frequency of the first mark.Complicati on come along as I try for the others.
Oct 21 '06 #1
6 2649
arne
315 Recognized Expert Contributor
Hello am a beginner in programming and I came to a problem with a question in which I need to calculate the frequency of appearance of marks.
I have used an array to store the marks but can only find the frequency of the first mark.Complicati on come along as I try for the others.
Could elaborate on the specific problems (and may also post some coding)? This will make it a lot easier to help.
Oct 21 '06 #2
Harryrun
4 New Member
Could elaborate on the specific problems (and may also post some coding)? This will make it a lot easier to help.
first the input is the number of students, where I used integer n to store the value
and a do-while loop to keep on scanning and store the marks in an character array.

then used a do-while loop to see if the first mark is repeated in the array.
Am stuck with trying to check each mark that are not same as the first.....Pleas e can you help?

while((2*i)<=le n)
{
scanf("%s",&col l); /*coll collects the mark to concatenate in mark*/
strcat(mark,col l);
strcat(mark," ");
i++;
printf("\t\t");
}
as=strlen(mark) ;

do
{
s+=3;
s2+=3;
if((mark[f]==mark[s])&&(mark[f2]==mark[s2]))
freq++;
}
while(s2<=as);
Oct 21 '06 #3
arne
315 Recognized Expert Contributor
first the input is the number of students, where I used integer n to store the value
and a do-while loop to keep on scanning and store the marks in an character array.

then used a do-while loop to see if the first mark is repeated in the array.
Am stuck with trying to check each mark that are not same as the first.....Pleas e can you help?

Are the marks just numbers, say from 1 to 6, or similar?
Or are the possible values for the marks at least known in advance, say letters A to F?
This would simplify things somewhat (and before we start to develop a general solution ... )
Oct 21 '06 #4
Harryrun
4 New Member
Are the marks just numbers, say from 1 to 6, or similar?
Or are the possible values for the marks at least known in advance, say letters A to F?
This would simplify things somewhat (and before we start to develop a general solution ... )

The marks are numbers only.
They range from 0 to 99.
Oct 21 '06 #5
arne
315 Recognized Expert Contributor
The marks are numbers only.
They range from 0 to 99.
Then you may define an array 'occurences'

Expand|Select|Wrap|Line Numbers
  1. int occurences[100];
  2.  
If you encounter a mark value of 'x' during the scan, you simply increase the xth position:

Expand|Select|Wrap|Line Numbers
  1. int x;
  2. scanf( "%d", &x );
  3. occurences[x]++;
  4.  
At the end of the day, the array will hold the occurences of the individual marks.

Correct me if I did not understand the problem :)
Oct 21 '06 #6
Harryrun
4 New Member
Thnx I'll try that out.
Oct 21 '06 #7

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

Similar topics

2
2319
by: Isaac Gouy | last post by:
Seems like there's a problem with the word-frequency program written for "The Great Computer Language Shootout" - it's using 161,500KB which is far more than other programs: http://shootout.alioth.debian.org/benchmark.php?test=wordfreq&lang=php&id=0&sort=cpu What am I doing wrong?
9
2157
by: christopher diggins | last post by:
I would like to survey how widespread the usage of smart pointers in C++ code is today. Any anecdotal experience about the frequency of usage of smart pointer for dynamic allocation in your own code or other people's code you have come across would be appreciated. I am also trying to identify the likelihood nad frequency of scenarios where smart pointer solutions would not be appropriate, i.e. for some reason such as performance or...
11
4386
by: NC Tim | last post by:
Hello, I think the question i have is fairly straightforward, but I can't seem to replicate the old SAS frequency procedure when I try to accomplish this in MS Access. anyway, i have about 10 questions on a survey that have a possible response range from 0-4. what I would like to do is simply show that for each question we had x amount of responses in each category, which amount to x percentage of all
19
3147
by: jason_box | last post by:
I'm alittle new at C and I'm trying to write a simple program that will record the frequency of words and just print it out. It is suppose to take stdin and I heard it's only a few lines but I'm not sure where to start. The only example I have to work with is if you ran the program say: File list contains: This is a test.
8
4332
by: writeanand | last post by:
How can I count the frequency of words in a ASCII File using STL? a) I dont know what words will be found in the file b) The max number of occurrences is 10,000 per word (in case that matters) Can anyone give me an example program and compare/contrast the use of various STL containers for this problem?
7
4060
by: Udhay | last post by:
How to get the frequency of an audio file and how to separate the low and high frequency of an audio file
1
4943
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 not supposed to store the actual value in an array. Please help me with this problem. Thank you Guinness #include <iostream> #include <iomanip> #include <cstdlib> #include <fstream> using namespace std;
8
4093
by: Andrew Savige | last post by:
I'm learning Python by reading David Beazley's "Python Essential Reference" book and writing a few toy programs. To get a feel for hashes and sorting, I set myself this little problem today (not homework, BTW): Given a string containing a space-separated list of names: names = "freddy fred bill jock kevin andrew kevin kevin jock" produce a frequency table of names, sorted descending by frequency. then ascending byname. For...
13
3742
by: umpsumps | last post by:
Hello, Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated.. def valsort(x): res = for key, value in x.items(): res.append((value, key))
0
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.