0

Below is what I currently have; I am not sure why I cannot just print the value, incrementally with the below; i.e. 1,2,3.. etc. I have also tried cout<<count;

 #include <iostream>
    using namespace std;
    int main()
    {char count;


     while(count<=10)
     {
     cout<<"My name is Bill"<<endl;
     cout << "The # is:" <<count<<endl;
     cout << count++;
     }
     }
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204

2 Answers2

4

count is uninitialized. Since you want to start from 1, you should initialize it that way. And, you should use an integer.

int count=1;
jxh
  • 69,070
  • 8
  • 110
  • 193
3
  1. You should declare count as an int and initialize it:

    int count = 0;
    

    I suggest you learn about the different primitive data types that C++ has. Using the correct type for what you want to do will save you a lot of headache.

  2. You are incrementing and printing out with one command:

    cout << count++;
    

    Instead, you only need to increment:

    count++;
    
Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268