Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Created October 6, 2017 04:09
Show Gist options
  • Select an option

  • Save annibuliful/1f976a2a11abc8e17fe4022f0a2a6573 to your computer and use it in GitHub Desktop.

Select an option

Save annibuliful/1f976a2a11abc8e17fe4022f0a2a6573 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(){
int input[500];
int count = 0;
int i;
int sum = 0;
float avg;
printf("Input Number: ");
for(i = 0 ; i < 500 ; i++){
scanf("%d" , &input[i]);
if(input[i] > 0){
sum += input[i];
count += 1;
}else{
break;
}
}
avg = (float)sum/(float)count;
printf(" AVG is %.2f \n" ,avg);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment