Practical 25


Aim:- Write a program, which takes five numbers as command line argument from user, store them in one-dimensional array and display count of negative numbers.

JAVA Code :-

import java.lang.*;
class TestArray
{
   public static void main(String[] args)
   {
      int c=0;
      int a[]=new int[5];
      for(int i=0;i<5;i++)
      {
         a[i]=Integer.parseInt(args[i]);
         if(a[i]<0)
          c++;
       }
        System.out.println("No. of negtive number: " +c);
     }
}

Output:-



No comments:

Post a Comment

Programs

Home Aim:- Write a program to convert rupees to dollar. (60rupees=1 dollar). Aim:- Write a program that calculate percentage marks...