[Solved] Create a function in C [closed]


Your scanf and printf formatting had issues. Also the conditional check in the if statements were also wrong.

You can modify the code as below for proper working…

#include <stdio.h>
#include <stdlib.h>

 void Negative_Count(long int,long int);

  int main(void) {

    long num1,num2;

    printf("Enter two number: ");
    scanf("%ld%ld",&num1,&num2);
    printf("you entered %ld%ld \n",num1,num2);

    Negative_Count(num1,num2);

    return 0;

}

 void Negative_Count(long int num1,long int num2)
 {
       if (num1<0 && num2<0) {     
        printf("%ld , %ld are negative.",num1,num2);
       }
       else if (num1>0 && num2>0) { 
        printf("%ld , %ld are positive.",num1,num2);
       }
       else if (num1>0 && num2<0){
        printf("%ld is negative",num2);
       }
       else if (num1<0 && num2>0){
        printf("%ld is negative",num1);
       }
 }

solved Create a function in C [closed]