Skip to content

Instantly share code, notes, and snippets.

@DeclanGas
Created June 23, 2022 15:06
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/bcf9fb529ec118f4f3337c8c28c3f48e to your computer and use it in GitHub Desktop.
Save DeclanGas/bcf9fb529ec118f4f3337c8c28c3f48e to your computer and use it in GitHub Desktop.
#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;
// declare an int c and assign it the value of a times 5
int c = a * 5;
// declare an int d and set it to a divided by 4
int d = a / 4;
// declare an int e and assign it to the remainder after dividing a by 4
int e = a % 4;
// declare a float f and set it to a divided by 4.0
float f = a / 4;
// printing the results
printf("%i plus 3 is %i\n", a, b);
printf("%i times 5 is %i\n", a, c);
printf("%i divided by 4 is %i\n", a, d);
printf("%i mod 4 is %i\n", a, e);
printf("%i divided by 4.0 is really %.2f\n", a, f);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment