0

Greetings:

I am having some errors on this code:
Any ideas what is missing in the code?
Thanks,

Dani

`

     #include<stdio.h>
     void func_count(int);

     int main( )
    {
            int i, num;

           for(i = 1; i < 21; i ++ )
           {
                 scanf(“%d”, &num);
                 if(num < 1 || num > 6)
                       printf(“Error: Invalid number %d\n”);
                 else
               func_count(num);
           }
           func_count(0);
           return 0;
     }


      func_count(int n)                          /* count occurrances of n */
     {
             static int count2, count5;
     count2 += ( n == 2);
     count5 += ( n == 5);
      if( n== 0)
     {
                    printf(“There are %d occurances of 2\n”, cnt_2);
                    printf(“There are %d occurances of 5\n”, cnt_5);
              }

               return;
      }

`

2
Contributors
1
Reply
18
Views
2 Years
Discussion Span
Last Post by tinstaafl
0

Your main problems appear to be in func_count. you didn't declare the return type, which in this case should be void, since that is how your prototype has it declared. Also,the 2 variables you have in that function are count2 and count5, however your printf statement is trying to print cnt_2 and cnt_5 which aren't declared anywhere.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.