Repeating and Missing numbers: You are given an array of size N. It contains numbers in the range 1-N(Both inclusive). One of these numbers is repeating and one is missing in the array.
Write a program to display these 2 numbers. The output should be the missing number followed by the repeating number separated by a space.
Repeating and Missing numbers
Input:
5 1,3,3,4,5
Output:
3 2
Solution
#include<stdio.h>
#include <stdlib.h>
void repeatingMissing(int arr[], int n)
{
//write your code here
int i;
for (i = 0; i < n; i++) {
int abs_val = abs(arr[i]);
if (arr[abs_val - 1] > 0)
arr[abs_val - 1] = -arr[abs_val - 1];
else
printf("%d ", abs_val);
}
for (i = 0; i < n; i++) {
if (arr[i] > 0)
printf("%d", i + 1);
}
}
int main(){
int n;
scanf("%d",&n);
int arr[n];
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
repeatingMissing(arr,n);
}Happy Learning – If you require any further information, feel free to contact me.

![[Solved] Search In Rotated Sorted Array Problem](https://realcoder.techss24.com/wp-content/uploads/2022/06/Solved-Search-In-Rotated-Sorted-Array-Problem-300x200.png)
![[Solved] Polynomial Addition using Linked List with C](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Polynomial-Addition-using-Linked-List-with-C-300x200.png)
![[Solved] Lewis is working on a game designing project called as Ball Blast Java, C++, Python, JavaScript](https://realcoder.techss24.com/wp-content/uploads/2022/10/Solved-Lewis-is-working-on-a-game-designing-project-called-as-Ball-Blast-Java-C-Python-JavaScript-300x201.png)