Created
October 6, 2017 04:09
-
-
Save annibuliful/1f976a2a11abc8e17fe4022f0a2a6573 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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