Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int arr[12];
- int lm = 11;
- int hm = 0;
- int total = 0;
- for(int i=0;i<12;i++){
- scanf("%d" , &arr[i]);
- if(arr[i]<0){
- printf("Invalid input");
- return 0;
- }
- total+=arr[i];
- }
- for(int i=0;i<12;i++){
- if(arr[i] < arr[lm]){
- lm=i;
- }
- if(arr[i]>arr[hm]){
- hm=i;
- }
- }
- printf("Total rainfall : %d\n" , total);
- printf("Average rainfall : %d\n" , total/12);
- printf("Lowest rainfall month : %d\n" , lm+1);
- printf("Highest rainfall month : %d\n" , hm+1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement