Need Help! Harvard's CS50 Problem Set 1: C _Itsa Mario

9:46:00 AM

After CS50 Week 1 Wednesday & Friday

Where to find problem set 1:C?


What's my result?

















How did it check out?















The code doesn't seem like to be 100% checked out. But it worked when I manually put these numbers in there. I am wondering what I did wrong in my code. Please comment below to help! Thank you!


























What did I learn?
or is ||
do-while loop & for loop

I know that for loop could be simply write as follows:
for (initialization; condition; update)
{
    //code inside
}
//code outside

But I still would like to explian it to myself in the notes for better understanding.
for (initial status of condition A; under what condition action B would act; how would condition A change after action B act )
{
    //code inside
}
//code outside


What was my reference?

C Program To display the pyramid of * and digits
Write a C program to print pyramid using *.
        
        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *

#include <stdio.h>
int main()
{
    int i,space,rows,k=0;
    printf("Enter the number of rows: ");
    scanf("%d",&rows);
    for(i=1;i<=rows;++i)
    {
        for(space=1;space<=rows-i;++space)
        {
           printf("  ");
        }
        while(k!=2*i-1)
        {
           printf("* ");
           ++k;
        }
        k=0;
        printf("\n");
    }
    return 0;
}

You Might Also Like

3 comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. NICE GREAT INFO ..!! WROTE MOST PATTERN PROGRAMS IN C ..WHICH WILL BE HELPFUL
    https://www.techgeekbuzz.com/pattern-programs-in-c/

    ReplyDelete

Popular Posts

Like us on Facebook

Flickr Images

Subscribe