- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write C Program to Delete duplicate elements from an array
Program : To delete duplicate elements in an array
#include <stdio.h>
int main() {
int arr[20], i, j, k, size;
printf("\nEnter array size : ");
scanf("%d", &size);
printf("\nAccept Numbers : ");
for (i = 0; i < size; i++)
scanf("%d", &arr[i]);
printf("\nArray with Unique list : ");
for (i = 0; i < size; i++) {
for (j = i + 1; j < size;) {
if (arr[j] == arr[i]) {
for (k = j; k < size; k++) {
arr[k] = arr[k + 1];
}
size--;
} else
j++;
}
}
for (i = 0; i < size; i++) {
printf("%d ", arr[i]);
}
return (0);
}
Output :
Enter array size : 5
Accept Numbers : 1 3 4 5 3
Array with Unique list : 1 3 4 5
- Related Questions & Answers
- How to reads customer number and power consumed and prints amount to be paid using C
- How to read the values of x, y and z and print the results expressions in one line using C Program
- Write C program to find Exponent Power Series
- How to Calculate Area of Right angle Triangle using C Language
- Write C Program to Find Factorial of Number Using Recursion
- How to check the type of triangle using C
- Recursive program to linearly search an element in a given array using C
- How to Find Area of Scalene Triangle using C
- How to Solve Second Order Quadratic Equation Using C Program
- Write C Program to Merge Two arrays in C Programming
- Find Second largest element in an array using C Programming
- Write C Program to Reversing an Array Elements in C Programming
- Write a C program using pointers to read in an array of integers and print its elements in reverse order.
- How to Calculate Area of Equilatral Triangle using C Language
- Write C Program to Calculate Addition of All Elements in Array
- Write C Program to Find Largest Element in Array in C Programming
Advertisements
ads