Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Q13-Given an array of N integers, check if it contains any negative integer.
- Ans-import java.io.*;
- import java.util.*;
- class Main {
- public static void main (String[] args) {
- Scanner sc=new Scanner(System.in);
- int len=sc.nextInt();
- int array[]=new int[len];
- boolean containsNegative=false;
- for(int i=0;i<len;i++){
- array[i]=sc.nextInt();
- if(array[i]<0){
- containsNegative=true;
- }
- }
- if(containsNegative){
- System.out.println("Yes");
- }
- else{
- System.out.println("No");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement