Skip to content

Instantly share code, notes, and snippets.

#include <cs50.h>
#include <stdio.h>
# define NUM_DAYS 5
int main(void)
{
int hours[NUM_DAYS];
// write a for loop to prompt for the number of hours for each day
#include <cs50.h>
#include <stdio.h>
int result;
int get_positive_int(string prompt)
{
do
{
result = get_int("%s", prompt);
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int height;
do
{
height = get_int("Height:");
#include <cs50.h>
#include <stdio.h>
#define ONE_YEAR 1
#define age a
int main(void)
{
// Prompt user for age
int age = get_int("Enter your age: ");
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int total = 0;
for (int i = 0; i <= 10; i++)
{
total += i;
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int number;
// write your do-while loop here to accept input between 0 and 10
do
#include <cs50.h>
#include <stdio.h>
int main(void)
{
int n = get_int("Enter a number: ");
int counter = 0;
// add your code here
while (n < 100)
#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
if (grade > 89 && grade < 101)
#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
int b = a + 3;
#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: ");