Questions tagged [pset2]

The problem set for Week 2 continues with the C programming language used in problem set 1.

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

Trying to implement itoa function in pset2 caesar

While working on Caesar i realized i needed a function to convert an int to a string and searched online. The first one I came across was the itoa function but it turned out it wasn't a standard ...
0
votes
2answers
74 views

Caesar pset2 How to Reprompt user for Command Line Argument?

I have started working on Caesar and I am stuck with how to repromt user for a command line argument incase they input some wrong values. Here is the code i wrote and I can't find any apparent errors #...
0
votes
1answer
29 views

Segmentation Error while Using if Statement for Pset2 Caesar

I have been working on Caesar for some time now and tried to use different loops but I am getting Segmentation Errors. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #...
3
votes
4answers
2k views

Pset2 Readabilty: Why are my grade levels calculating incorrectly?

For Pset2: Readability, I'm writing a program in C that prompts the user for text input, analyzes how many letters, words, and sentences are in the text entered by the user, and calculates the grade ...
0
votes
1answer
43 views

pset 2 Readability Segmentation Fault

I started working on readability and I am trying to figure out how to count the letters. I found a way but it includes all the characters so now I am trying to eliminate all the entries besides the ...
0
votes
1answer
17 views

pset2 ceasar ( why does it keeps showing " expected "ciphertext: yx...", not "ciphertext: yx..."

#include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc , string argv[]) { if (argc == 2) { if ...
0
votes
0answers
82 views

PSET Make Readability

i am having some problems trying to execute make readability. Can you help me? Thanks in advance!
1
vote
1answer
105 views

Why is it a segmentation fault when argc is 1 only i.e if I input "./caesar" only? It contains some other errors as well given in screenshot

My program perfectly encrypts texts if user gives a key or enters a wrong key such as an alphabet. But if argc is 1, then I incur a segmentation fault. I also incur a few other problems when I apply ...
0
votes
1answer
34 views

Having trouble identifying non-decimal digit in Caesar PSET 2

I'm working on Caesar from Problem Set 2. I have done the first step to check for a single command line argument, but I'm stuck on how to check the argument to see if any characters are non - decimal ...
0
votes
1answer
23 views

Is it just me or PSET2 Correction seems to have a mistake

I ran the check50 on my pset2 Substition.c I get everything right except for 1 encrypts "This is CS50" as "Cbah ah KH50" using YUKFRNLBAVMWZteogxhcipjsqd as key expected "...
1
vote
1answer
401 views

pset 2-substitution-error handles multiple duplicate characters in key timed out while waiting for program to exit

Im working on substitution from pest 2 and I'm getting everything approved except for the last message: handles multiple duplicate characters in key timed out while waiting for program to exit Below ...
1
vote
1answer
59 views

Pset2 Caesar - Segmentation fault error

First off, I will show my code: int main(int argc, string argv[]) { if (argc != 2) { printf("Wrong command line arguments\n"); return 1; } else { ...
1
vote
1answer
417 views

What am I missing ? (pset2, readability)

The problem is that when i run check50 cs50/problems/2020/x/readability into the terminal, it says :( handles questions in passage Cause expected "Grade 2\n", not "Grade 3\n" Log ...
0
votes
1answer
124 views

Week 2 Readability Letter Count

I am able to figure out the number of letters and spaces (the answer is 300) with the code below. How do I write a command to exclude the spaces? A hint would be appreciated. Thank you. ''' #...
0
votes
1answer
60 views

Pset2 Readability: Counting words and sentences

whenever I try to run my readability code I always get that I have no words or sentences. Additionally, whenever I run my code the number of letters seems to include spaces eventhough I am using the ...
0
votes
1answer
77 views

check50 problems caesar pset 2

0 I won't post my code, because, as far as I could tell, it works fine, but I keep on getting this when I run check50 and I don't know know exactly what it means or how to fix it. My code runs ...
0
votes
2answers
41 views

getting error on caesar

I keep getting an error on the last else idk what's wrong with that code. #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> ...
0
votes
1answer
36 views

pset2 Readability test question

This is what I have so far. I realized that when counting letters there are more symbols you must exclude, but I am not sure how to do that. Also, my program isn't running for some reason and I am not ...
0
votes
1answer
18 views

Trying to do pset 2, but it doesn't even accept my input. What am I doing wrong?

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int check(int c, string key); int main(int argc, string argv[]) { int ...
0
votes
1answer
40 views

clarification validating command line arg

thanks for the answer. I tried to use a for loop, like this, for (int i = 0; i <= argc; i++) { if (isalpha(*argv[1])) { printf ("Usage: ./caesar ...
0
votes
3answers
114 views

Why So Many Check50 Errors on Caesar? Results match expected output

Of the 11 Check50 checks, only 4 check out correct but when I run the code with the Check50 inputs, my outputs match the expected outputs, so why so many errors? Here is a link to my Check50 results: ...
0
votes
1answer
79 views

I get segmentation fault after this line and I don't know why

I get segmentation fault at this point in my code and I can't figure out why string convert(string text, int num_copy) { string new_index = NULL, answer; for (int j = 0; ; j ++) { if (isupper(text[...
0
votes
2answers
80 views

I keep getting segmentation fault and I don't know why

I'm trying to print the value of argv[1] to check if the program will run as expected. It compiles fine, but I keep getting 'segmentation fault' when the program runs. #include <cs50.h> #include ...
1
vote
2answers
68 views

My Coleman-Liau index gives the wrong answer

the program seems to be running fine but I don't know what went wrong in the index, it just doesn't give the right answer. #include <cs50.h> #include <stdio.h> #include <string.h> #...
0
votes
2answers
1k views

"Output not valid ASCII text" error with Substitution pset

i'm having these errors when i check my code. This is it: #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int main(int argv, string argc[]) { ...
0
votes
2answers
45 views

readability errors

I keep getting errors on the int i. idk what's wrong with my code #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> int main(void) string text=...
1
vote
2answers
51 views

Hey. Please help me find my mistake. The number of words in my sentences is not counted properly

I tried using debugger but could not figure out where I went wrong. please help #include <stdio.h> #include <cs50.h> #include <string.h> #include <math.h> int main(void) { ...
0
votes
1answer
39 views

PS2 - substitution

thanks for helping me out :) When I am running my code I get a weird output, an intractable char that is being added randomly to my output. The weird thing is that that the char that is being added is ...
0
votes
1answer
25 views

pset2 making a whole string uppercase for use in substitution.c

I am trying to use the following helper function inside my substitution.c script: string upper(string key) { int n = strlen(key); char key_upper[n]; for (int i = 0; i < n; i++) { ...
0
votes
1answer
158 views

Pset2 Readability. I am starting to do readbility and for some reason the code i wrote this far seems not to be compiling properly

My for loop doesn't seem to be executing. When i run the program it seems for loop is been skipped. Can someone please help me out. #include <stdio.h> #include <cs50.h> #include <string....
0
votes
1answer
146 views

Caesar Pset2 Handles non-numeric key :(

I am tearing my hair out on this exercise. I cannot get it to pass a non-numeric key. I've played around with the code for 2 weeks now. I can either get it to handle a numeric key or handle a lack of ...
0
votes
0answers
415 views

CS50 - PSET2 - Substitution Segmentation fault

I keep getting 'Segmentation fault' every time I run the code(mentioned below). The code is compiling just fine. It's asking for input and is returning required message when the command line argument ...
0
votes
0answers
84 views

CS50x pset2 substitution, check50 test returns negative even though output is correct

My code fails only one of the test in check50 even though the output is correct and passes other ones. The test it fails: :( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key ...
0
votes
1answer
168 views

Pset2 - Substitution - "Output not valid ASCII text" error despite correct cipher output

after running check50 I am getting an "output not valid ASCII text" error for the following problems: :( encrypts "A" as "Z" using ZYXWVUTSRQPONMLKJIHGFEDCBA as key output not valid ASCII text :...
0
votes
1answer
125 views

PSET2 Readability - tests no passing

I am not sure what I am doing wrong. #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { //Create integers ...
0
votes
1answer
68 views

Pset2 Coleman-Lau Index Always Prints -15

I'm struggling with PSet 2 Readability. I don't want to cheat the answers because I am genuinely trying to learn how to think better and improve my logic. I so far have been able to get the letter ...
0
votes
2answers
73 views

pset 2 caesar -- bug that specifically lowercase letters with key more than 52 don't work -- everything else does

// ciphering for (int i = 0, n = strlen(plaintext); i < n; i++) { ... // lowercase if (plaintext[i] > '`' && plaintext[i] < '{') { if (...
1
vote
1answer
330 views

I have "handles non-numeric key timed out while waiting for program to exit" problem inPset 2 and I can't solve it

here is my code: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <math.h> #include <stdlib.h> int main(int argc, string argv[]...
0
votes
1answer
34 views

Testing code to validate input using a parenthesis for cs50/pset 2/caesar.c I get error bash: syntax error near unexpected token `)'

Been struggling with this all morning and grateful for any help please! I'm aware that it's not the most elegant code but below weems to work OK with most invalid input that I've thrown at it so far, ...
0
votes
1answer
61 views

Pset2 readability

im trying to write this code in a particular way but my programme seems to keep getting the letter counts wrong. running debug 50 it seems that the bool i have created (letter) does not change from ...
0
votes
1answer
1k views

Pset2 Caesar !! Help?

Please, help me, I can't figure out my problem. This is my code : #include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]...
0
votes
1answer
45 views

PSET2 Caesar (BARFOO/BaRFoo error)

Hi everyone and I'm sorry if this has been asked here, but I've spent hours online trying to figure out why only the mixed (upper and lower) tests failed. I don't know what I'm overlooking or missing ...
0
votes
1answer
103 views

pset2 substitution not working

im kinda stuck with pset2, substitution. Any help is appreciated. When trying to convert the plaintext into the ciphertext, the formula just doesnt do anything. I suppose there is something wrong ...
0
votes
1answer
241 views

Segmentation fault in Substitution - Problem Set 2

I have finally finished writing my code for the Substitution question in Problem Set 2, but Check50 tells me that my code has a segmentation fault when there is a lack of key. My code is as follows: #...
0
votes
1answer
133 views

Problem Set 2 - Caesar

I am very new to coding. Prior to starting CS50, I have had no experience in coding at all, so pardon me if my questions are trivial. I am trying to write some code for 'Caesar' in Problem Set 2 and ...
0
votes
1answer
39 views

Improvement in Cash Code

im curently doing pset4, but redoing the psets one by one for practice since I feel like im not yet ready to make pset4. Just finished pset2, Cash. The code is right and works, i was just wondering if ...
0
votes
1answer
58 views

Can't fix logical problem, pset2 substitution

I can't fix this logical problem. I have a check_alpha function which should return if all characters are alphabetic. bool check_alpha(char key[]) { for (int i = 0, n = strlen(key); i < n; i++...
0
votes
2answers
57 views

pset2 readability. The brackets are in the wrong place but I can't figure out where they should go to make the program work correctly

include include include include include include int letters = 0; int words = 0; int sentences = 0; int main(void) { string text = get_string("Text: "); for (int i = 0, len = strlen(...
0
votes
1answer
287 views

Pset2 Readability test fail "complex single sentence" Grade 9 instead of Grade 8

When using check50 or inputting the provided texts, my program passes all but one test; the "complex single sentence" test returns a Grade 9 instead of Grade 8 (Coleman-Liau index returns 8.785455 and ...
0
votes
1answer
21 views

Strlen function does not give the intended output

when I execute this code below with the text: hello world, the result is 5 characters. Why is that? #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { ...

1
4 5
6
7 8
26