0

I am having a VERY difficult time assembling any of these psets past "Hello, world" I under stand pieces but do not understand assembly or structures. example:

do { } while(); I have put in and taken out everything in these curlies and brackets and still have yet to make this work. And the hash tag pyramid I have looked at working code and do not see at all WHY it works. I have watched and re watched lectures and am getting very frustrated because I love the problem solving aspects and code writing. PLEASE HELP!

1

If you want to supplement CS50 you The New Boston goes through C on a very basic level. He is also good at explaining the basic concepts. A lot of the learning will come from persevering and eventually things will just click into place as you hear different ways people explain the same concepts.

https://www.youtube.com/watch?v=2NWeucMKrLI&list=PL6gx4Cwl9DGAKIXv8Yr6nhGJ9Vlcjyymq

Here is a simple do while loop. You can paste this code into a file and run it to see what it does.

#include <stdlib.h>
#include <stdio.h>
#include <cs50.h>


int main ()
{
    // Initialise int i as 0
    int i = 0;

    // Code between curly braces {} will run at least once before the while() condition is checked.
    do {
        printf("Loop number: %i\n", i);
        // i will increment by 1 for each iteration of the loop (including the first iteration).
        i++;
    }
    // while condition is between parenthesis ()
    // Once i is no longer less than 5 the while condition becomes false and breaks out of the loop.
    while(i < 5);
}
| improve this answer | |
0

Have you tried watching additional walkthrough videos on YouTube? https://www.youtube.com/watch?v=E3Oz3AjCYoQ They explain how to work through the problems in much greater detail.

| improve this answer | |
  • Thanks Anna it is starting to come together. Details like why in some code does the while end of the loop look like }while (i < 5); and others the curly brace is placed as you did? Why does some code have return 0; others don't? For the Pset1 mario I found a working code, printed it out and am dissecting it and translating syntax to proper english. That is how I need to see this. – Warren Muzak May 19 '17 at 14:57
0

Since you don't understand the positioning of braces and other stuff, you might be lacking the knowledge of syntax of the language.

Though these syntax of the language do not affect your programming logic cause these syntax varies with the languages you use.

I would suggest you a good book on language you use (C in this case) to better understand the power of the language you are using and their syntax so that you can exploit those power to your advantages in your program.

Suggested book: The c language by Brian kernighan and Dennis M. Ritchie

Note: Remeber to learn by doing.

| improve this answer | |
  • Thank MIB, yes the Syntax is an issue, I am in a loop watching the Week 1 lecture. I am told by a working programmer that C is no longer used and Python is the standard. Even if thats true I still feel the need to understand the fundamentals of C in order to be confident in learning the rest. At this point I don't care about CS50 grades i just want to understand this language as i am REALLY enjoying working through it. – Warren Muzak May 20 '17 at 20:49
  • No Problem Warren. Anytime for help. – MIB May 21 '17 at 11:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .