# Basic problem using for loops w/ functions. help :(

• 04-22-2012
rensan
Basic problem using for loops w/ functions. help :(
Would someone help me with this word problem? :(

Write a function that will accept three integers as parameters, call these three integers as start , end and step respectively.

-assume that start is always less than end and step is a positive integer greater than zero.

-thereafter, the function should print the numbers such that the first item is start, the second item is equivalent to the first item plus the value of step, the third item is equivalent to second item plus the value of step and so on. the last value to be printed should not be greater than end.
• 04-22-2012
Salem
• 04-22-2012
rensan
can you help me with this ? :(
• 04-22-2012
laserlight
Probably. You should make an attempt first though, and that is what Salem is getting at.
• 04-22-2012
rensan
Code:

```         Quote:                                                                 #include<stdio.h> void notepad(int,int,int); void main() {                 int a,b,c;           notepad(a,b,c);  } void notepad(int a,int b, int c) {         int start,end,step;         printf("Enter the 1st Number :");         scanf("%d",&start);         printf("Enter the 2st Number :");         scanf("%d",&end);         printf("Enter the 3st Number :");         scanf("%d",&step);         for(start=start;start<end;++start)         printf("%d\n",start);         }                                                 ```
is this correct? :( im still newbie for C
• 04-22-2012
Salem
Well the first step would be for you to show that you can either
- call a function with parameters, but can't do the loop
- can do the loop in main, but somehow cannot call a function
- can do a loop, but only if step is 1

Now, where exactly are you stuck?

Edit:
Try start += step
• 04-22-2012
rensan
where i would put "start+=step" ? :( sorry.
• 04-22-2012
Salem
Where in the code you have at the moment do you see start being modified?
• 04-22-2012
memcpy
Why do you pass a, b, and c to your function? They aren't used or modified.

Don't use void main: SourceForge.net: Void main - cpwiki

> where i would put "start+=step" ?
You're making me think you didn't write the above code. Just think about it. In the loop, instead of incrementing by 1 every time, increment by step.

Code:

`for(start=start;start<end;++start)`
You don't need "start=start;".