I'm trying to write a C program which reads three integers, where if any two of those integers equal the remaining integer, it will print all integers within 1 and 10. If not, it will ask for three more integers and print the number of integers that are divisible by 6. This is my program, but it looks long-winded. Is there a cleaner way to do it? Thanks.
#include<stdio.h>
int main(){
int x,y,z;
printf("Enter three integers.\n");
scanf("%d %d %d", &x, &y, &z);
if(x + y == z){
printf("1, 2, 3, 4, 5, 6, 7, 8, 9");
}
else if(x+z == y){
printf("1, 2, 3, 4, 5, 6, 7, 8, 9");
}
else if(y+z == x){
printf("1, 2, 3, 4, 5, 6, 7, 8, 9");
}
else {
int a, b, c, count;
count = 0;
printf("Type in three more integers.\n");
scanf("%d %d %d", &a, &b, &c);
if(a%6 == 0){
count++;
}
if(b%6 == 0){
count++;
}
if(c%6 == 0){
count++;
}
printf("%d integers are divisible by 6.", count);
}
}