What did I do wrong??

Hey Guys,

What is wrong with this simple code?
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

int firstInitial;
int secondInitial;
int lastInitial;
int A,D,M;


cout<< "Enter your first initial: ";
cin>>firstInitial;
cout<<"\n";

cout<< "\nEnter your second initial: ";
cin>>secondInitial;

cout<< "\nEnter your last initial: ";
cin>>lastInitial;

cout<<"\n\n";

cout<<firstInitial<<"."<<secondInitial<<"."<<lastInitial<<".\n";

return 0;

}

This is only meant to ask the user to put in their initials. . . .but what happens is the program only asks for the first initial then runs right pass the other two without allowing the user to input their second and last initials. . then a string of numbers for the last cout. .WHAT did I do wrong??


Your asking for their initial, then trying to read in a number.
You've also failed to assign defaults to your vars.
Last edited on
Hokay. . .thanks, I made firstInitial etc char all =0. . . .now works fine. . .thanks
Topic archived. No new replies allowed.