Skip to content

Instantly share code, notes, and snippets.

@Getmrahul
Last active July 12, 2016 16:18
Show Gist options
  • Save Getmrahul/c1ec675550dc9e2ee0c278b689a6ead0 to your computer and use it in GitHub Desktop.
Save Getmrahul/c1ec675550dc9e2ee0c278b689a6ead0 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!
*/
#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