13,403,463 members (53,307 online)
See more:
1st line- 2 10 30 68 130
2nd line- 1 2 3 5 8 13 21 34 55
3rd line- 1 4 7 10 13 16 19 22 25

please only use for loop for this as my teacher gave a task :(

```#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
for(a=1;a<=25;a+=3)
{
printf("\n\t3rd line:%d",a);
}
for(b=2;b<=55;b++)
b+=3;
c=b+10;
{
printf("\n\t\t\t:2nd:%d\n%d",b,c);
}

getch();   ```

i just wrote this one , it gives 3rd line correctly but what about the 1st two lines they are'nt that simple.
Posted 3-Dec-12 3:37am
Updated 3-Dec-12 4:28am
v4

## Solution 4

```#include<stdio.h>
main()
{

int a=1,b=1,i,c;

printf("2nd line :");
for(i=0;i<9;i++)
{
c=a;
a=b;
b=c+b;
printf("%d ",a);
}
printf("\n");

printf("1st line :");
for(i=1;i<6;i++)
{
printf("%d ",(i*i*i)+i);

}
printf("\n");

printf("3rd line :");
for(a=1;a<=25;a+=3)
{
printf("%d ",a);
}
printf("\n");

}```

## Solution 1

Your teacher gave the task to you. At least make an effort to solve it.
jahanxb 3-Dec-12 8:48am

@richard i know this is cheating but at least i should have something to get an idea . i am not a freaking genious :p
Richard MacCutchan 3-Dec-12 8:51am

You don't need to be a genius to write a few simple loops. And if you do not even know that much then I suggest you go back and read your course notes.
jahanxb 3-Dec-12 8:55am

right now i am doing that :p

## Solution 2

To understand those series, there is one trick which works well: form the first differences (i.e. b-a, c-b, d-c, e-d...) and observe.

If you can't find a regularity, then repeat the process, forming the second differences, and so on.

This will allow you to figure out a formula or a computational procedure.

v2
jahanxb 3-Dec-12 8:55am

well i am gonna try it , but my teacher said no use of condtions and less number of variables
YvesDaoust 3-Dec-12 9:10am

In what way does this contradict my suggestion ???

1 and 3 can be done with a single variable; 2 requires two of them.

## Solution 3

1. Set the start value to the first number in the sequence.
2. Display the current value of the sequence.
3. If current value equals last number, quit.
4. Calculate the next number in the sequence.
5. Go back to step 2 and repeat.
jahanxb 3-Dec-12 8:58am

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
for(a=1;a<=25;a+=3)

{ printf("\n\t3rd line:%d",a);
}
for(b=2;b<=55;b++)
b+=3;
c=b+10;
{

printf("\n\t\t\t:2nd:%d\n%d",b,c);
}

getch();

i just wrote this one , it gives 3rd line correctly but what about the 1st two lines they are'nt that simple
Richard MacCutchan 3-Dec-12 9:21am

It took me less than a minute with Google to find the answer to the line 1 problem. Or you could find a fellow student who understands mathematics and ask them (Hint: it's a simple polynomial).

Top Experts
Last 24hrsThis month
 OriginalGriff 223 Richard MacCutchan 120 Maciej Los 85 RickZeeland 84 F-ES Sitecore 75
 OriginalGriff 5,347 Maciej Los 2,820 Richard MacCutchan 1,903 CPallini 1,730 RickZeeland 1,129