Created
July 20, 2016 07:00
-
-
Save knifedge/c142f6ff3566fcf8ea00e64b7a1edf35 to your computer and use it in GitHub Desktop.
duplicate in an array of size n with numbers from 1 through n-1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N 5 | |
int main(){ | |
int array[N],i,Asum=0; | |
int sum = (N *(N-1))/2; | |
printf("Enter %d integer from 1 to %d,with one duplicate:"N.N-1); | |
for(i=0;i<N;i++){ | |
scanf("%d",&array[i]); | |
Asum = Asum+array[i]; | |
} | |
printf("\nDuplicate number is : %d\n",Asum-sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment