Computer Science, asked by guptji9264, 2 months ago

2. Take 20 integer inputs from user and print the following:
number of positive numbers
number of negative numbers
number of odd numbers
number of even numbers
number of o .
3. Find the largest and smallest elements of an array​

Answers

Answered by Rameshjangid
0

Answer:

The programming language used is Python

Explanation:

p,n,o,e,z=0,0,0,0,0

#Here i declared all the variable together, you can also write them seperately

print("Enter 20 integers\n")

for i in range(1,20+1):

n=(int)(input())

if(n>0):

p+=1

if(n<0):

n+=1

if(n%2!=0):

o+=1

if(n%2==0):

e+=1

if(n==0):

z+=1

print("no. of Positive numbers:",p)

print("no. of Negative numbers:",n)

print("no. of odd numbers:",o)

print("no. of even numbers:",e)

print("no. of zeroes",z)

Variable Description:-

p:- to calculate no. of positive numbers

n:- to calculate no. of negative numbers

o:- to calculate no. of odd numbers

e:- to calculate no. of even numbers

z:- to calculate no. of zeroes

Program Explaination:-

The program runs a loop from 1 to 20.

Then it accepts the numbers as input from the user

Then it checks if number is even or odd or positive or negative or 0 ..if any of them is true, then it executes that statement

once Loop value is >20, loop terminates

Learn more about similar questions visit:

https://brainly.in/question/36957889?referrer=searchResults

https://brainly.in/question/13000957?referrer=searchResults

#SPJ1

Attachments:
Similar questions