Hi all,
please i need help.
i trying to write simple program in c# express 2010 in console application:

i am trying to write program to put 5 numbers on array and the check if have 2 Consecutive numbers(2 and 3 or 8 and 9 etc...) if yes the program will write to the following numbers.
i want the pication11.program.Max()': not all code paths retrogram will input the numbers to array in function. i did it not correct because i got error:
"ConsoleApplurn a value"
my wrong code:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplication11


    class Program
    {

        static void Main(string[] args)
        {


            Console.WriteLine("The folowing numbers:");




        }









        public static int Max()
        {
            int v=1;
            int[] arr = new int[5];
            for(int i=1;i<=5;i++)
            {

                arr[i] = int.Parse(Console.ReadLine());
            Console.WriteLine("Please enter number");

            return v;


            }

        }

    }

}
{

please help me.

Recommended Answers

All 4 Replies

Well, all that does is write out: The folowing numbers:

You also have a brace the wrong way around at the end of the file, you never call your Max method and it will return after one iteration of the loop. Additionally, v is set to 1 and never changes, so your method will always return 1.

The error: not all code paths return a value tells you that return v; (line 46) shouldn't be inside the for loop. Simple fix: move that return instruction outside the loop.

Also, a method/function can only return once.

i mean this: Hi all,
please i need help.
i trying to write simple program in c# express 2010 in console application:

i am trying to write program to put 5 numbers on array and the check if have 2 Consecutive numbers(2 and 3 or 8 and 9 etc...) if yes the program will write to the Consecutive numbers.
but i got error please someone can write me the correct program?

Have you at least put any effort into implementing the changes you've been told about? If so show your updated code and outline what it's doing wrong. We're not in the habit of doing people's homework for them.

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.