Questions tagged [plurality]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
172 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
2answers
95 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 (...
0
votes
1answer
149 views

Plurality - check50 issue

Hoping for some insight on this.. code works perfectly fine, prints correctly when testing in terminal, but for some reason check50 outputs errors once it starts printing winners. Would love to find ...
0
votes
1answer
19 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
1answer
40 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
0answers
8 views

CS50 pset 3 Plurality - Works until…Segmentation fault, and not enough vote prompts?

Task is to have people type in their votes for the candidates given in the command line, then the most voted candidate wins. I only need to and am allowed to write code for the last two function ...
0
votes
2answers
386 views

Error testing in plurality question

I already test my code with all possible input and it working fine but when I run with check50 cs50/problems/2020/x/plurality, I got a couple of error result :( print_winner identifies Bob as ...
0
votes
1answer
417 views

Plurality is being failed by check50 when it works in my terminal (PSET3)

Plurality Check50: https://submit.cs50.io/check50/dfe0d69252268f63eddb40057eada6979586a661 However, code works when I run it in my terminal: https://imgur.com/a/xEp0EnH Code: void print_winner(void)...
0
votes
0answers
29 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
17 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
140 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
2answers
55 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
1answer
25 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
41 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
26 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
54 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
14 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
3answers
140 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
2answers
158 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
1answer
91 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
0answers
40 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
113 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
37 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
1answer
30 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 ...
0
votes
1answer
93 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
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
82 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
64 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
108 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
1answer
104 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 ...
1
vote
1answer
24 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
0answers
88 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
152 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
306 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>...
0
votes
0answers
46 views

plurality questions

I am sure this is going to be the first of a couple of questions about this assignment. I also understand there are probably many problems with the code I am about to show but I do have two general ...
0
votes
1answer
128 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
52 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
85 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
115 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
1answer
216 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
187 views

Plurality segmentation fault

I am getting a segmentation fault despite knowing that the size of the candidates[] array is the same as the value stored in the variable candidate_count and I am iterating through the array from 0 to ...
0
votes
1answer
1k views

Problem set 3 Plurality ISSUE cs50

I've been trying to solve the new problem set 3 plurality step by step, and here where I got stuck, but somehow I'm sure about my answer bool vote(string name) { bool v = false for (int i = 0 ; i &...
0
votes
1answer
408 views

Plurality fails to compiles

I always work on Psets on my local machine and replace string with char * so I don't have to use the CS50 library in my header files. This is the only explanation I have for why my code doesn't ...
0
votes
1answer
138 views

why does it not return a value for bool?

So my code does not compile because it does not return a value. I don't know how to make it work and return true and false as it is in the if statement // Update vote totals given a new vote bool ...