Thread: Printing name in reverse order and in caps

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    71

    Printing name in reverse order and in caps

    Hi,

    I'm trying to print my name in reverse and in capital letters. I got this far and I am almost certain this is correct, but when I compile I get a bunch of numbers and not my name.

    Can anyone give me hand please?

    Code:
    #pragma hdrstop
    #include<iostream>
    #include<conio>
    using namespace std;
    using std::toupper;
    
    //---------------------------------------------------------------------------
    
    #include<string.h>
    #pragma argsused
    
    int main()
    {
    char name[] = {"Jason"};
    int character;
    character = strlen(name);
    
    for (int i = strlen(name); i >= 0; i--)
    {
       character = name[i];
       character = toupper(character);
       cout << character;
    }
    
       getch();
       return 0;
    
    }

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    Code:
    char name[] = {"Jason"};
    char character;
    
    for (int i = strlen(name) - 1; i >= 0; i--)
    {
       character = name[i];
       character = toupper(character);
       cout << character;
    }

Popular pages Recent additions subscribe to a feed