3 integer variables from the user ( a, b, c ) and find how many of them are negative numbers. After finding out the total count of negative numbers, return the count. for no negative numbers, count will be 0.
Constraints -10^6<=a<=10^6 -10^6<=b<=10^6 -10^6<=c<=10^6
public class Main { static int printCount(int a, int b, int c){ int count =0; for(int i=0; i<a || i<b || i<c; i++){ if(a<0 || b<0 || c<0){ count++; } } return count; } } public static void main(String[] args) throws Throwable { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); System.out.println(printCount(a, b, c)); } }
a
b
c
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)