Сначала Вот исправленный ответ для вашей логики
#include<stdio.h>
int issumof2(int data[], int size, int number);
int inarray(int data[], int size, int number);
int size=7,sum2;
int main()
{
int data[7];
int i, number=1;
printf("Enter 7 numbers: ");
for (i = 0; i < size; i++)
scanf("%d", &data[i]);
//I am a little confused about this part. I wasn't sure how to write it.
while(inarray(data, size, number)==1 || issumof2(data, size, number)==1)//till functions are false
{
number=number+1;
}
printf("Smallest positive integer: %d\n", number);
return 0;
}
int issumof2(int data[], int size, int number)
{
int i, j, sum = 0;
for (i = 0; i < size; i++)
{
sum2 =data[i]+data[i];
for (j = 0; j < size; j++)
{
sum = data[i] + data[j];
if (sum==number || sum2==number) {
return 1;
}
}
}
return 0;
}
int inarray(int data[], int size, int number)
{
int i;
for (i = 0; i < size; i++)
{
if (number == data[i]) {
return 1;
}
}
return 0;
}
Также я подготовил еще один набор кода, объясняющий ваши ошибки.Надеюсь, это поможет вам выучить
#include<stdio.h>
int issumof2(int data[], int size, int number);
int inarray(int data[], int size, int number);
int size=7,sum2; // Size has be changed from 3 to 7 , since you want to check the for 7 numbers
int main()
{
int data[7];
int i, number=0;
printf("Enter 7 numbers: ");
for (i = 0; i < size; i++)
scanf("%d", &data[i]);
//I am a little confused about this part. I wasn't sure how to write it.
// while(inarray(data, size, number)==0 && issumof2(data, size, number)==0)//till functions are false
// I feel its best to check the followin way
// If any one of the condition is true, then that is not the required number, so increment it
// else leave the loop which is the required number
while(inarray(data, size, number)==1 || issumof2(data, size, number)==1)//till functions are false
{
number=number+1;
//printf("Smallest positive integer: %d\n", number);
// You will print the required number after the loop, not inside the loop
}
printf("Smallest positive integer: %d\n", number);
return 0;
}
int issumof2(int data[], int size, int number)
{
int i, j, sum = 0;
for (i = 0; i < size; i++)
{
sum2 =data[i]+data[i];
for (j = 0; j < size; j++)
{
sum = data[i] + data[j];
// if (sum==data[i] || sum2==data[i])
if (sum==number || sum2==number) // You are supposed to check the Sum with Number. Not with data irself
return 1;
// else
// return 0; // Returning 0 here is not correct, It should be returned if all the condition are failed.
}
}
return 0; // Correct place to return 0;
}
int inarray(int data[], int size, int number)
{
int i;
for (i = 0; i < size; i++)
{
// if (i == data[i])
if (i == number) // You are supposed to check with numbner not with data itself
return 1;
// else
// return 0; // You are not supposed to return 0 here. Return is after all the condition is failed
}
return 0; // Corect place to return 0
}