Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
503 B
13
Indexable
Never
#include <stdio.h>
int Ask(int n){
    int returnVal;
    printf("Enter positive integer %d: ",n);
    scanf("%d", &returnVal);
    while(returnVal <= 0){
        printf("Enter positive integer only, please\n");
        printf("Enter positive integer %d: ",n);
        scanf("%d", &returnVal);
    }
    return returnVal;
}
int main(){
    int first, second, third;
    first = Ask(1);
    second = Ask(2);
    third = Ask(3);
    printf("The sum is %d\n", first + second + third);
}