# C Program to Find Missing number in Array

Write a c program to find missing number in array. Given an array of numbers from 1 to n. The array is sorted. One number is missing from an array. You have to write a c code to find the missing number from an array. Also ,there is no duplicates in an array. This type of questions is generally asked in technical interviews

There are multiple approaches to solve this problem. Here, I am going to explain two approaches to solve this problem and both the solution take O(n) time complexity.

Programming Questions on Array

## How to Find Missing Number in Array

Logic

Subscribe Our Tutorials

1. As per problem statement, we have an array of 1 to n numbers and there is no duplicate number in an array. One number is missing from an array and we have to find it.

Let’s first calculate the sum of 1 to n numbers. We can calculate easily by using sum of the series formula.

2. In next step, add all the numbers of an array. Let’s take the value of n = 100.

Now, we have the sum of 100 numbers and sum of all the numbers of an array.

If we subtract the sum of 100 numbers to the sum of all the numbers in an array we get the missing number.

Time complexity of this problem is O(n).

## C Program to Find Missing Number in Array 