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
2answers
29 views

Readability assignment, getting “Segmentation fault” message

It took me a while to be able to compile and run this program, and now I'm getting a "segmentation fault" message. What have I done wrong? Here's my code: #include <stdio.h> #include &...
0
votes
1answer
20 views

Bad math pset2 - caesar

I tried submitting the solution for pset2 - caesar but I get a lot of errors back. Most of them are to do with wrong translation of the input text. Can anyone tell me where I'm going wrong ? Thank you ...
0
votes
1answer
11 views

I am getting different outputs with my code in CS50 pset1 substitution

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <math.h> #include <string.h> int main(int argc, string argv[]) { int d = 0; int duplicate = 0; ...
0
votes
1answer
29 views

cs50 pset2 substitution Segmentation error

I am stuck at working out what is wrong with my code. I receive the values entered at the command line, I ask the user for text, I validate the command line values as characters of the alphabet and ...
0
votes
1answer
19 views

Can't get PSET2 Caesar to compile

I'm having trouble getting my version of Caesar to compile. It keeps saying: error: use of undeclared identifier 'n' for (int i = 0; n = strlen(unencrypted); i < n; i++) I thought maybe I was ...
0
votes
1answer
21 views

cs50 Pset2 *Spoiler*

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { //create key string key = ...
0
votes
1answer
17 views

PSET2 - Why do I get the errors in the check50?

My code: #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> bool validate (string key); int main(int argc, ...
0
votes
1answer
15 views

PSET2 substitute

Why do I only get the corresponding key for A and B and not c and d with my code? #include <cs50.h> #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { ...
0
votes
1answer
17 views

readability - resulting grade is incorrect

#include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <math.h> int main(void) { string text = get_string("Text: "); ...
1
vote
2answers
54 views

I truly confused on why ceaser won't work,

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0
votes
1answer
16 views

I've been trying to submit ceaser and it won't compile can someone help?

#include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <ctype.h> #include <stdlib.h> //atoi ? bool is_valid_key( string s); // ...
0
votes
1answer
34 views

Getting a “seg fault” on Caesar, Pset2

This is my code for Ceasar (pset2) of cs50. Whenever I try to make the program, I get a control may reach end of non-void function Could you help me with this? #include <stdio.h> #include <...
0
votes
1answer
41 views

Caesar prints out the desired output but fails the check50

I managed to write the code for caesar and it presents the desired values as output. However, when I execute check50, apart from a smiley on all other points, this is what I get: :( handles non-...
0
votes
1answer
15 views

Pset2 Substitution My code working when I use debugger and does not working thorough console or test. What am I doing wrong?

Sorry for my English( I am learning. 1.I have make this code, but when I have wrote "isduplicate" function it makes uncatchable bug. Code work as my expectetion only in debugger. So where is ...
0
votes
1answer
21 views

Pset 2 - Readability -> Wrong grade

I'm having problems with the Pset 2 problem: readability. The goal of exercise is to implement a program that computes the approximate grade level needed to comprehend some text using the Coleman-Liau ...
0
votes
1answer
20 views

Substitution Just can't handle invalid keys

My code - #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool check_distinct_char(string s); bool check_char(string s); ...
0
votes
1answer
19 views

pset2 substitution unable to identify string which has character repetition

Here is my code- #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool check_distinct_char(string s); bool check_char(...
0
votes
1answer
12 views

pset2 substitution checking if all the characters in the key are different

I have almost finished substitution. Just that I have not yet been able to come up with a elegant way to check if all the characters in the key are distinct hence I used the following way to check if ...
0
votes
1answer
37 views

caesar pset 2 non-numeric key error even when it works well when i try it myself

Here is my code which works well even with non-numeric key. #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <ctype.h> #include <string.h> bool key_check(...
0
votes
1answer
23 views

Caesar Code Complies when I think it shouldn't

One of the lines of my code is this - if (isupper(plaintext[j])) { int cap_end = (plaintext[j] - (int) 'A' + atoi(argv[1]))%26 + (int) 'A'; printf("%c", (char) cap_end)...
0
votes
1answer
37 views

Errors in Caesar pset2 and Wrong Output

I am almost finished with Caesar only a couple of issues persist which I am unable to overcome Here is my code - #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <...
0
votes
1answer
28 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
1answer
27 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> #...
1
vote
2answers
51 views

pset2 - readability - grades slightly off

I have a problem that I have not been able to diagnose on my own or by perusing this stack overflow. The the tests are here. All of the index values are correct except for the grade seven sentence ...
0
votes
2answers
35 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
24 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
2answers
24 views

substitution behaves randomly strange

I am working on the main part of the problem. The previous checks all pass ( checking if two arguments, if key is 26 lenght, if key is only alphabetical chars and if every char is only once). But the ...
0
votes
1answer
35 views

why am i getting a non numeric key error? cs50 caesar

i have been trying to do this for a month and i am finaly down to my last error message when i run my check 50.the error message is :( handles non-numeric key timed out while waiting for program to ...
0
votes
1answer
15 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
1answer
27 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
35 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
0answers
17 views

In pset2: why i am able to iterate through the for loop for just one ? and also the program is processing after looping once?

#include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> int main(void) { string str= "Hello"; int l =strlen(str); string str2[l-1]; ...
0
votes
1answer
21 views

Pset2 Readability error: expected identifier or '('

I've been trying to compile this code but always get this error "error: expected identifier or '(' " for the line 13 (which is the first one starting with "for") COuld someone help ...
0
votes
1answer
19 views

Pset2 Readability error with “else” statement

readability.c:28:9: error: expected expression else: Shown above is the error I am getting. If anyone would point me to what exactly I am doing wrong. that would be great. Bellow, I will add my ...
0
votes
0answers
7 views

не получается справиться с этими объявлениями-ошибками

:) caesar.c exists. :) caesar.c compiles. :( encrypts "a" as "b" using 1 as key expected prompt for input, found none :( encrypts "barfoo" as "yxocll" using 23 ...
0
votes
1answer
32 views

pset2 mathematical IF statement : attempt

#include <stdio.h> #include <string.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #include <cs50.h> int main ( int argc, ...
0
votes
1answer
19 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 "...
0
votes
1answer
36 views

Pset2 Readability Not Working

I need help in executing the program here. This is my program and when I execute it, it asks me for a text. I copy-pasted the first HOW TO TEST YOUR CODE "One fish. Two fish. Red fish. Blue fish.&...
0
votes
1answer
25 views

pset2 Readability: reading index being calculated incorrectly even though hard sentence, word and letter numbers are correct

The indexes come out sometimes too low,some times too high and I don't really understand why if the variable calculations come out right every time. Here's my code for it: //calculates average letters ...
0
votes
2answers
36 views

PSET2: Readability code giving wrong grades

My Readability code keeps on creating the outputs of the wrong grade when I try to execute it. When inputting the text, 'When he was nearly thirteen, my brother Jem got his arm badly broken at the ...
1
vote
1answer
52 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 { ...
0
votes
1answer
45 views

Caesar Cipher - output not valid ASCII text

I am using character array and none of the test cases matches the result. Please help me find what is missing. :) caesar.c exists. :) caesar.c compiles. :( encrypts "a" as "b" ...
1
vote
1answer
70 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
55 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
33 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
71 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
30 views

PSet2 / Substitution

I am trying to make an upper case key and a lower case key of the one typed by the user but when I use the toupper and tolower functions they turn all my chars into lower or upper. Not just the one I ...
0
votes
1answer
33 views

Pset2 Readability undeclared identifier error message

I am attempting to make my program but everytime I try, it tells me I have not identified my variable "i" eventhough I identified it as an integer above. Does anyone know what I'm doing ...
0
votes
2answers
38 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
32 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 ...

1
2 3 4 5
25