Write a program that reads even number from user, computes their average, and finds out how many numbers are below average and displays duplicate numbers.
Answers
Answered by
0
Answer:
Wrote it in C. Hope it helps
Explanation:
#include <stdio.h>
#include <stdlib.h>
main(){
int mat[20]; /* the number is optional. you can define a number also*/
int below_average, i , j, n;
float avg;
avg = 0;
for(i=0;i<20;i++){
printf("Give a number: ");
scanf("%d", &mat[i]);
avg = avg + mat[i];
}
avg = avg/ 20;
below_avergage = 0;
for(i=0; i<20; i++){
if(mat[i]<avg){
below_average = below_average + 1;
}
n = 0; /*n is to find how many times the same number exists.*/
for(j = 0; j<20; j++){
if(mat[i]==mat[j]){
n = n+1;
}
}
if(n>1){
printf(mat[i]);
}
}
printf("Below average are %d numbers", below_average);
system("pause");
}
Similar questions
Math,
6 months ago
India Languages,
6 months ago
Computer Science,
11 months ago
Math,
11 months ago
Science,
1 year ago
Math,
1 year ago
Physics,
1 year ago