Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9097633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:09:51+00:00 2026-06-17T00:09:51+00:00

i’m trying to write a program in which a word as a string is

  • 0

i’m trying to write a program in which a word as a string is provided as an input and i have to rearrange the word such that it just changes the order of the letters in a word by moving
all the vowels to the end, keeping them in the same order as they appeared in the original word

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = "application";
            char[] letters = word.ToCharArray();
            char x = new char { };
            for (int j = 0; j < letters.Length; j++)
            {
                if ((letters[j] == 'a') | (letters[j] == 'e' ) | (letters[j] == 'i' ) | (letters[j] == 'o' ) | (letters[j] 

== 'u'))
                {
                    for (int i = 0; i < letters.Length - 1; i++)
                    {
                        x = letters[i];
                        letters[i] = letters[i + 1];
                        letters[i + 1] = x;
                    }
                }
            }
            string s = new string(letters);
            Console.WriteLine(s);
        }
    }
}

the output of the program is

ationaplic

but the intended output of program is

pplctnaiaio

Why is my code not producing my intended output?

The edited working code is

namespace VowelSort
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = "application";
            char[] letters = word.ToCharArray();
            char x = new char { };
            int count = 0;
            for (int j = 0; j < letters.Length - count; j++)
            {
                if ((letters[j] == 'a') | (letters[j] == 'e') | (letters[j] == 'i') | (letters[j] == 'o') | (letters[j] == 'u') | (letters[j] == 'A') | (letters[j] == 'E') | (letters[j] == 'I') | (letters[j] == 'O') | (letters[j] == 'U'))
                {
                    for (int i = j; i < letters.Length - 1; i++)
                    {
                        x = letters[i];
                        letters[i] = letters[i + 1];
                        letters[i + 1] = x;

                    }
                    count++;
                    j--;
                }

            }
            string s = new string(letters);
            Console.WriteLine(s);
            Console.WriteLine(count);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T00:09:52+00:00Added an answer on June 17, 2026 at 12:09 am

    There are three problems I found here:

    1. When you find a vowel, you start your inner loop at 0 so you always move the first character to the end. Start it at j instead.
    2. After you’ve moved a vowel, you start your outer loop at the next letter – so if you have two vowels in a row, you skip the second one (because it’s been moved behind he “current” position”). After you’re done moving a vowel, decrement j.
    3. You run your outer loop right to the end, but you should stop it when you get to the vowels you’ve already moved. Keep count of the number of vowels you’ve moved, and stop your outer loop when you get to that many characters from the end.

    Try to implement these changes yourself, but if you get stuck I can give you some pointers.

    Once you have this working, you might like to speed up your inner loop by realising you don’t have to perform multiple pairwise swaps – you can just note the vowel you’ve found, move everything after it up one character, and then insert the vowel at the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.