Skip to main content

Posts

Featured

Closest to Zero

 You have been given an integer array A of size N . You need to print the number with the value closest to zero . If there are multiple elements , print the number with the greater value. Input Format: First Line: An integer N denoting  the size  of the array A. Next Line: N  space - separated integers denoting the elements of the array A Output Format: Print the value  of the element closest to zero . If there  are multiple candidates, then  print the number  with greater value. Constraints 1<=N<=100 1<=|Ai|<=100 , where |Ai| denotes the absolute value of Ai Sample input :  5 0 2 3 4 5 Sample output : 0 Solution :-  C#  using System ; using System . IO ; using System . Linq ; using System . Collections . Generic ; public class HelloWorld { static public void Main () { String line ; line = Console . ReadLine (); int N = Convert . ToInt32 ( line ); line = Console . ReadLine (); int [] A = new int [ N ];

Latest Posts

Writing is inspiring, isn't it?

trip to tekanpur

THE REPUBLIC INDIA !!!