Quote (Aimed_Shot @ Dec 2 2014 06:33pm)
It would only print it once. Notice the return statement
Code
#include <stdio.h>
#include <stdlib.h>
void main(void){
int num[5], i, j, k=0;
int temp = 0;
//read five integers
for (i=0;i<5;i++){
printf("Enter an integer: ");
scanf("%d", temp);
if (repeatedNumber(temp, i, &num)) {
printf("Repeated number: %i", temp);
break;
}
}
}
bool repeatedNumber(temp, i, int *num[]) {
for (int j=0; j < i; j++) {
if (temp == num[j])
return true;
}
num[i] = temp;
return false;
}
Interesting. I will have to check it out some more and try to understand it.

This is what I got and it works as well.

Code
#include <stdio.h>
#include <stdlib.h>
void Repeatednumber(int num[], int repeated[]);
void main(void){
int num[5], repeated[2]={0}, i;
for (i=0;i<5;i++){
printf("Enter an integer: ");
scanf("%d", &num[i]);
}
printf("\nRepeated Numbers: ");
Repeatednumber(num, repeated);
printf("\n");
system("pause");
}
void Repeatednumber(int num[],int repeated[]){
int i, j, k=0;
for(i=0;i<=4;i++){
for(j=i+1;j<=4;j++){
if (num[i]==num[j]){
if(num[i]==repeated[0]){
continue;
}
repeated[k] = num[i];
k=1;
}
}
}
if(repeated[0]==0&&repeated[1]==0){
printf("There are no repeating numbers.");
}
else if(repeated[0]!=0&&repeated[1]==0){
printf("%d", repeated[0]);
}
else{
printf("%d and %d", repeated[0], repeated[1]);
}
}