How can I check if two numbers from a sequence are lower than 5?
The function needs to get a sequence and check if a sum of any of the numbers are smaller than 5. I’m having truble to figure how I can get the first two values because at first there is always one.
int check_if_under_5(int Knum)
{
int sequence=0, Anum=0, Bnum=0;
printf("Enter a sequence. To stop print, enter -1\n");
while(sequence != -1)
{
Anum = sequence;
scanf("%d",&sequence);
Bnum = sequence;
if (Anum + Bnum < 5)
return 1;
else
sequence = Anum;
}
return 0;
}
smallest_so_far + new_element < 5. If so, return true.smallest_so_farif necessary and continue with the next element.