Can you help me guys with my code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mckapusta
    New Member
    • May 2022
    • 1

    Can you help me guys with my code?

    Code:
    using System;
    namespace ConsoleApplication1
    {
        class Program
        {
    
            static void Main(string[] args)
            {
    
                
                    double a, x, y,b;
                    Console.Write("a=");
                a = double.Parse(Console.ReadLine());
                    Console.Write("b=");
                   b= double.Parse( Console.ReadLine());
    
                for (x = a; x < b; x++);
                {
                    if (x <= 3)
                    {
                      y = Math.Log10(Math.Pow(x, 3));
                        Console.WriteLine("y");
                        Console.WriteLine("x");
                    }
    
                    else if (3 < x && x < 4.5)
                    {
                        y = 1 / Math.Abs(Math.Sin(x));
                        Console.WriteLine("y");
                        Console.WriteLine("x");
                    }
                    else if (x <= 4);
                    {
                        y = 1 / Math.Cos(1 / x);
                        Console.WriteLine("y");
                        Console.WriteLine("x");
                    }
                }                      
            }
        }
    }
    Last edited by zmbd; May 30 '22, 11:01 PM. Reason: [Z{Merged two threads, double post, cleaning thread; Placed required [CODE/] formatting; guessed that the code is C# move to correct forum}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Hello mckapusta
    Welcome to Bytes.com

    We can certainly help you troubleshoot your code; HOWEVER, you need to do a little work first
    1. Tell us what errors you're receiving
    2. Give us an example of the desired output
    3. Tell us what you have done to troubleshoot the code


    By, simply stating that your code "doesn't work," along with posting code that appears to have had very little if any troubleshooting performed and expecting someone to help doesn't usually result in much of an answer and may result in your thread being deleted. Instead, please tell us what you were expecting to happen, what actually happened.

    Comment

    • SioSio
      Contributor
      • Dec 2019
      • 272

      #3
      Are the semicolons on lines 17 and 32 intentionally written?

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Hello SioSio - thank you for your input here!

        However, my intention was to have OP do a bit of deep thought otherwise I would have simply pointed out the obvious errors on :
        Lines 17/32 - compiler level error - VS2019IDE points this out in the warnings debug
        Lines 22/23 - output level error - These, as written, do not produce what one would guess OP is expecting to happen
        Lines 29/30 - output level error - ditto
        Lines 35/36 - output level error - ditto

        We want to encourage our users to post and ask for help (that is what we are here for and enjoy doing - it's our hobby and a kind of pay-it-back for all of the help we received when we were just learning and with something we just can't get our heads around to find the solution ); however, in the long run it's better if some preliminary troubleshooting is done before posting and for OP to list any error messages and steps already taken. In the first case it helps us to narrow down the issues and in the second case it speeds things up because we don't have to "re-invent the wheel"

        Comment

        Working...