Created
July 12, 2016 16:20
-
-
Save Getmrahul/f582efbf62064d9cb0f99ae0fe9892c0 to your computer and use it in GitHub Desktop.
Sum & Mult till before the last before element and check if it's less than the last before element!
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 arr[20],n,i=0,sum=0,mult=1,element; | |
printf("Enter number of elements: "); | |
scanf("%d",&n); | |
while(i<n) { | |
printf("\nEnter no%d: ",i); | |
scanf("%d",&arr[i]); | |
if (i<n-2){ | |
sum += arr[i]; | |
mult *= arr[i]; | |
} | |
i++; | |
} | |
element=arr[n-2]; | |
if ((sum<element) && (mult<element)) { | |
printf("\nFantabulous\n"); | |
} else { | |
if(sum<element){ | |
printf("\nFantastic\n"); | |
} | |
if(mult<element){ | |
printf("\nFabulous\n"); | |
} | |
} | |
return 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment