Skip to main content
Plants under shade

There are certain plants that needs to be grown under the shade of huge trees and the dead leaves from the trees become the natural manure for the plants. So willow trees are planted throughout the village at certain positions.

The position(distance from the first tree) follows the following series
0 6 10 17 22 30 36....

Input format:
Input is an integer which corresponds to number of willow trees, n.

Output format:
Output is the series that contains 'n' numbers.

Sample Input 1:
7
Sample Output 1:
0 6 10 17 22 30 36

Sample Input 2:
5
Sample Output 2:
0 6 10 17 22

//Program
#include<stdio.h>
int main()
{
int n,i,x=0,y=6,z=0,k=0;
scanf("%d",&n);
printf("%d %d ",x,y);
for(i=2;i<n;i++)
{
    if(i%2==0)
    {
        x=x+10+k;
        printf("%d ",x);
        k=k+2;
    }
    else
    {
        y=y+11+z;
        printf("%d ",y);
        z+=2;
    }
}


return 0;

}

Comments

Popular posts from this blog

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; }
Ram starts explaining his son about the growth rate of organic farming and the future needs. Help Ram to display the growth rate, the area covered, pesticides used and other important information by writing a program. Input format: The first input is an integer which corresponds to the worldwide market. The second input is a float which corresponds to the growth rate. The third input is an integer which corresponds to the area. The third input is a string which corresponds to the pesticide. Output format: Refer the sample output. Sample Input and Output: World-wide market 653 Growth rate per annum from 2001-2011 18.1 Area 35460 Natural Pesticide Neem oil The World-wide market reached $653 billion with the growth rate of 18.1% in the period 2001-2011. The total area covered was 35460 hectares and Neem oil was used as a natural pesticide. //PROGRAM #include<stdio.h> #include<stdlib.h> #define max 500 int main() { int wwm; int area; float...
CROP DETAILS Crop Details A small farmer, Mr.John, use to grow different crops every year in his field. All the crops are being grown using goat manure, farmyard manure, groundnut and neem cake. All the crops are grown organically. He got high yield by using sufficient water and fertilizers at in this year. He will sell his crops in the market. In the market, he wants to maintain the details of each crop that are purchased by customers. Details like crop name, the weight of the crop, cost of the crop Display the details of crops in ascending order of crop names. Create a structure called crop. struct crop{ char cropName[30]; float weight; int cost; }; Input and Output Format: Refer sample input and output for formatting specification. All float values are displayed correctly to 2 decimal places. All text in bold corresponds to the input and the rest corresponds to output. Sample Input and Output: Enter the number of Crops 2 Enter the details of Crop 1 Enter name...