Hey everyone. I'm taking an intro C++ class online, and my first assignment is to write a program "that inputs a character, integer, and float type and then outputs the values." I'm having a hard time finding an example of this in my textbook. I know how to display a message to the console and do basic math problems, but that's all I've learned so far. I came across a code online, and I don't really understand it. Any tips and pointers would be much appreciated. Like I said, I'm a brand new beginner, so anything would be helpful. Thanks a lot! :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include<iostream>
usingnamespace std;
int main()
{
char P;
int Q;
float R;
cout<<"Enter a character followed by new line";
cin>>P;
cout<<"Enter a integer followed by new line";
cin>>Q;
cout<<"Enter a float followed by new line";
cin>>R;
cout<<P<<endl<<Q<<endl<<R<<endl;
return 0;
}
L B is right indenting your code is a good practice.. Indenting is for readability purpose, when ever a code is in {} another curly brace you should indent you codes.