FRUIT YIELDING TREE
Fruit yielding tree
Jack owned a farm which had ‘n’ fruit trees. He sold a tree from the farm which yielded the maximum number of fruits. Now, he wanted to find the tree that yielded the second maximum number of fruits. Write a program to help Jack in finding the second largest fruit yielding tree without sorting.
Function Specification: int secondLargest(int *, int);
Input format:
The first line of the input corresponds to the n.
The next n inputs correspond to the number of fruits yielded by each tree.(Assume number of fruits yielded by each tree is unique)
Output format:
The output is an integer which corresponds to the second largest fruit yielding tree from the farm.
Sample Input:
7
7
5
8
6
9
4
3
Sample Output:
8
#include
#include
int secondLargest(int*a,int n);
int main()
{
int i,n;
int *p;
scanf("%d",&n);
p=(int*)malloc(n*sizeof(int));
for(i=0;if)
{
s=f;
f=(*(a+i));
}
else if(((*(a+i))>s)&&((*(a+i))!=f))
s=*(a+i);
}
return s;
}
C Program To Calculate The Revenue The demand for organic food increases every year by 8.9%. Write a program to find the increase in revenue after 3 years. Given the revenue in the first year is ‘x’ crores. Input Format: The first line of the input is an integer that corresponds to the ‘x’ value. Output Format: Output is a float value that corresponds to the revenue after 3 years, rounded off to 2 decimal places. Sample Input: 4 Sample Output: 5.17 //PROGRAM #include<stdio.h> int main() { int x,i; float rev; scanf("%d",&x); rev=x; for(i=0;i<3;i++) { rev=rev*(1.089); } printf("%.2f",rev); return 0; }
PLEASE SHARE TOTAL PROGRAM
ReplyDelete