Assalam o Alikum my question is that what is the difference between character array and string. my instructor is use
char str  instead of string str. and i can not understand what is difference between them.
A character array is just what it sounds like, it's a raw array (sequence of contiguous memory) of characters (1 byte numbers that are interpreted as characters when printed on a screen) with the end marked with a 0 character (null-terminated strings). That's about all you get with a character array, it's just raw memory and you have to manually allocate / deallocate it, use C-style functions like strcmp or strcat to do operations on that memory, and you have to worry about capacity. Character arrays are essentially the only option in C for representing strings. It can be useful to know about them and how to work with them, mainly as a way to build your "low-level understanding" of things, but they are not really used in practice in C++, unless you are dealing with some C code.
Strings, as in, using the std::string class, are the proper way to deal with strings in C++. This is a class that encapsulates a dynamic array of characters and provides a number of useful features to manipulate strings. For one, it automatically handles the allocation / deallocation of the memory, as well as increasing the capacity whenever needed (as you append stuff to the string). That, by itself, is a sufficient reason to use C++ strings over the C-style character arrays, almost always. In addition, C++ strings have a number of nice functions and operators that allow you to compare, concatenate, split, and transform the strings very easily and safely. They are, by far, the preferred option.
Some instructors like to use character arrays for one of two reasons: (1) they want you to understand the underlying "raw" mechanisms before you start using std::string; or, (2) they are old and back when they learned C++ (probably before the standard was established), the std::string class was a new and exotic thing. If it's the former, then that's fine, it can be good to learn this low-level stuff (but it's not good to dwell too much on it either). If it's the latter, then I have to emit the following:
Warning: Use of 'your instructor' is deprecated. Consider a modern replacement for 'your instructor'.
using namespace std;
cout<<"enter your name = ";
cout<<"enter your friend name = ";
cout<<"enter your height = ";
cout<<"your name is = "<<str<<endl;
cout<<"height is = "<<h<<endl;
cout<<"your Friend name is = "<<str1<<endl;
public class GrossmontBank
//class variables (global - accessible throughout this class)
//scanner object to be used throughout
private static Scanner input = new Scanner(System.in);