Sunday, August 30, 2020

positive.c

#include <cs50.h>
#include <stdio.h>

int get_positive_int(void);

int main(void)
{
int i = get_positive_int();
printf("The positive integer you entered is: %i\n", i);

}


get_positive_int(void)
{
int n;

do
{
n = get_int("Enter a positive integer:\n");
}while(n<1)

return n;

}








No comments:

Post a Comment