C# Program to Convert Negative Values an Integer Array Into Positive

Hello, C# Program to Convert Negative Values an Integer Array Into Positive We are going to know the vibrancy of. There are many interesting facts in this article. Let’s move on to the articles

C# Program to Convert Negative Values an Integer Array Into Positive

C# Program to Convert Negative Values an Integer Array Into Positive

// C# program to convert negative values 
//an integer array into positive.

using System;

class Demo
{
    public static void Main()
    {
        int[] arr = { 10, -20, 30, -40, 50, -60, 70 };
        int loop = 0;
        
        for (loop = 0; loop < arr.Length; loop++)
        {
            if (arr[loop] < 0)
                arr[loop] = -arr[loop];
        }

        Console.WriteLine("Array elements after conversion:");
        for (loop = 0; loop < arr.Length; loop++)
        {
            Console.Write(arr[loop]+" ");
        }
        Console.WriteLine();
    }
}
Array elements after conversion:
10 20 30 40 50 60 70
Press any key to continue . . .

Final Words

We hope that you and your doubts have been resolved through the article C# Program to Convert Negative Values an Integer Array Into Positive. And if you have any doubts let us know via the comment box. We cater to your doubts. And if you liked this article, we ask you to share it with your friends.

Hi, I'm Selva a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment