Skip to content

Instantly share code, notes, and snippets.

@DeclanGas
Created June 23, 2022 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeclanGas/f84aa40f65a8d92fb8795f802343be99 to your computer and use it in GitHub Desktop.
Save DeclanGas/f84aa40f65a8d92fb8795f802343be99 to your computer and use it in GitHub Desktop.
#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)
{
printf("You get an A!\n");
}
// grades between 80 and 89 get a B
if (grade > 79 && grade < 90)
{
printf("You get a B!\n");
}
// only grades between 70 and 79 get a C
if (grade > 69 && grade < 80)
{
printf("You get a C!\n");
}
// all other need improvement
if (grade < 70)
{
printf("You need to work harder to pass this class!\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment