Questions tagged [week2]
The week2 tag has no usage guidance.
40
questions
0
votes
2
answers
26
views
Problem set 2 , Passes all tests when submitted but only give 2/11 grade
check50 results in all the tests passing but also produces a repetitive error, Invalid key. Please provide a positive integer. Cause Timed out while waiting for program to exit. Not sure which line ...
1
vote
1
answer
814
views
password week 2 practice problem
This is a part of my code (a boolean function) ,so the goal is to return true or false.
It's working pretty well, but I was wandering if there were a better way.
Instead of using those integers, is ...
2
votes
1
answer
472
views
iterate pagerank issue in cs50ai pagerank project
My PageRank results from iteration come up more than .001 off the initial sampling result but I am not sure where I went wrong. please see code below followed by results. Any help would be greatly ...
0
votes
1
answer
23
views
Understanding arrays, pointers with an example
/* day_mon1.c -- prints the
days for each month */
#include <stdio.h>
#define MONTHS 12
int main(void)
{
int days[MONTHS = {31,28,31,30,31,30,31,31,30,31,30,31};
int index; for (index = 0;
...
0
votes
1
answer
38
views
runtime error in sandbox for array examples from week 2 lecture
This is confusing me a little and I want to fully understand it before moving through the rest of the lecture. I usually code alongside David's examples on screen and was trying to understand why this ...
0
votes
1
answer
42
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
1
answer
879
views
Can I reset all my progress for Week 2 in cs50 IDE?
I am starting the Hello project for cs50 and I made a small mistake in my starting code. In attempting to fix my error, I dug myself deeper into a hole (or a chasm) of mistakes. I think it would be ...
0
votes
1
answer
95
views
Week 2 Lecture - Functions - Valid Triangle
This is from the functions lecture on a valid triangle. I'm not getting any error messages but I can't figure out why the
bool valid_triangle (float x, float y, float z)
function is not working. Any ...
1
vote
1
answer
249
views
Week 2 passing array example problem?
Hi, I have problem understanding the concept of 'passing an array by reference instead of value' and I cant understand this example. Can anyone explain to me why does it take 10, 22 as final answer?
0
votes
1
answer
34
views
Expected expression on "valid triangle" exercise? i thought the 'or' symbol was 2 lines ( || ) what have i done wrong here?
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
// PROTOTYPE THE FUNCTON
bool valid_triangle(float input1, float input2, ...
0
votes
2
answers
34
views
Can anyone tell me what ive done wrong and breakdown how to properly prototype and deploy created functions?
code:
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
// PROTOTYPE THE FUNCTONS & DECLARE VARIABLES
int multiply(int ,...
1
vote
0
answers
48
views
Week2 Help50 Make Buggy0 doesn't work
I executed help50 just like in the lecture(see photo) but it doesn't recognise the file although it is written right:
0
votes
1
answer
268
views
[Week 2 Substitution.Why does my code fail the checks even if the output is correct?
Here is my code.
Apologies if it is hard to understand / messy.
When I check50 it shows this.
I have a brief idea on how to solve the invalid characters in key but I don't mind some help on that too.
...
0
votes
2
answers
37
views
Pset 2 Vigenere - Shift value
I am at the point in pset2 Vinegere, where I have to write the shift function. The tutorial (or guidance on the left side in sandbox) is telling me to place the following line of code after the curled ...
0
votes
3
answers
42
views
Why are algorithms mentioned in week 2
In week 2 David mentions Algorithms e.g. Bubble sort, Binary search etc...
But why are they important? and where do they fit into the bigger picture?
I only did the Caesar cypher and Vigenere cypher ...
0
votes
1
answer
132
views
pset3 Music design and connection to Week 2 lecture?
I have completed all of the work for pset3 Music and it works fine. There are no error messages, I can synthesize the songs, and it passes all the Check50 tests. However I can't shake this nagging ...
0
votes
1
answer
43
views
Week 2 Merge Sort: Why is it assumed that the elements will be in order when they are merged?
When using the Merge Sort algorithm, I feel like everything makes sense until we start "merging" the elements back together. Why is it assumed implicitly that the process of merging will put the ...
0
votes
1
answer
135
views
Enquiry on Week 2's Valid_Triangle
May I ask what does this means? How does %s derive can / cannot ?
**
printf("These %s be the lengths of sides of a valid triangle.\n",
valid_triangle(a, b, c) ? "can" : "cannot");
}
**
0
votes
4
answers
6k
views
I don't understand how the collatz(n) recursive function works
If you watch the short on recursion in week2 2018, Doug explains how calculate the steps for the collatz conjecture.
I don't understand how the solution he proposes can work:
int collatz(int n)
{
...
0
votes
1
answer
69
views
Error wrapping around vigenere
so far the vigenere.c works if the keyword and the plaintext are the same size of characters, but once it tries to wrap around if the keyword is smaller than the plaintext the output goes wrong.
Here ...
0
votes
1
answer
55
views
expected output, but not "MB\n"
check50_more report :
:) initials.c exists
:) initials.c compiles
:) outputs "MB" for "Milo Banana"
:) outputs "MB" for "milo banana"
:( outputs "MB" for " milo banana "
\ expected output, but ...
0
votes
1
answer
87
views
cs50 capitalize0.c from week 2 example problem
I have written the program as in the example of week 2, I can not find anything I have done differently, unfortunately. I have not declared the counting variable i and n, as in the example, however, ...
0
votes
1
answer
97
views
vigenere.c done incorrectly, or check50 broken? [duplicate]
I completed vigenere.c per the spec for pset2, and it seems to be working fine. However, when I use check50, this is the result I get.
So it says everything is fine, however when it checks how the ...
0
votes
1
answer
120
views
Unused variable error when trying to implement the Valid_Triangle function
I am trying to implement the Valid Triangle code, however for some reason I am always getting an unused variable error for the x,y, and z variables in the main function. How do I fix?
#include <...
0
votes
1
answer
78
views
Can you use switch with Vigenere's?
Week 2's switch.c example really appealed to me--found it very clean and easy to read. I did Vigenere's using for loops and if statements and tried to rewrite it using a switch. My code doesn't even ...
0
votes
1
answer
106
views
pset2 How to get rid of spaces in the end of the milo banana_ _ _ _ (input)?
How to get rid of spaces in the end of the input?
My code works perfectly with _ _ milla_ _ _ banana
But I have issues with the case if _ _ _ milla_ _ banana_ _ _
when I have spaces in the end
How ...
0
votes
1
answer
65
views
Problem from Section lesson "Function" but I have the following error message
When I compiled my code for the Section video titled, "Functions" where we were to make and define the function valid_triangle, the following error code was printed:
triangle.c:15:9: error: expected ...
0
votes
1
answer
548
views
Difference between Pass by Value and Pass by Reference (a practical example)
at the end of Doug's video on arrays he explains how variables get passed in function calls in comparison to how arrays work.
void set_array(int array[4]);
void set_int(int x);
int main (void)
{
...
0
votes
1
answer
40
views
Clarification regarding for loops and arrays
In the continued lecture of week2:
At about 17:00 he writes the for loop. What does i stand for? I don't think it is age, but it can't be the number of students? What does it mean?
What is ages[i]? ...
2
votes
3
answers
5k
views
'\0' vs '0' : What's the difference?
2016 version Lecture Week 2 continued...
What's the difference between \0 and 0? I have watched the lectures, but it didn't help.
Thanks in advance!
1
vote
2
answers
2k
views
Floating Point Imprecision
In Week 2 Lecture (the first one), Mr. Malan says a reason for floating - point imprecision (40:00). I don't get his reason. Sorry for the bad question, but please explain...
Thanks in advance.
0
votes
1
answer
44
views
What is an Array exactly?
The short from CS50 is not giving me a clear idea about what an array is exactly. Can someone give me some more information about the array in C?
0
votes
1
answer
236
views
Can anyone give me an example of code without a command-line-argument and code with a command-line-argument?
After watching the lectures, walkthrough and notes of the lectures It is still not clear to me what purpose a command-line-argument got exactly. I hope if someone can give me an example of code with ...
0
votes
1
answer
52
views
2nd Week and 2nd Lecture: Dynamic array
I just took the second lesson of second week, we were taught how to do dynamic integer array, some confusions i need to clear up is when we have initialized an integer and even take the value from ...
1
vote
2
answers
186
views
Why is d = 185 to satisfy de = 1 mod m (where m = 924)? (Wk2, shorts: cryptography)
At the 6:50 min mark of this video: https://courses.edx.org/courses/HarvardX/CS50x3/2015/courseware/c0986764d695405f9d995f43b7c10676/5194906ad75c4edb9ecd401df372b8f3/
here's a screen shot, too: https:...
0
votes
2
answers
35
views
Week 2 walkthroughs ages.c has a bug?
The ages.c code doesn't seem to account for a scenario where user enters a negative integer when prompted for ages.
{
for (int i = 0; i < n; i++)
{
printf("Age of ...
0
votes
0
answers
55
views
Code is not working in CS50 Appliance but working in CODE BLOCKS
EVEN AFTER REPLACING #incluse with #include the code is working in code blocks but not working in cs50 appliance. Please tell me why?
#include<stdio.h>
#include<conio.h>
main( )
{
...
4
votes
3
answers
1k
views
What does if (s != NULL) do?
According to the lecture in Week 2 and the walkthrough video "String", to make sure that the user gives us a valid string we use this condition:
if (s != NULL)
{
//code
}
...
1
vote
2
answers
28
views
Why 'a'-'A', instead of 32
In the lectures and the walkthroughs for Week 2, David goes through a capitalize program. He makes a point of using the subtraction 'a'-'A' rather than simply the value 32 in order to change the case ...
2
votes
4
answers
1k
views
How to calculate modulo?
From the cryptography video short(Week2) , can anybody tell how to compute the value of m = c^d (mod n) ?
How do we find that 658^185(mod 989) equals 67 ?