Solution with out using functions
Solution using functions without passing arguments
Solution using functions and by passing arguments
Solution : Without using function
Program/Source Code
#include <stdio.h> int main() { int n; printf("Enter any no "); scanf("%d",&n); if(n<0) printf("Number is -ve"); else printf("Number is not -ve"); return 0; }
Output:
case 1:
Enter any no 26
Number is not -ve
case 2:
Enter any no -63
Number is -ve
Solution : Using function Without Passing Arguments
Program/Source Code
#include <stdio.h> void check() { int n; printf("Enter any no "); scanf("%d",&n); if(n<0) printf("Number is -ve"); else printf("Number is not -ve"); } int main() { check(); return 0; }
Output:
case 1:
Enter any no 32
Number is not -ve
case 2:
Enter any no -87
Number is -ve
Solution : Using function Passing Arguments
Program/Source Code
#include <stdio.h> void check(int n) { if(n<0) printf("Number is -ve"); else printf("Number is not -ve"); } int main() { int n; printf("Enter any no "); scanf("%d",&n); check(n); return 0; }
Output:
case 1:
Enter any no 34
Number is not -ve
case 2:
Enter any no -34
Number is -ve
Previous:C Program to check and print whether the number is +ve or not
Next: C program to check and print whether the number is even or not |
Tutorials | Technical Questions | Interview Questions |
---|---|---|
C Programming C++ Programming Class 11 (Python) Class 12 (Python) |
C Language C++ Programming Python |
C Interview Questions C++ Interview Questions C Programs C++ Programs |