Bulid your logic and algorithm | C Program
Build a program in c Language :
Logic:
1.Take an array2.Insert elements of 4 elements.
3.Select one element and sum the rest
4.Check weather it is larger than sum or not.
Output:
Code:
#include<stdio.h>
#define max 4
int a[max];
void input();
void greater();
int sum,i,j;
void main()
{
input();
greater();
}
void input()
{
printf("Enter the four element: \n");
for(i=0;i<max;i++)
scanf("%d",&a[i]);
}
void greater()
{
for(i=0;i<max;i++)
{
sum=0;
for(j=0;j<max;j++)
{
if(a[j]!=a[i])
{
sum=sum+a[j];
}
}
if(sum<a[i])
{
printf("\n %d is greater than sum of rest= %d\n",a[i],sum);
}
}
}
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)