# What do I do when there's more than 1 mode?

This is a discussion on What do I do when there's more than 1 mode? within the C Programming forums, part of the General Programming Boards category; Hi. My program is supposed to find the average & mode of a set of 6 integers. This is what ...

1. ## What do I do when there's more than 1 mode?

Hi. My program is supposed to find the average & mode of a set of 6 integers. This is what I have:

PHP Code:
``` #include<stdio.h> int main() {     int temp[6], i, avg, mode;     printf("Enter 6 integers: *REMEMBER TO PRESS ENTER BETWEEN EACH INTEGER!* ");     for(i=0; i<6; i++){         scanf("%d", &temp[i]);     }     /*average*/     avg = 0;     for(i=0; i<6; i++){         avg = avg+temp[i];}     printf("Average temperature: %d\n", avg/6);                 /*mode*/     for(i=0; i<6; i++){         if(temp[i]== temp[i+1]){             mode=temp[i];             }         else{             mode=0;}     }     printf("Mode is: %d\n", mode);     return 0;     }  ```
The problem is that if there should be two modes(ex. 2, 4, 8, 4, 6, 8) it will only display one of them. Any advice how to correct this problem is greatly appreciated.

Thank You.

2. maybe a frequency table would help. Here is an example then check for more than one in the table.