until now u didnt solve my problem use c++ to input three words and then put them from largest to smallest using if statement

Recommended Answers

All 5 Replies

You have not posted any code yet, so can not help you.

#include<iostream>
using namespace std;

int main()
{
    char word;
    int length;
    cout<<"please input three words";
    cin>>word;
    if (length>5)
    word= 'number 1';
    else if (length =5)
    word= 'number 2';
    else if (length<5)
       word = 'number 3';
    
     system ("pause");
    return 0 ;
}

1. Don't forget code tags.

2. char word; only declares a character. To use strings you have to include the string header file.

also, you need to set length , use strlen() for that.

I see you never read your previous threads.

>>until now u didnt solve my problem use c++
WE are not supposed to solve YOUR homework, you are.

Ok, this took me all of 15 minutes to write

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    vector<string> array;

    for(int i = 0; i < 3; i++)
    {
        cout << "Enter string #" << i+1 << ":  ";
        string word;
        cin >> word;
        array.push_back(word);
    }
    sort(array.begin(), array.end());
    vector<string>::iterator it;
    for(it = array.begin(); it != array.end(); it++)
        cout << *it << "\n";

    return 0;
}
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.