|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#46
|
||||
|
||||
|
Re: C Programming Homework Help Needed
Hi Pat,
Shouldn't your "for" loop start with its index set to 2 rather than 3? Your array size is 3 -- with an index of 0, 1 or 2. Dave D |
|
#47
|
||||
|
||||
|
Re: C Programming Homework Help Needed
I just fixed that, but I'm still having the same problem.
As an example, I'll enter 1111 and the error checking appears to work, but then I'll enter 1211 and it will say there is an error with the second digit. This happens for any digit that has a value of 2. |
|
#48
|
||||
|
||||
|
Re: C Programming Homework Help Needed
Sorry, no, your index is OK, but your array declaration should read
int num[4]; not int num[3]; |
|
#49
|
||||
|
||||
|
Re: C Programming Homework Help Needed
Thanks Dave! That seems to have taken care of it!
It's been a year since I've written code, so I'm a bit rusty. ![]() |
|
#50
|
||||
|
||||
|
Re: C Programming Homework Help Needed
That C structured programming class seems to be dragging out for quite some time. It might be about time to start in on C++.
![]() |
|
#51
|
||||
|
||||
|
Re: C Programming Homework Help Needed
Nah, it's been over multiple classes, just all using some C as a component of them.
|
|
#52
|
|||
|
|||
|
help on palindrome
i have make a program that can trace palindrome number but i need it to loop over and over again till i keyin -1 then only the program terminate this is the code that i have used: Code:
#include<stdio.h>
#include<string.h>
void main()
{
char strsrc[5];
char strtmp[5];
printf("\n Enter a five-digit number ( -1 to end ): "); gets(strsrc);
strcpy(strtmp,strsrc);
strrev(strtmp);
if(strcmp(strsrc,strtmp)==0)
printf("\n %s is a palindrome\n",strsrc);
else
printf("\n %s is not a palindrome\n",strsrc);
}
|
|
#53
|
|||||
|
|||||
|
Re: C Programming Homework Help Needed
Quote:
You want it to end? Hint: use an exit statement, but only execute it when the program is supposed to terminate. |
|
#54
|
||||
|
||||
|
Re: C Programming Homework Help Needed
What exactly do you mean by "loop"? Do you want it to repeatedly ask for a number, then check it for palindrome-ness (sorry, vocabulary suffered a non-Build season hit
) , or do you want to loop through calculations (a bit daft, but I don't know what the professor/employer expects...), or what? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| programming help needed | krunal | Programming | 3 | 29-01-2007 00:18 |
| Help on a Homework Assignment. | Pavan Dave | General Forum | 1 | 13-09-2006 14:20 |
| HELP-URGENT PROGRAMMING HELP NEEDED | Rohith Surampudi | Lego Mindstorm Discussion | 1 | 24-03-2006 23:05 |
| URgent Programming Help needed | rcubes85 | Programming | 4 | 15-02-2005 23:21 |