![]() |
| | #1 |
| Registered User Join Date: Jan 2009
Posts: 13
| Code: #include<conio.h>
#include<stdio.h>
#include<stdlib.h>
char name[25];
void input_name()
{
printf("please enter your name.");
scanf("s%",&name);
}
void process()
{
for (name=1; <10; name+1)
printf("Your name is %s/n",name);
}
int main()
{
input_name();
process();
getch();
return 1;
}
|
| Chalmers86 is offline | |
| | #2 |
| Registered User Join Date: Jan 2009
Posts: 13
| sorry didn't mean to create two. If possible could the admin delete this sorry to make a mess. |
| Chalmers86 is offline | |
| | #3 |
| Registered User Join Date: Oct 2008
Posts: 452
| Do you know about while loops? I think you should learn about those first. Then, all you really need to know is that: Code: for(A; B; C) {
D;
}
Code: A;
while(B) {
D;
C;
}
So, now, how do you think you should do it? |
| EVOEx is offline | |
| | #4 |
| Registered User Join Date: Jan 2009
Posts: 13
| I’ve done a little on while loops but I’m not that experienced in C programming as a whole. This is my first year at college. I understand what you have wrote there. I’ve been taught for the for loop that – For(initialisation; test condition; Incrementation or decrementation) Which I kinda understand but what is initialisation? I put name=1 cause I thought you had to tell the computer that name was one thing and the rest told the computer add to one till you reach ten. I understand the while loop is definitely the most logical way of solving this problem but I’m just trying to understand the for loop so I can incorporate it in another program. I understand the theory behind the language but can put it into code. If that makes sense? |
| Chalmers86 is offline | |
![]() |
| Tags |
| problem |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| For Loop Disaster | Chalmers86 | C Programming | 4 | 03-23-2009 12:58 AM |
| Tsunami disaster. | anonytmouse | A Brief History of Cprogramming.com | 23 | 01-09-2005 09:56 AM |
| NTFS disaster recovery | -=SoKrA=- | Tech Board | 20 | 04-17-2004 02:16 AM |
| Class + Union + Struct = Disaster?? | Inquirer | C++ Programming | 5 | 10-28-2002 03:55 PM |
| disaster relief | iain | A Brief History of Cprogramming.com | 1 | 09-13-2001 08:12 PM |