Questions tagged [loops]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
2answers
23 views

rejects a height of 9, and then accepts a height of 2 expected “” #“\n”##“”, not “”

This is my solution for the cs50 pset1 (less). Passes ok all the test cases except for the "9 then 2" case. I tried it in the IDE myself and after passing 9 and the any other integer the ...
0
votes
1answer
44 views

Mario Less Loops doubt and code review

I have attempted the PSET 1 of 2020 CS50x and have a couple of doubts. Could someone check if the following code for Mario less one is correct. If it is I also had a question that what should I put ...
0
votes
0answers
28 views

Week 1 Super Mario Level 2

All, I have Mario built if I input numbers 1-8. However I can't get it to run a second time or re-run if I put in a number like 9. I think I need to have a loop to return it to the top. Have tried ...
0
votes
0answers
9 views

Debugger question- stop after a certain number of loops?

I'm working on pset4, and my code keeps messing up after the second jpg. I want to use the debugger to check it, so I set a breakpoint on the first line of my main do-while loop. However, each time I ...
0
votes
1answer
14 views

Pset 2 - loop question

im trying to make it so my program returns Success after it checks whether the provided argument is all digits. i can see why this code prints success 3 times if i provide a 3 digit number as the ...
0
votes
2answers
269 views

While Loop in C only executing once and then stopping

I have created a function in C that tests if an integer in between a range of 100 (min) and 500 (max) - The function calls on another function called "getInt()" which tests whether the integer is ...
0
votes
1answer
18 views

Selection Sort: Holes in Logic

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { string s = get_string("Enter a number: "); string answer ...
0
votes
1answer
43 views

Infinite loop in pset2 Initials

#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> int i; int main (void) { printf("Your Name: "); string s = get_string(); if (s !=NULL) { printf("%...
0
votes
2answers
190 views

pset2 initials.c, returning first initial

I originally used a for loop (for(int i = 0, n =strlen(name); i < n ; i++), but decided to try a while loop setting i=1. Either way my output is always limited to the first character. I've tried ...
1
vote
0answers
637 views

Every 2nd digit on Pset1 Credit problem: Tldr bolded

Im struggling with manipulating the string of numbers in the credit problem. I've figured out how to divide the initial input number by 10 (*100 each iteration) then mod % by 10 in order to access the ...
0
votes
1answer
61 views

Resize.c is not copying pixels correctly

I have been stuck on this problem for over a week now. I can not seem to get the inner for loops to correctly copy and place the pixels from the infile.bmp to the outfile.bmp. I am able to created the ...
0
votes
1answer
76 views

Understanding for loops and lingering questions I need answered before moving on!

I coded this and it passes. I just want to understand it much better than I do at this moment. I got hung up on a few of things and found the solutions online to those questions I was having but I ...
0
votes
1answer
80 views

PSET 4 - Recover.c only recovering one empty file

My code compiles and actually recovers 1 single image, an empty one, then it quits. I suspect the issue is related to the amount of bytes I'm reading from card.raw, but I can't be sure. I tried moving ...
0
votes
2answers
178 views

pset1 mario Initializing for loop from GetInt

I'm running the Mario program and I have everything working except the correct count, which I can fix. The only issue I'm having is a syntactical one. I'm tying to initialize the "for loop" with the ...
0
votes
1answer
23 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]? ...