Loops in c++

Hello everyone

Am actually a newbie and learning C++ on my own. Have been trying to generate a code that prompts a student to enter his/details and after finishing. it couts his/her information. And prompts another student data to be entered. i have already some simple code here but it’s not giving my expectations.. Please help me on how to do it. +254718056203 is my contact add me in watsapp en help me. Hope am not a bother. Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <string>



using namespace std;

int main()
{
  int admno;
  string studentname;
  string Addresscode;
  string telephonenumber;

  cout<<"please Enter admission number:\n";
  cin>>admno;
  cout<<"Please Enter student name:\n";
  getline(cin,studentname);
  cout<<"please Enter student telephone number:\n";
  getline(cin,telephonenumber);

  do {cout<<"admission Number: "<<admno<<"Address code: "<<Addresscode<<"Telephone number: "<<telephonenumber;}

while (admno!=35);
cin.get();


  }

Look at the do while -example in http://www.cplusplus.com/doc/tutorial/control/
have successfully gone a step ahead and its showing"please Enter student telephone number" at the same moment with "please Enter student telephone number". what might be the problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <string>
using namespace std;
int main()
{
int admno;
string studentname;
string Addresscode;
string telephonenumber;
do {
    cout<<"please Enter admission number(0 to terminate):\n";
    cin>>admno;
    if(admno == 0)
    {
        break;
    }
    cout<<"Please Enter student name:\n";
    getline(cin,studentname);
    cout<<"please Enter student telephone number:\n";
    getline(cin,telephonenumber);
    cout<<"admission Number: "<<admno<<"Address code: "<<Addresscode<<"Telephone number: "<<telephonenumber;
}
while (admno!=0);
cin.get();
}
Topic archived. No new replies allowed.