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

  • SEARCH
  • Home
  • 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 8736217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:15:20+00:00 2026-06-13T10:15:20+00:00

I am new to programming and I have a project in my Algorithm class.

  • 0

I am new to programming and I have a project in my Algorithm class. What we have to do is decide on a problem and solve it. We haven’t learnt much more than string, char and WriteLine. We did add a couple of things as you will see soon!

I decided that what I want to solve this: The user inserts a word, no matter how long and the program will automatically make the first letter a capital letter. So far this is what I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
    static void Main(string[] args)
    {
    start:
        Console.WriteLine("Please enter a word below:");
        Console.WriteLine("");
        string str = Console.ReadLine();
        char char1;
        if (str[0] >= 97)
        {
            char1 = (char)(str[0] - 32);
        }
        else
        {
            char1 = (char)(str[0] + 32);
        }

        char char2 = (char)(str[1]);
        char char3 = (char)(str[2]);
        char char4 = (char)(str[3]);
        char char5 = (char)(str[4]);
        Console.WriteLine("");
        Console.Write(char1);
        Console.Write(char2);
        Console.Write(char3);
        Console.Write(char4);
        Console.WriteLine(char5);
        goto start;
}
}
}

The problem with that code is that any word with less than 5 letters will make the program crash. Anything with more than 5 letters will just be cut at the fifth letter… I was told that using arrays should solve this problem. Seeing as I am a total newbie at this, I would need this to be broken down and be as simply told as possible!

Any help getting this to work would be very appreciated.

Thanks 🙂

  • 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-13T10:15:21+00:00Added an answer on June 13, 2026 at 10:15 am
    Console.WriteLine("Enter a word:");
    string str = Console.ReadLine();
    Console.WriteLine(str[0].ToString().ToUpper() + str.Substring(1));
    

    This will work.

    Or… if you need to go through the entire string and find the first actual alphabetical character, you can do the following:

    Console.WriteLine("Please enter a word:");
    string s = Console.ReadLine();
    bool found = false;
    char[] chars = new char[s.Length];
    for (int i = 0; i < s.Length; i++)
    {
        if (Char.IsLetter(s[i]) && !found)
        {
             chars[i] = s[i].ToString().ToUpper()[0];
             found = true;
        }
        else
        {
            chars[i] = s[i];
        }
    }
    s = new String(chars);
    Console.WriteLine(s);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning dynamic programming and have attempted solve Problem 15 of Project Euler
I am new to c++ programming, I have a c++ project developed in visual
I'm very much new to programming and have been doing fairly well so far.
I am new to C# programming and I have a problem with dll creation.
I'm new to iOS programming, I have a project going on and along with
I have a project in my programming class and I'm failing a test case.
i am new kernel programming.i have been trying to load this driver program for
I am new to web programming...I have been asked to create a simple Internet
I'm new to PHP programming and have poor knowledge about it, but I want
I'm pretty new in iphone programming and have stumbled upon this issue which 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.