Untitled
unknown
plain_text
3 years ago
1.1 kB
11
Indexable
#include <stdio.h>
int main() {
int first = -1, second = -1, third = -1;
while(first <= 0){
printf("Enter positive integer 1 : ");
scanf("%d", &first);
if(first <= 0)
printf("**Positive integers only, please\n");
}
while(second <= 0){
printf("Enter positive integer 2 : ");
scanf("%d", &second);
if(second <= 0){
printf("**Positive integers only, please\n");
continue;
}
if(first > second){
printf("**Less than number 1\n");
second = -1;
}
}
while(third <= 0){
printf("Enter positive integer 3 : ");
scanf("%d", &third);
if(third <= 0){
printf("**Positive integers only, please\n");
continue;
}
if(first > third){
printf("**Less than number 1\n");
third = -1;
continue;
}
if(second > third){
printf("**Less than number 2\n");
third = -1;
continue;
}
}
printf("The sum is %d\n", first + second + third);
return 0;
}Editor is loading...