-1

this is the program

// file: am00201.cpp
// author: a.montes de oca

#include <iostream>
using namespace std;
int main()
{
int a[16] = {67, 111, 110, 103, 114, 97, 116, 117, 108, 97,

             116, 105, 111, 110, 115, 33};
int i;
char letter;

i = 0;
while (i < 16)
    {
      letter = a[i];
       cout << letter
       i++;
     }
cout << '\n';
return 0;
} // end of main function

when i attempted on compiling the program this is what it read:

1>------ Build started: Project: PostLab, Configuration: Debug Win32 ------
1>Compiling...
1>am00201.cpp
1>f:\csc101\lab02\postlab02\am00201.cpp(19) : error C2146: syntax error : missing ';' before identifier 'i'
1>Build log was saved at "file://f:\csc101\Lab02\PostLab02\PostLab\PostLab\Debug\BuildLog.htm"
1>PostLab - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

what am i doing wrong?

Edited by Nick Evan: Fixed formatting

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by adnan.siddique
-1

working now. a semicolon was missing

#include <iostream>
using namespace std;
int main()
{
int a[16] = {67, 111, 110, 103, 114, 97, 116, 117, 108, 97,

116, 105, 111, 110, 115, 33};
int i;
char letter;

i = 0;
while (i < 16)
{
letter = a[i];
cout << letter;
i++;
}
cout << '\n';
return 0;
} // end of main function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.