English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include

int main()
{
char start, end, dummy;
int cnt, line;

printf("Enter Start Character");
start = getchar();
dummy = getchar();

printf("Enter End Character");
end = getchar();

for(line = 0;cnt = start; cnt<=end; cnt++; line++);
{
printf("%3d%3x%2c", cnt, cnt, cnt);
if(line%3==0 line!=0)&&
{printf("\n")
}

return 0;
}




this is just the start but it says i have errors on line 15 and 18 and i dont know what they are...


a little help would be greatly appreciated.

2007-10-16 11:57:54 · 3 answers · asked by alienworkshop27 1 in Computers & Internet Programming & Design

im looking for the error in line 15 and 18, or possibly 14 and 17

2007-10-16 12:05:42 · update #1

3 answers

List of problems:

Your for statement is wrong. You can only have 3 separate statements. It should be like this to correct the syntax (commas are okay as dividers):
for ( line=0 , cnt = start; cnt<=end; cnt++, line++)

You are missing a '}' after your if statement, you close the for loop but not the if statement.

The if statement doesn't have the && (and) sign at the correct spot. It should be : if ( line%3 == 0 && line != 0 )

You are missing the ';' after the printf statement. This will work below:




int main()
{
char start, end, dummy;
int cnt, line;

printf("Enter Start Character");
start = getchar();
dummy = getchar();

printf("Enter End Character");
end = getchar();

for(line = 0, cnt = start; cnt<=end; cnt++, line++);
{
printf("%3d%3x%2c", cnt, cnt, cnt);

if(line%3==0 && line!=0)
printf("\n");
}

return 0;
}

2007-10-16 13:11:37 · answer #1 · answered by Adopted 3 · 1 0

Well, first of all you only got a C++. Next time try shooting for at least a B-...

2007-10-16 19:05:56 · answer #2 · answered by Anonymous · 1 0

on line 15 {printf("\n") it should be printf("\n");
Check your block code openers and closers, you got more { than you do }.

2007-10-16 19:02:03 · answer #3 · answered by boer84 3 · 0 0

fedest.com, questions and answers