-->

program to generate series 1,2,3,4,5,.............100 using function

using codeblock
----------------------------------------------------------------------------------------
// to generate 1,2,3,4,5,....100 series using function.
#include<stdio.h>                      //header file
void series();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
series();                                     // function calling.
return 0;                                       //returns 0 value
}
void series()                              // function body line ; also called function definition
{
 int i;                    // variable declaration
for(i=1;i<=100;i++)       //loop running from 1 to 100 with increment 1 each time
{
    printf("%d\n",i);      //output
}
}

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

using turboc++
---------------------------------------------------------------------------------------------------
// to generate 1,2,3,4,5,....100 series using function.
#include<stdio.h>                      //header file
#include<conio.h>
void series();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
series();                                     // function calling.
getch();                                       //holds the output
}
void series()                              // function body line ; also called function definition
{
 int i;                    // variable declaration
for(i=1;i<=100;i++)       //loop running from 1 to 100 with increment 1 each time
{
    printf("%d\n",i);      //output
}
}


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

No comments:

Post a Comment