Created
June 23, 2022 16:38
-
-
Save DeclanGas/737c3ac01f9dd8231b56216ead21a3c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cs50.h> | |
#include <stdio.h> | |
int result; | |
int get_positive_int(string prompt) | |
{ | |
do | |
{ | |
result = get_int("%s", prompt); | |
} | |
while (result <= 0); | |
return result; | |
} | |
int main(void) | |
{ | |
int n = get_positive_int("Enter a positive number: "); | |
// print the output from our function | |
printf("My positive int is %i.\n", n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment