Thread: Tips for project

  1. #1
    Unregistered
    Guest

    Tips for project

    I have to do this project in my C++ class but I am not certain how, any tips or hints would be appreciated.
    The problem reads as follows...
    "declare a character array named Alpha and initialize it to ABCDE...
    In your program, include a loop that replaces one character at a time with the lowercase letters a-z. Print the character array to the screen during each iteration of the loop.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    162
    To initilize an array to ABCDE, do this:

    char Alpha[] = {"ABCDE"};

    then just loop though the array and assign all the elements with their equvilant lowercase values. I don't want to tell you too much, because that would diminish the point of the exercise, but try:
    (int)Alpha[i] -= ('A' - 'a');

    Good luck.

  3. #3
    Unregistered
    Guest
    The easiest way to change the captialisation on a letter would be:

    Alpha[i] ^= 0x20;

    It works most of the time, but it doesn't go too well when a something other than a letter is encountered.

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Well the entire program is given below.. This is how you do it. Run this program and you will get the result you want.. This program was done using turbo c++

    # include <iostream.h>
    # include <conio.h>

    main()
    {
    clrscr();
    int i;
    char alpha[26]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(i=0;i<26;i++)
    {
    alpha[i]=alpha[i]+32;
    cout<<alpha[i];
    }


    }

  5. #5
    karkandas
    Guest
    stupid question but ill ask it
    i saw several times the clrscr() around

    but when i try to compile something in microsoft c++ enterprise edition it gives me an error always undeclared idientifier??

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    clrscr() is only good for Windows based systems since it is a thin encapsulation of a Windows function. But anyway, #include <conio.c>
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programming Tips
    By webmaster in forum General Discussions
    Replies: 27
    Last Post: 10-29-2018, 12:49 PM
  2. Ballon Tips in C++ (Borland C++ Builder 6)
    By dfghjk in forum C++ Programming
    Replies: 4
    Last Post: 05-11-2008, 08:00 PM
  3. Tips on becoming a competent programmer
    By trickae2 in forum C Programming
    Replies: 16
    Last Post: 08-28-2006, 07:33 PM
  4. C++ Programming Tips
    By gflores in forum C++ Programming
    Replies: 20
    Last Post: 09-14-2004, 07:53 PM
  5. any useful tips to increase speed when parsing files
    By Shadow12345 in forum C++ Programming
    Replies: 2
    Last Post: 01-18-2003, 05:52 PM