hello guys well in this program I used cin.get to get the value of the variable if you see the source code look over " cin.get(names, 20);" names= your variable and 20 is the space of the memory that is gonna be occuped by your variable if Im not wrong .
so lets go where I sum the char variable "grade = grade + 1;" considering that the exercise pleads you that it has to request a letter input we just sum 1 to the input so for example you put any letter like A it will output B just check this:
Also note that the program adjusts the grade downward—that is, up one letter.
Assume that the user requests an A, a B, or a C so that you don’t have to worry about the gap between a D and an F.now lets go to the array I already explained about the memory store Ive never used cinget before but you may have an idea how it works.
problem:
Write a C++ program that requests and displays information as shown in the following
example of output:
What is your first name? Betty Sue
What is your last name? Yew
What letter grade do you deserve? B
What is your age? 22
Name: Yew, Betty Sue
Grade: C
Age: 22
Note that the program should be able to accept first names that comprise more than one
word. Also note that the program adjusts the grade downward—that is, up one letter.
Assume that the user requests an A, a B, or a C so that you don’t have to worry about the gap between a D and an F.problem solved:
#include <iostream>
using namespace std;
int main()
{
char names[20];
char lastname[10];
char grade;
int age;
cout << "What is your first name? ";
cin.get(names, 20);
cout << endl;
cout << "What is your last name? ";
cin >> lastname;
cout << endl;
cout << "What letter grade do you deserve? ";
cin >> grade;
cout << endl;
grade = grade + 1;
cout << "What is your age?: ";
cin >> age;
cout << endl;
cout << "Name: " << lastname << " , " << names;
cout << endl;
cout << "Grade:" << grade;
cout << endl;
cout << "Age: " << age;
cout << endl;
system("pause");
return 0;
}
thanx to bluechill and cludthin for their support I hope this was helpful