-->

program to know a number is positive or negative or zero using function.

using codeblock
---------------------------------


//program to know a number is positive or negative or zero using function.
#include<stdio.h>                      //header file
void number();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
number();                                     // function calling.
return 0;                                       //returns 0 value
}
void number()                              // function body line ; also called function definition
{
 int number;                    // variable declaration 
printf("enter number\n");           // displays message to input data
scanf("%d",&number);        // gets data from user.
if(number>0)                     //condition testing
{
printf("%d is positive\n",number);    // displays output
}

else if(number<0)                     //second condition testing
{
   printf("%d is negative\n",number); 
}
else                                   // if none of above condition satisfy
{
    printf("%d is zero\n",number);      //output
}
}


------------------------------------------------------------------------------------------
using turboc++
----------------------------------------------------------------------------------------------
//program to know a number is positive or negative or zero using function.
#include<stdio.h>                      //header file
#include<conio.h>
void number();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
number();                                     // function calling.
getch();                                       //holds the output
}
void number()                              // function body line ; also called function definition
{
 int number;                    // variable declaration 
printf("enter number\n");           // displays message to input data
scanf("%d",&number);        // gets data from user.
if(number>0)                     //condition testing
{
printf("%d is positive\n",number);    // displays output
}

else if(number<0)                     //second condition testing
{
   printf("%d is negative\n",number); 
}
else                                   // if none of above condition satisfy
{
    printf("%d is zero\n",number);      //output
}
}

No comments:

Post a Comment