# C Exercises: Find the integer that appears the least often

## C Basic-II: Exercise-1 with Solution

Write a C program that takes n number of positive integers. Find the integer that appears the least number of times among the said integers. If there are multiple such integers, select the smallest one.

**Sample Date:**

(1,2,3) -> 1

(10, 20, 4, 5, 11) -> 4

**C Code:**

```
#include <stdio.h>
int ctr[101];
int num;
int main()
{
int i,x,min_num,result;
printf("What is the number of integers you wish to input? ");
scanf("%d",&num);
printf("Input the number(s):\n");
for(i=0;i<num;i++)
{
scanf("%d",&x);
ctr[x]++;
}
min_num = 100;
for(i=1;i<=100;i++)
{
if( ctr[i]>0 && ctr[i]<min_num)
{ result=i;
min_num=ctr[i];
}
}
printf("Smallest among the said integers: %d\n",result);
}
```

Sample Output:

What is the number of integers you wish to input? 3 Input the number(s): 1 2 3 Smallest among the said integers: 1

**Flowchart:**

**C Programming Code Editor:**

** Contribute your code and comments through Disqus.**

**Previous C Programming Exercise:** C Basic Part-II Exercises Home

**Next C Programming Exercise:** Reverse a string partially.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

## C Programming: Tips of the Day

**What's an object file in C? **

An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)

A linker takes all these object files and combines them to form one executable (assuming that it can, i.e.: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (-c is a common "just compile; don't link" option.)

Ref : https://bit.ly/3CbzF8M

**Exercises: Weekly Top 16 Most Popular Topics**- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- JavaScript basic - Exercises, Practice, Solution
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- JavaScript conditional statements and loops - Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation