Your Ad Here

Saturday, May 24, 2008

Negate the positive Elements of The Array

// C# program to Negate the positive Elements of The Array

using System;
using System.Collections.Generic;
using System.Text;

namespace Step2
{
class negate
{
public static void Main()
{
int[] a = new int[10];
for (int i = 0; i < 10; i++)
{
a[i] = Convert.ToInt16(Console.ReadLine());
if (a[i] > 0)
a[i] = -a[i];
}
Console.WriteLine("Elements:");
for (int i = 0; i < 10; i++)
{
Console.WriteLine(a[i]);
}
}
}
}

No comments: