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.
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.
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);
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 ... )
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.
arne 315
Recognized Expert Contributor
The marks are numbers only.
They range from 0 to 99.
Then you may define an array 'occurences'
If you encounter a mark value of 'x' during the scan, you simply increase the xth position: -
int x;
-
scanf( "%d", &x );
-
occurences[x]++;
-
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 :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
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?
|
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...
|
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
|
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.
|
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?
| |
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
|
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;
|
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...
|
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))
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |