Results 1 to 2 of 2

Thread: C program for to count (-) and (+) numbers.

  1. #1
    MoralesMyers is offline Senior Member
    Join Date
    Dec 2009
    Posts
    202
    Rep Power
    3

    Default C program for to count (-) and (+) numbers.

    Suppose we give five positive and eight negative number then output result should show the count of positive number as five and count of negative number as an eight. How can I write the program for count positive and negative number? Any help would be highly appreciated. Thanks.

  2. #2
    PowellParker is offline Senior Member
    Join Date
    Dec 2009
    Posts
    210
    Rep Power
    3

    Default

    1) Try the following code which is helpful for u.

    void main( )
    {

    int a[50],n, count_n=0,count_p=0,i;
    printf(“Enter the size of the array\n”);
    scanf(“%d”, &n);
    printf(“Enter the elements of the array\n”);
    (for i=0;i < n; i++)
    {
    scanf(“%d”,&a[i]);
    }

    for(i=0;i < n;i++)
    {
    if(a[i] < 0)
    count_n++;
    else
    count_p++;
    }
    printf(“There are %d negative numbers in the array\n”,count_neg);
    printf(“There are %d positive numbers in the array\n”,count_pos);
    }

Similar Threads

  1. Program for prime numbers in c
    By ScottWright in forum Programming
    Replies: 2
    Last Post: 04-30-2010, 01:54 PM
  2. How To Count The numeral Of typeset?
    By CoxWatson in forum Programming
    Replies: 1
    Last Post: 02-10-2010, 04:25 PM
  3. C# program to print random numbers
    By Garcíarobine in forum Programming
    Replies: 2
    Last Post: 01-13-2010, 05:47 PM
  4. Word count for multiples files
    By Fred Morgan in forum Programming
    Replies: 0
    Last Post: 07-27-2009, 11:37 AM
  5. Transistor Count
    By vandana43 in forum Processors
    Replies: 0
    Last Post: 03-19-2008, 11:15 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48