Hi, yeah, you're quite right about readibility, I didn't know I could break each line like that, I thought it would have caused an error or something.
About this
When the value of the variable letter is 65, the alphabet A is displayed. When the value is 90 the variable Z is displayed. At this time the value of counter is 26. The for the values 91-96 there is no display. Then the value of letter becomes 97. Counter gets incremented to 27, we go to the next line and the letter a is displayed
I think I am following but I thought that if I say
if (counter==26)//counter condition
cout<<" \n";
the line space will be placed after the 26th character but instead it places it after character 25.
I can show you another quick example though, because I don't seem to be getting this counter business and line breaks at all.
This example is in the book I am using for C++(C++ a beginner's guide - Herbert Schildt). it goes:
#include<iostream>
using namespace std;
int main()
{
double f;
double m;
int counter;
counter=0;
for(f=1.0;f<=100.0;f++)
{
m=f/3.28;
cout<<f<<" feet is"<<m<<"meters.\n";
counter++;
if (counter==10)
{
cout<< "\n";
counter=0;
}
}
return 0;
}
As you can see it's
if (counter==10)
{
cout<< "\n";
so here the line breaks is actually placed after 10 lines as it says in the program, whereas in my program if I say
if (counter==26)//counter condition
cout<<" \n";
…