Skip to content

Instantly share code, notes, and snippets.

@jmichalenko
jmichalenko / magic.c
Created February 13, 2024 00:40
CS50 Labs Magic Numbers Starter Code
View magic.c
#include <cs50.h>
#include <stdio.h>
#define ONE_YEAR 1
int main(void)
{
// Prompt user for age
int age = get_int("Enter your age: ");
@jmichalenko
jmichalenko / forloop.c
Created February 13, 2024 00:34
CS50 Labs For Loops Starter Code
View forloop.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
for (int i = 0; i < 10; i++)
{
printf("hello, world\n");
}
}
@jmichalenko
jmichalenko / dowhile.c
Created February 13, 2024 00:29
CS50 Labs Do While Loops
View dowhile.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int number;
// write your do-while loop here to accept input between 0 and 10
@jmichalenko
jmichalenko / while.c
Created February 13, 2024 00:23
CS50 Labs While Loops Starter Code
View while.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int n = get_int("Enter a number: ");
int counter = 0;
// add your code here
@jmichalenko
jmichalenko / booleans.c
Created February 13, 2024 00:16
CS50 Labs Booleans Starter Code
View booleans.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// Get grade as a number
int grade = get_int("Enter your grade: ");
// grades between 90 and 100 get an A
printf("You get an A!\n");
@jmichalenko
jmichalenko / operators.c
Created February 13, 2024 00:09
CS50 Labs Operator Starter Code
View operators.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// declare an int variable a and get user input
int a = get_int("Enter a whole number: ");
// declare an int b and assign it the value of a plus 3
@jmichalenko
jmichalenko / placeholders.c
Created February 12, 2024 23:57
CS50 placeholders starter code
View placeholders.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// declare a string animal and get user input
string animal = get_string("Enter a a type of animal: ");
// declare a celestial body and get input
string body = get_string("Enter a celesial body: ");
@jmichalenko
jmichalenko / variables.c
Created February 12, 2024 19:46
CS50 Labs variables starter code
View variables.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// Let's assume my age is 17
printf("Right now I'm %i years old.\n", 17);
// My age next year
printf("Next year I'll be %i years old.\n", 17 + 1);
@jmichalenko
jmichalenko / datatypes.c
Created February 12, 2024 19:40
Datatypes Starter Code
View datatypes.c
#include <cs50.h>
#include <stdio.h>
int main(void)
{
// declare a string named "name" and get input with get_string
string name = get_string("Name: ");
// declare an int named "age" and get user input with get_int
@jmichalenko
jmichalenko / syntax.c
Created February 8, 2024 20:20
syntax with errors
View syntax.c
include stdio.h
{
int main(void)
printf("This is CS50AP!\n")
}