Questions tagged [plurality]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
19 views

I changed typedef struct in Plurality in problem set 3, is there any problem?

"You should not modify anything else in plurality.c other than the implementations of the vote and print_winner functions (and the inclusion of additional header files, if you’d like)." I ...
0
votes
0answers
43 views

Help on Plurality Pset3

I'm trying to solve assignment "Plurality" of Problem set 3. However, check50 didn't prove to be quite useful for me this time. I'm having only one error message saying "print_winner&...
0
votes
1answer
25 views

Plurality problem

I ran check50 on my code and it worked fine on everything except in dealing with invalid votes, so I tested it by debugging and fount out that a segmentation error occurs while debugging, and then ...
0
votes
1answer
14 views

Plurality Clarification

Here, can I edit return false because it seems to be in the wrong place for me (to return false at any time and/or case it was called in), or I should edit only the TODO code section?
0
votes
1answer
18 views

Plurality starter code clarification

Previously, we 've been indicating an array by typing its datatype at first, and then the rest of the syntax how does candidate here is typed instead of the datatype ?
0
votes
1answer
13 views

Printf works fine if arr[0] is the largest after sorting, but not if another element is moved to that position. Why?

I am trying to sort a typedef struct array and print out those elements that have the largest number. I can get the answer I want, but if the element that is largest is NOT what was originally in the ...
0
votes
0answers
28 views

CHECK50 for Plurality shows bug which manual testing can't find

Could anyone perhaps help me figure out what's wrong with the code below? When I check it manually, it works every time, in every scenario I can think of, but when I run check50 on it, I get ":( ...
0
votes
1answer
54 views

cs50 plurality invalid vote

I'm working on plurality on pset3, and so far I haven't edited any code, but whenever I try enter a vote it comes back as 'invalid vote'. Is this normal? And if so what should I do to solve this bit.
0
votes
1answer
42 views

Pset3 Plurality: program runs fine when I check manually, but Check50 disagrees

I wish I could be more specific with my question, but the problem is as the title suggests, check50's results do not seem to comport to mine. When I put it through check50, it fails on print_winner ...
0
votes
0answers
27 views

Problem incrementing vote in plurality

EDIT: I FIGURED IT OUT AND IT IS NOW WORKING. My code does not increment the vote. It correctly prints the invalid vote- but its not increment the vote at all. #include <cs50.h> #include <...
0
votes
1answer
14 views

Plurality test passing on all except one

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
1answer
356 views

cs50 plurality non-void function does not return a value in all control paths error

I'm currently trying to do cs50 pset3 plurality problem and I have unfortunately ran into this error which I do not know how to overcome. The error is "non-void function does not return a value ...
0
votes
0answers
15 views

Problem set 3 plurality compilation mystery [duplicate]

In my program of problem set 3 plurality i compiled it and it got compiled and it was working good but when i ran check50 it is telling that "plurality.c code failed to complie" in a red ...
0
votes
0answers
33 views

pset3 plurality-- my code is working fine and the prints out multiple winners as well but when i try check50 it fails can anyone tell what is wrong

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int votes; } ...
0
votes
1answer
43 views

Plurality - Why do I get segmentation fault?

I've tried running the program but when I put into an incorrect vote I get "segmentation fault". What's wrong? EDIT: I've changed: while (n < candidate_count) to while (n < ...
0
votes
2answers
59 views

check50 for plurality

Every example I try myself works perfectly fine but once I check50 it, I get error messages for not printing one,two, or all three winners. I saw some people having format issues with spaces, but I ...
0
votes
0answers
40 views

Plurality works with my examples, but not with check50

I have finished my plurality program and its fine with the examples I give it, but it fails to print any of the winners of the Check50 examples. Any idea of how can I reproduce that elections, to see ...
0
votes
0answers
23 views

Fail to compile - PSET3/PLURALITY [duplicate]

I'm trying check my code using "check50 cs50/problems/2020/x/plurality" and the code fails to compile. The code seems working fine for me. Someone whould help? The error message: :) ...
0
votes
1answer
36 views

Plurality works perfectly with debug50, but it does not without it

I've been working for weeks on pset3 - plurality, and all my logic is working fine in debug50, but not in real execution. It gives me either "segmentation fault" or (null). Basically, my ...
0
votes
3answers
433 views

pset3 plurality check50 invalid vote

So I have a few questions on Plurality check50 errors for this Pset: My Code is as follows: #include <cs50.h> #include <stdio.h> #include <string.h> #include <math.h> // Max ...
0
votes
3answers
49 views

Even though I get correct output check50 shows error in pset3 plurality problem

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
1answer
118 views

Plurality Pset 3 I need Help

