Basic Programs
If Else based Programs
- Program to check given number is zero,even or odd
- Program to find largest middle and smallest number among three nos
- Program to find the commission based on given sales amount
- Program to calculate the telephone bill on given no of calls
- Program to find grade based on 5 subject marks
- find the freequency of elements in array
Loop Based Programs
Array Based Programs
String Programs
Function Programs
Pointers Programs
Structure & File Handling Programs
Data Structure Programs
Basic C Program
program to count freequency of elements in an array
#include <stdio.h> int main() { int arr[20],fr[20],flag=-1,count=1,i=0,j=0; printf("enter array elements\n"); for(i=0; i<20; i++) { scanf("%d",&arr[i]); } for(i = 0; i < 20; i++){ count = 1; for(j = i+1; j < 20; j++){ if(arr[i] == arr[j]){ count++; //To avoid counting same element again fr[j] = flag; } } if(fr[i] != flag) fr[i] = count; } //Displays the frequency of each element present in array printf("---------------------\n"); printf(" Element | Frequency\n"); printf("---------------------\n"); for(i = 0; i < 20; i++){ if(fr[i] != flag){ printf(" %d", arr[i]); printf(" | "); printf(" %d\n", fr[i]); } } printf("---------------------\n"); return 0; }
Video/ C Introduction
Watch video in full size