Last active
July 12, 2016 16:18
-
-
Save Getmrahul/c1ec675550dc9e2ee0c278b689a6ead0 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
/* | |
Sum & Mult till before the last before element and check if it's less than the last before element! | |
*/ | |
#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