I'm not sure if I'm doing this part correctly, the part where I have to make it all lower case then to all upper case, then just first name.

#include <iostream>
#include <cstring>
#include <stdio.h>

using namespace std;

int main()
{
    char a[3][14] = { "Barack ", "H", " Obama" };

    cout << "Enter your full name: ";
    cout << a[0] << a[1] << a[2] << endl;

    //Find length of name
    int i = strlen(a[0]);
    int j = strlen(a[1]);
    int k = strlen(a[2]);
    cout << "\tYou name's length is " << (i+j+k) << endl;

    tolower (a[0][0]); 
    tolower (a[0][1]);
    tolower (a[0][2]);
    tolower (a[0][0]);

    cout << "\tYour name in lower case: " << a[0][0] << a[1] << a[2] << endl;

    cout << "\tYour name in upper case: " << a[0] << a[1] << a[2] << endl;

    system("pause");
    return 0;
}

Output should look like:

Enter your full name: Barack H Obama
    You name's length is 14
Your name in lower case: barack h obama
Your name in upper case: BARACK H OBAMA
Your first name: BARACK

BARACK, what is your friend's name? barack
    Your name is the same as your friend's name

The tolower and toupper functions only work on a single character at a time. So, if you want to apply it to a whole string, then you need to iterate through the characters in the string and apply that function to each character.

For example, if you have a string, you can do this:

char a[] = "Something";
int a_n = strlen(a);
for(int i = 0; i < a_n; ++i)
  a[i] = char(tolower(a[i]));

This will turn each character of the a string into a lower-case one. You should be able to figure out how to apply that to your particular problem.

Generally-speaking though, it is easier to use the C++ class std::string instead of these old C-style strings (char*).

so should I delete this part? :

 //Find length of name
    int i = strlen(a[0]);
    int j = strlen(a[1]);
    int k = strlen(a[2]);
    cout << "\tYou name's length is " << (i+j+k) << endl;
    tolower (a[0][0]); 
    tolower (a[0][1]);
    tolower (a[0][2]);
    tolower (a[0][0]);

But it has three elements though, how would that be incorporated?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.