Whats wrong i keep getting segfault for(int o = 0; o < n - 1; o++) { if(candidates[o].votes > high0) { high0 = candidates[o].votes; name1 = candidates[o].name; } ...
0
votes
1answer
48 views

Pset3 Plurality returning "Invalid vote" in main programme code

When inputting vote names in "Plurality", the programme is returning Invalid vote. It looks like this in the terminal: ./plurality Alice Bob Garry Jim Number of votes: 4 Vote: Alice Invalid ...
0
votes
1answer
58 views

Pset 3 Plurality Help (still not working)

When I compile my code it works, but when I try to run it, it says segmentation fault. I believe the segmentation fault is on the line that says printf("Winner is %s with %i votes\n", winner,...
0
votes
1answer
18 views

Prints " Invalid vote " for " code 1 " as vote function But works fine for " code 2 " as vote function. Whats wrong with " code 1 "?

// CODE 1 :- bool vote(string name) { // TODO for (int i = 0; i < candidate_count; i++) { if ( candidates[i].name == name ) { candidates[i].votes = candidates[i].votes + 1 ; return true ; } } ...
0
votes
0answers
41 views

Pset3 Plurality Help Again

This time I'm able to compile and run my code properly, but it tells me that there is a segmentation fault. Can someone help me figure out how to fix it? My code is below, thanks. #include <stdio.h&...
0
votes
1answer
187 views

Pset 3 Plurality Help

I was trying to compile my code for plurality but it says: plurality.c:82:1: error: control may reach end of non-void function [-Werror,-Wreturn-type] } ^ 1 error generated. <builtin>: recipe ...
0
votes
1answer
86 views

pset 3 plurality

To figure out the winner, I am trying to do a bubble sort and then print the last name (or names if the last two are tied). For some reason, after it goes through the first run-through of the bubble ...
0
votes
2answers
75 views

PSet 3 Plurality keeps getting 'segmentation fault'

This keeps coming up with "segmentation fault" when I run it although everything I want it do is working. It seems to be coming from the last if statement because there's no fault when I delete that ...
0
votes
2answers
223 views

PSET3 Plurality Problem

void print_winner(void) { // TODO int c = 1; int numwin = 1; candidate mv[MAX]; mv[0].votes = -1; for(int i = 0; i < candidate_count; i++) { if(candidates[i].votes >...
0
votes
2answers
301 views

CS50 pset3 plurality program gives error for print_winner function (did not print both winners of election)

I have finished the plurality program for pset3 of cs50, but upon running check50 on my code, I receive the following error directed towards the print_winner function: :) plurality.c exists :) ...
0
votes
1answer
34 views

Calling 'Vote' function in Plurality (Problem Set 3)

My program runs fine, but I have a question (it might be a silly one but I'm completely new at programming and just want to be sure I'm learning well!) string name = get_string("Vote: "); this is ...
1
vote
1answer
130 views

pset3 plurality - trouble implementing a linear sort

I have some code that completely passes check50, but prints results way too many times. For instance, here's a typical output: ~/pset3/plurality/ $ ./plurality Alice Bob Carol Number of voters: 5 ...
0
votes
1answer
106 views

PSET3-Plurality. Check50 print winner Alice

My program behave correctly when i try it manually but it fails in check50. It returns " :( print_winner identifies Alice as winner of election " print_winner function did not print winner of election....
0
votes
1answer
92 views

PSET 3 Plurality - Program works but also returns invalid vote?

For those who don't know, this pset is for calculating votes in an election. We were told to code the two functions vote and print_winner, and not to touch any of the other code. The program seems ...
0
votes
1answer
154 views

Problem set 3 Plurality check50 error

I have managed to complete the plurality problem for problem set 3, however when I run check50 I get this one error: :( print_winner identifies Bob as winner of election print_winner function did not ...
0
votes
2answers
131 views

Why am I running into a segmentation error in PSET 3 plurality?

I've been working on plurality for hours now and I'm stuck with a "segmentaion error." So my approach to this problem was to sort the candidate objects in terms of votes and print the first object (...
1
vote
1answer
36 views

Global Variable vs Local variables?

I'm trying to write a function that will be called in main(int argc, string argv[]) for pset 2: plurality. Inside the function, I want a for loop. I've written this: bool vote(string name) { ...
0
votes
1answer
168 views

Having problems with plurality for cs50

I am trying to run the program for plurality for cs50, and the program compiles I put my candidates in and number of voters and vote, but instead of printing the winner it gives me a segmentation ...
0
votes
0answers
205 views

:( print_winner identifies Alice as winner of election. print_winner function did not print winner of election

What kind of test I should do to know What is the problem in my code because it's the only issue I have every other condition is working good.
0
votes
1answer
44 views

My Plurality.c works when I test it with all of their usage examples but when I run check or submit it says it doesn't print

I'm a beginner and CS50 is the first coding experience I have. Like the title says, my code works when I test it but the CS50 won't accept it so I'm not sure what's wrong. Thanks for any help! ps. ...
0
votes
1answer
173 views

Problem with plurality

when i check50 my code I get this message : :( print_winner identifies Bob as winner of election print_winner function did not print winner of election :( print_winner identifies Charlie as ...
0
votes
1answer
60 views

Pset3: Plurality; Code doesn't consider command line arguments expect the first one!

I don't understand why my code only considers the first command line argument and shows "Invalid Input" for rest of the arguments upon passing other argument's name while voting. Here is the code ...
0
votes
1answer
90 views

CS50 plurality will not return any answers

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
1answer
243 views

why is this wrong?cs50 pset3 plurality

#include <cs50.h> #include <stdio.h> #include <string.h> // Max number of candidates #define MAX 9 // Candidates have name and vote count typedef struct { string name; int ...
0
votes
1answer
145 views

pset3 output seemingly correct but not for check50

My problem is that I cannot make it correct in the check50 although the output from the simple testing seemingly fine. It would be grateful if anyone could help me understanding how to solve this. ...
0
votes
3answers
1k views

pset 3 plurality code help

My code prints all names in the case of a two way/threeway tie, but for some reason I still get an error message in check50 that it does not. The only thing I could think of was maybe it had to do ...
0
votes
1answer
256 views

PSET3-Plurality. Check50 doesn't re

After finishing plurality, it fails check50. It returns "print_winner function did not print winner of election". In print_winner function I did the following void print_winner(void) { //create a ...
0
votes
1answer
174 views

pset3 I did print winner from pluarity, but check50 says I didn't. What's wrong?

I ran plurality according to spec and was able to print out all winners correctly. check50 says I didn't. What could be the problem? Is there any way to see what check50 used as inputs for plurality? ...
0
votes
1answer
380 views

Plurality vote strange errors

My code works consistently, but I get these two errors which I check it. I would like to know how to replicate these errors on my own so that I can figure out how to fix them. #include <stdio.h>...