Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please use C, thank you! Write a program to find the smallest positive integer that does not appear in the array and cannot be formed
Please use C, thank you!
Write a program to find the smallest positive integer that does not appear in the array and cannot be formed by the sum of two numbers in an array. For this assignment implement the following function int issumof2(int data[], int size, int number) int inarray((int data[], int size, int number) The function issumof2 returns 1 if the number is sum of 2 elements in the array data and returns 0 otherwise, size is the number of elements in the array. The function in array returns 1 if the number appears in the array data and returns 0 otherwise, size is the number of elements in the array. An example is given in figure 1. 1, 2, 3 and 4 appear in this array. 4 can be formed as 4+1, 5 as 3+2, 6 as 3+3, 7 as 3+4 and 8 as 4+4 (it is ok to use a number twice). 9 does not appear in the array and it cannot be formed as sum of 2 numbers in the array. So, 9 Is the solution for this array. Read an array of size 7 from the user, compute the smallest positive integer that does not appear in the array or cannot be formed by the sum of two numbers in an array, and print the result. Sample execution is given below Enter 7 numbers 1 2 2 3 4 3 1 Smallest positive Integer = 9Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started