-->

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
}
}

to know a number is even or odd using function.

using codeblocks
----------------------------------------------------------------------------------------------------
//to know a number is even or odd using function.
#include<stdio.h>                      //header file
void evenodd();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
evenodd();                                     // function calling.
return 0;                                       //returns 0 value
}
void evenodd()                              // 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%2==0)                     //condition testing
{
printf("%f is even\n",number);    // displays output
}

else
{
   printf("%d is odd\n",number); //displays output
}
}



---------------------------------------------------------------------------------------

using turbo c++
----------------------------------------------------------------------------
//to know a number is even or odd using function.
#include<stdio.h>                      //header file
#include<conio.h>
void evenodd();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
evenodd();                                     // function calling.
getch();                                       //returns 0 value
}
void evenodd()                              // 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%2==0)                     //condition testing
{
printf("%f is even\n",number);    // displays output
}

else
{
   printf("%d is odd\n",number); //displays output
}
}



function related programs with types

function related programs with types


click below to see programs:
-----------------------------------------------------------------------------------------------

 FUNCTION WITH NO ARGUMENTS AND NO RETURN VALUES.


program to print smallest number among three numbers using function.

using codeblock
--------------------------------------------------------------------------------------------------------------------
//to print smallest number among three numbers using function.
#include<stdio.h>                      //header file
void smallest();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
smallest();                                     // function calling.
return 0;                                       //returns 0 value
}
void smallest()                              // function body line ; also called function definition
{
 float number1,number2,number3;                    // variable declaration 
printf("enter three numbers\n");           // displays message to input data
scanf("%f%f%f",&number1,&number2,&number3);        // gets data from user.
if(number1>number2 &&number1>number3)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else if(number2>number1 &&number2>number3)
{
    printf("%f is greater\n",number2);    // displays output for second condition
}
else
{
   printf("%f is greater\n",number3); 
}

}

--------------------------------------------------------------------------------------------------------------------------
using turbo C++
-----------------------------------------------------------------
//to print smallest number among three numbers using function.
#include<stdio.h>                      //header file
#include<conio.h>
void smallest();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
smallest();                                     // function calling.
getch();                                       //returns 0 value
}
void smallest()                              // function body line ; also called function definition
{
 float number1,number2,number3;                    // variable declaration 
printf("enter three numbers\n");           // displays message to input data
scanf("%f%f%f",&number1,&number2,&number3);        // gets data from user.
if(number1>number2 &&number1>number3)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else if(number2>number1 &&number2>number3)
{
    printf("%f is greater\n",number2);    // displays output for second condition
}
else
{
   printf("%f is greater\n",number3); 
}

}

program to get greatest number between two numbers

using codeblocks
-------------------------------------------------------

// program to get greatest number between two numbers
#include<stdio.h>                      //header file
void greater();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
greater();                                     // function calling.
return 0;                                       //returns 0 value
}
void greater()                              // function body line ; also called function definition
{
 float number1,number2;                    // variable declaration
printf("enter two numbers\n");           // displays message to input data
scanf("%f%f",&number1,&number2);        // gets data from user.
if(number1>number2)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else
{
    printf("%f is greater\n",number2);    // displays output if the condition did not satisfy
}
}

/* here we have used top down approach. i.e calling from top and writing its body line down.
 we can also reverse the process.*/


-------------------------------------------------------------------------
using turbo C++
---------------
//program to get greatest number between two numbers
#include<stdio.h>                      //header file
#include<conio.h>
void greater();                          // function prototype/declaration with return type zero.
void main()                                //main function
{
greater();                                     // function calling.
getch();                                       //holds the output on screen
}
void greater()                              // function body line ; also called function definition
{
 float number1,number2;                    // variable declaration
printf("enter two numbers\n");           // displays message to input data
scanf("%f%f",&number1,&number2);        // gets data from user.
if(number1>number2)                     //condition testing
{
printf("%f is greater\n",number1);    // displays output
}
else
{
    printf("%f is greater\n",number2);    // displays output if the condition did not satisfy
}
}

program to draw a rectangle.




//drawing rectangle
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int gdriver, gmode;    //variables declaration
gdriver=DETECT;        // detection of graphics driver

initgraph(&gdriver, &gmode, "c:\\tc\\BGI");
       /* initialize graphics and local variables with path in TC folder*/
       /* gmode is for graphics mode you want to work. */
rectangle(20,20,200,200);//(left,top) is the upper left corner of the
//rectangle, and (right,bottom) is its lower
//right corner.
//left is for x coordianate value and top is for
// y coordinate value . similarly right and bottom
// are for x and y coordinates res.
//give bigger value for all.
getch();          //gets one character from user and closes the graphics.
closegraph();     //closes graphics.h
}







program to draw a circle

//drawing circle
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
clrscr();
int gdriver, gmode;    //variables declaration
gdriver=DETECT;        // detection of graphics driver

initgraph(&gdriver, &gmode, "c:\\tc\\BGI");
       /* initialize graphics and local variables with path in TC folder*/
       /* gmode is for graphics mode you want to work. */
circle(40,40,30);  // circle with starting and ending angle (coordinate value for x and y of screen)
  //where you want to display circle;for x and y res.
  //last argument is radius.
getch();          //gets one character from user and closes the graphics.
closegraph();     //closes graphics.h
}