Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem #1 Pointers should not be used for this program. Write a single C progra

ID: 651658 • Letter: P

Question

Problem #1


Pointers should not be used for this program.

Write a single C program that reads up to 21 floating-point numbers entered at the keyboard into a onedimensional array and provides the count of both positive and negative numbers and the total of the negative and the positive numbers. The program will stop reading sets of values when the sentinel 0 is entered. Pointers should not be used for this program.

The program should not accept a negative quantity. That would be no participation.

The program should not accept a quantity above 21. That is too much participation.
No <isostream> use <stdio.h> instead.

Sample output:

Sample Output Senario 1 Name and Date: Course and Class Problem: numbers Statement: Arrays Name and Date: Course and Class #: Problem: numbers Statement: Arrays The array accepts values from the user, counts&totals; positives & negatives,. The array accepts values from the user, counts & totals positives & negatives. How many numbers will you enter (positives & negatives) or 0 to quit: 22 Press any key to continue... How many numbers will you enter (positives & negatives) or 0 to quit: -5 Press any key to continue. Press any key to continue

Explanation / Answer

this is the solution .......

#include

int main()

{

    int p_nArr[20]={0};  

    int nCount_Pos = 0;

    int nCount_Neg = 0;

    int num=0;

    int SIZEOFARRAY= 0;

    int index;

    printf("nEnter the Size of the array");

    scanf("%d",&SIZEOFARRAY);

    printf("nEnter the elements ::n");

    for( index = 0; index < SIZEOFARRAY; index++ )

    {

         scanf("%d",&p_nArr[index]);

         if (p_nArr[index] > 0 )

            nCount_Pos++ ;

         else if (p_nArr[index] < 0 )

             nCount_Neg++;

    }

    if ( nCount_Neg > 0)

    {

       printf("nNumber of negative numbers in the array are :: %dn", nCount_Neg);

       for( index = 0; index < SIZEOFARRAY; index++ )     

       {

          if (p_nArr[index] < 0 )

         printf("%d ",p_nArr[index]);          

       }

    }

    if ( nCount_Pos > 0 )

    {

           printf("nNumber of Positive numbers in the array are :: %dn",nCount_Pos);

           for( index = 0; index < SIZEOFARRAY; index++ )     

           {

              if (p_nArr[index] > 0 )

             printf("%d ",p_nArr[index]);          

           }        

    }

    getch();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote