Pls need help urgently!

I am a beginner in c++ and recently came across this problem I would like to solve.
Write a program that will read in a persons first and last name and 3 test scores. Print out the persons name 3 test scores and the average. Your program should work for any number of lines of data.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
   #include <iostream>
   using namespace std;
   int main ()
  {
    char firstname, lastname;
    int  test1, test2, test3, avg;
    cout << "Enter your firstname and lastname "<< endl;
    cin>>firstname>>lastname;

    while (cin>>test1>>test2>>test3)
    {
      avg = (test1+test2+test3)/3;

      cout << "Your name is  " <<firstname<< " and your three test scores  are  " << test1 << test2 << test3 << "and average is " << avg <<endl;
    }
      return 0;
  }


For some reason this code doesnt print out my first name and last. PleaseI need help and the numbers are joined together when they are printed out. Thanks in advance !!!
> For some reason this code doesnt print out my first name and last.
Use std::string for firstname and lastname
char is just 1 character

> and the numbers are joined together when they are printed out.
std::cout << foo << ' ' << bar;
If you don't say that you want to print an space, then it would not print an space
Thank you so much I got it now....
Topic archived. No new replies allowed.