Question

write a program that finds a random missing number in an unsorted list of numbers

write a program that finds a random missing number in an unsorted list of numbers

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// This code In C

/* GetMissingNumber Function takes array and size of array as arguments*/

int GetMissingNumber (int a[], int n)

{

    int i, total;

    total = (n+1)*(n+2)/2;   

    for ( i = 0; i< n; i++)

       total -= a[i];

    return total;

}

  

/*program to test above function */

int main()

{

// note that this code for positive inter

    int a[] = {1,2,4,5,6};

    int missNumber= GetMissingNumber(a,5);

    printf("%d", missNumber);

}

please comment for further information

Add a comment
Know the answer?
Add Answer to:
write a program that finds a random missing number in an unsorted list of numbers
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT