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
17 views

Readability Wrong Output at Index around 7-8

I have been struggling with Week 2 Problem Set 2 Readability Question. At this point, I feel like I am stuck, and spend too much time just trying to fix one error. The code works perfectly except &...
0
votes
1answer
9 views

pset2- readability

While counting the number of sentences ( Pset 2: Readability) , how do we differentiate between exclamation marks within a sentence and those which are used to end a sentence ? This is my code: //...
0
votes
1answer
15 views

I have included all the libraries, yet it shows errors (pset2)

This is my code: #include <stdio.h> #include <cs50.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main (int argc, string ...
0
votes
1answer
13 views

Can't check CAESAR pset2

I solved the Caesar problem and it works flawlessly. But I can not check it properly. The results are correct but ''' check50 cs50/problems/2021/x/caesar ''' says it is incorrect. If I view the ...
0
votes
1answer
14 views

Check50 problem with Readability

When I submit my readability code check50 says: Expected Output: Before Grade 1 Actual Output: Before Grade 1 Expected Output: Grade 16+ Actual Output: Grade 16+ Since my program outputs what is ...
0
votes
1answer
30 views

Help with Either Command Line Argument or Arrays for Problem set 2 Caesar

I am on Problem Set 2: Caesar. Right now I'm trying to write code that first checks if the second command line argument is a int and if it does prints the integer. I got my program to compile after ...
0
votes
1answer
9 views

float rounds with %2.f

I'm working on pset2 with cash. But something interesting is happening if input is 6.876 and i printf that value of that variable I get 6.88 instead of 6.87. How can I get 6.87 instead of round 6.88? ...
0
votes
2answers
34 views

What modification do I need to shorten my code?

I have come up with the following code to solve caesar.c of pset2. It passes all check50 tests. However, it fails to detect when a string input is not a number. The way I understand it, I have to ...
0
votes
2answers
26 views

Caesar Error:Invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)text + argv[1]) % 26

There are a few errors in my code, but the one I really don't understand is `caesar.c:25:42: error: invalid operands to binary expression ('string' (aka 'char *') and 'int') int c = ((int)...
0
votes
2answers
36 views

Caesar : Extra random characters at the end of a char ciphertext array

I'm having a problem with an output. Sometimes output adds an extra characters, different each time the code runs. For example, when I use key "1" and write "a", it displays "...
0
votes
1answer
20 views

Having Trouble using StrCpy with Command Line argument for Problem Set 2 Caesar. Trouble with Array

Hello I'm still fairly raw at this coding thing so i'm sure im making rookie mistakes. I'm doing Problem Set 2 caesar and I've hit a wall and haven't been able to move forward. What I have been trying ...
0
votes
1answer
13 views

Undeclared identifier error inCS50 Pset2 caeser

I keep getting 2 undeclared identifier errors on these respective lines line 48: printf("ciphertext:%c", ((p[n] - 65 + k) % 26) + 65); line 54: printf("ciphertext:%c", ((p[n] - 65 +...
0
votes
1answer
22 views

pset 3 caesar - output looks fine but check50 returns errors

PS2 caesar to output ciphertext works fine, and outputs all texts as expected - however check50 returns poor score. //Code is: #include <stdio.h> #include <cs50.h> #include <string.h>...
0
votes
2answers
32 views

CS50 Readability compile error

Im trying to compile the program but keep getting this error message below: Can someone tell me what this means please. The carat arrow is supposed to be pointing at "char" and "ch&...
0
votes
1answer
14 views

CS50 readability.c:31:1: error: expected identifier or '(' {

I keep getting this same error message readability.c:31:1: error: expected identifier or '(' { Please Help! I put my program below: #include <stdio.h> #include <cs50.h> #include <math.h&...
0
votes
1answer
19 views

Input Problem in Char 'P' PSET2 Substitution

QUESTION When i put cipheralgorithm (which is a function that is making encryption) in comment section (/*) everything goes perfect i can get input when i type ./substitution ...
0
votes
0answers
24 views

All my functions work individually for Substitution (pset2), but when I put them together the programme doesn't work!

Hey guys :) I've been wracking my brain for ages on my code for pset2 (Substitution) and would really appreciate some help. I've created a function to convert a string into its uppercase variant, ...
0
votes
1answer
27 views

PSET2, Caesar (less)

My code to assess whether the command-line argument consists solely of digits compiles but doesn't work properly, and I can't figure out exactly what the problem is. Even if I enter an integer-only ...
0
votes
1answer
17 views

Segmentation fault: Pset 2 Caeser isdigit

The log is telling me: "Segmentation fault", and after looking into it, I figured out the problem was in the "isdigit", but i don't know how to fix it, i'm here for about 2 hours ...
0
votes
1answer
21 views

Expected output and output are the same, yet the program somehow isn't correct. Caesar

This is my code: for(int i = 0, len = strlen(plaintext); i < len; i++) { char c = plaintext[i]; if (isalpha(c)) { char p = 'A'; if (islower(c)) { p =...
0
votes
1answer
29 views

Why doesn't my Caesar code work?

#include <cs50.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include <stdlib.h> #include <math.h> bool string_validity(string s); int main(int ...
0
votes
1answer
15 views

Caesar scoping. variable len not defined, yet it works

The code is following: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <ctype.h> bool key_validity(string s)...
0
votes
1answer
15 views

PSET2 Substitution: Trouble Encrypting all alphabetic characters

First post, so let me know if anything is wrong with the post. My code passes every test except for this one. :( encrypts all alphabetic characters using DWUSXNPQKEGCZFJBTLYROHIAVM as key expected &...
0
votes
1answer
32 views

:( handles lack of key failed to execute program due to segmentation fault

The following piece of code I've written for pset2/caesar produces a "segmentation error" when there is a lack of key (when no command-line argument is provided). I don't know which line or ...
0
votes
1answer
38 views

I'm stuck at PSet 2 Caesar Cipher: The alphabets don't follow my modulo 26. It goes beyond it, printing non-alphabetic characters

The crux is at the last part where I've commented "CONVERT PLAINTEXT TO CIPHERTEXT" The variable asciiValue holds the, well, the asciiValue of the enciphered character. As you can see, I've ...
0
votes
0answers
37 views

pset2/caesar handles lack of key failed to execute program due to segmentation fault [duplicate]

#include <cs50.h> #include <math.h> #include <stdio.h> #include <string.h> int key(string input); int main(int argc, string argv[]) { int l = strlen(argv[1]); int ...
0
votes
1answer
19 views

How to print the output in Caesar(Pset2)?

here's my code #include <stdio.h> #include <cs50.h> #include <ctype.h> #include <string.h> #include <stdlib.h> int main(int argc, string argv[]) { // prints Usage : ...
0
votes
2answers
35 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
24 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
35 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 ...
-1
votes
1answer
25 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
26 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
18 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
17 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
24 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
66 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
19 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
35 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
51 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
19 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
24 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
22 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
22 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
16 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
41 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
25 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
42 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
37 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
28 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
2 3 4 5
25