1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

please click here (imp)

Discussion in 'C++' started by wafa, Dec 24, 2010.

  1. wafa

    wafa New Member

    Joined:
    Dec 24, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    hello every one this programme do kaptel letter but i want chang when the word have small letter change to kapter and when have kapter chang to small i try this code

    but it gust kapter letter
    i need like this
    user in put
    cin>>WElcoME
    cout<<weLCOme//this out put<<

    this my code""

    #include​
    <iostream>

    #include​
    <string>

    int​
    main()
    {
    std::
    string line;

    std::cout
    <<"Enter your a line of text: ";

    if ( getline ( std::cin, line ) ) {
    // Make the line all upper case

    for ( std::string::size_type i = 0; i < line.size(); i++ )
    line
    [i] = std::toupper ( line[i] );

    std::cout<< line <<
    '\n';
    }
    return 0;
    }

     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    try this

    Code:
    
    #include <iostream>
    
    int main(){
        std::string line;
        std::cout<<"Enter your a line of text: ";
        if ( getline ( std::cin, line ) ) {
            for ( std::string::size_type i = 0; i < line.size(); i++ )
                if (isupper(line[i]))
                     line[i]=tolower(line[i]);
                else if (islower(line[i]))
                     line[i]=toupper(line[i]);
            std::cout<< line <<'\n';
        }
        getchar();
    return 0;
    }
    
     
  3. wafa

    wafa New Member

    Joined:
    Dec 24, 2010
    Messages:
    8
    Likes Received:
    0
    Trophy Points:
    0
    yesssssssss

    than u ur my Teacher

    that's code worke

    iam so happy thanx alot
     

Share This Page