Computer Science, asked by pathakshobha300033, 9 months ago

I know this is long question but it is very important for me.

Attachments:

Answers

Answered by pesh20gathoni
1

Answer:

Void main()

{

float a[20];

int i,j,k,l;

Clrscr();

for (i=0;i < 20 ; i++)

{

Printf("Please enter the %d value ", &i+1 );

Scanf("%f",&a[i]);

}

j = 0; //reset count to 0 for numbers of equal to 0 values

k = 0; //reset count to 0 for numbers of greater than 0 values

l = 0; //reset count to 0 for numbers of less than 0 values

for (i = 0; i < 20; i++ )

{

If(a[i] = 0)

j++; // if number is equal to 0, count will add 1 into j

else if(a[i] > 0 )

k++; // if number is greter than 0, count will add 1 into k

else

l++; // else count will add 1 into l

}

Printf("\n\n\t Number of values equal to zero are %d", &j);

printf("\n\n\t Number of values Greater then zero are %d", &k);

printf("\n\n\t Number of values Less than zero are %d", &l);

}

Answered by poojan
2

Program that takes 20 float values into a one dimensional array and computes the given conditions.

Language used : Python Programming

Program :

n=int(input("Enter the number of values needed to be taken : "))

array=[]

greaterthanzero=0

equalszero=0

lessthanzero=0

#List is considered as the single dimensional array

#reading n elements into the list

for i in range(n):

   #As we have made sure that the inputs need to be float, the list takes float values only, resembling the array.

   y=float(input())

   array.append(y)

   if y>0:

       greaterthanzero+=1

   elif y==0:

       equalszero+=1

   elif y<0:

       lessthanzero+=1

print("Number of values that are greater than zero, in the array are : ",greaterthanzero)

print("Number of values that are equals to zero, in the array are : ",equalszero)

print("Number of values that are less than zero, in the array are : ",lessthanzero)

Input :

Enter the number of values needed to be taken : 20

-1.0

8.9

4.16

7.382

9.99

-28.34638

-0.1

4.999

3.20000

8456789.9234

-456789.789

-567.567

56789.456

5.68

0

0.00

5.07

753.678

0

4567.789

Output :

Number of values that are greater than zero, in the array are :  12

Number of values that are equals to zero, in the array are :  3

Number of values that are less than zero, in the array are :  5

Explanation :

First, we need to take the input of the range of float numbers needed to be taken. Let it be n. Now, write a loop that takes n float values, and on taking each input check if it is greater than zero, or less than zero or equals and increment corresponding variable to maintain count.

Once the n numbers are inputted, print the counts. That's it!

Hope it helps. Thank you!

Attachments:
Similar questions