-->

Saturday, December 22, 2018

program to display all even numbers lying 1 and 200 using function.

using codeblocks
-----------------------------------------------------------------------------------------
//program to display all even numbers lying 1 and 200 using function.
#include<stdio.h>                      //header file
void even_number();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
even_number();                                     // function calling.
return 0;                                       //returns 0 value
}
void even_number()                              // function body line ; also called function definition
{
 int i;                    // variable declaration
for(i=0;i<=200;i=i+2)       //loop running from 0 to 200 with increment 2 each time
{
    printf("%d\n",i);           // displaying all the numbers
}
     
}

Saturday, December 15, 2018

marking scheme

Dear students,
 Please open the file attached here with.
This file is in google drive.

click here to goto drive.

Thursday, December 13, 2018

program to get square root of a number using function.

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

//program to get  square root of a number using function.
#include <stdio.h>  //header file
#include<math.h>
void square_root();//function prototype
int main()                 //main function
{
    square_root();          // function calliing
    return 0;             // returning 0 value
}

void square_root()      //function body line/definition
{
    float n,square;       // initilizating value 1
    printf("enter value");// display of those value
    scanf("%f",&n);
   
        square=sqrt(n);            // finding sum of two numbers
        printf("square root=%f\n",square);//display of that sum
     
}
-------------------------------------------------------------------------------------------------
using turbo c++
-------------------------------------------------------------------------------------------------
//program to get  square root of a number using function.
#include <stdio.h>  //header file
#include<math.h>
#include<conio.h>
void square_root();//function prototype
void main()                 //main function
{
    square_root();          // function calliing
    getch();             // holds the output
}

void square_root()      //function body line/definition
{
    float n,square;       // initilizating value 1
    printf("enter value");// display of those value
    scanf("%f",&n);
   
        square=sqrt(n);            // finding sum of two numbers
        printf("square root=%f\n",square);//display of that sum
     
}

program to get Fibonacci series 1,1,2,3,5,8,.... 20th term.

using codeblocks
-----------------------------------------------------------------------------------------------------
//program to get Fibonacci series 1,1,2,3,5,8,.... 20th term.

#include <stdio.h>  //header file
void fibonacci();//function prototype
int main()                 //main function
{
    fibonacci();          // function calling
    return 0;             // returning 0 value
}

void fibonacci()      //function body line/definition
{
    int a=1,b=1,c,i;       // initializing value 1
    printf("%d\n%d\n",a,b);// display of those value
    for(i=1;i<=18;i++)     // running loop for 18 times
    {
        c=a+b;            // finding sum of two numbers
        printf("%d\n",c);//display of that sum
        a=b;             //assigning b to a and c to b.
        b=c;
    }
}


----------------------------------------------------------------------------------------------------------
using turboc++
-----------------------------------------------------------------------------------------

//program to get Fibonacci series 1,1,2,3,5,8,.... 20th term.

#include <stdio.h>  //header file
#include<conio.h>//header file
void fibonacci();//function prototype
int main()                 //main function
{
    fibonacci();          // function calling
    getch();             //holds the output
}

void fibonacci()      //function body line/definition
{
    int a=1,b=1,c,i;       // initializing value 1
    printf("%d\n%d\n",a,b);// display of those value
    for(i=1;i<=18;i++)     // running loop for 18 times
    {
        c=a+b;            // finding sum of two numbers
        printf("%d\n",c);//display of that sum
        a=b;             //assigning b to a and c to b.
        b=c;
    }
}

program to get reverse of a number using function


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

//program to get reverse of a number using function

#include<stdio.h>                      //header file
void reverse();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
reverse();                                     // function calling.
return 0;                                       //returns 0 value
}
void reverse()                              // function body line ; also called function definition
{
int rem;                             //initialization to value 1
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(;n!=0;)                     //loop running from 1 to 100 with increment 1 each time
{
    rem=n%10;               //finding remainder
    printf("%d",rem);       //output
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
   

}
------------------------------------------------------------------------------------------------------

using turboc++
--------------------------------------------------------------------------------------------------
//program to get reverse of a number using function
#include<stdio.h>                      //header file
#include<conio.h>
void reverse();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
reverse();                                     // function calling.
getch();                                       //holds the output.
}
void reverse()                              // function body line ; also called function definition
{
int rem;                             
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(;n!=0;)                     //loop running until its value reaches 0 each time
{
    rem=n%10;               //finding remainder
    printf("%d",rem);       //output
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
   

}

program to get factorial value of a number using function

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

//program to get factorial value of a number using function
#include<stdio.h>                      //header file
void factorial();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
factorial();                                     // function calling.
return 0;                                       //returns 0 value
}
void factorial()                              // function body line ; also called function definition
{
int factorial_value=1,i;                             //initialization to value 1
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(i=1;i<=n;i++)                     //loop running from 1 to 100 with increment 1 each time
{
    factorial_value=factorial_value*i;                //formulation for factorial
}
printf("factorial=%d\n",factorial_value);      //output
}
--------------------------------------------------------------------------------------------------
using turboc++
------------------------------------------------------------------------------------------------
//program to get factorial value of a number using function
#include<stdio.h>                      //header file
#include<conio.h>
void factorial();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
factorial();                         // function calling.
getch ();                                       //holds the output
}
void factorial()                              // function body line ; also called function definition
{
int factorial_value=1,i;                             //initialization to value 1
 int n;                                       // variable declaration
 printf("enter a number\n");
 scanf("%d",&n);                            //input
for(i=1;i<=n;i++)                     //loop running from 1 to 100 with increment 1 each time
{
    factorial_value=factorial_value*i;                //formulation for factorial
}
printf("factorial=%d\n",factorial_value);      //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.*/

Wednesday, December 12, 2018

program to get sum of 1,2,3,4,5,.............100 using function

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


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


----------------------------------------------------------------------------------------------------------
using turboc++
-------------------------------------------------------------------------------------------------
//program get sum of  1,2,3,4,5,.............100 using function
#include<stdio.h>                      //header file
#include<conio.h>
void sum_series();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
sum_series();                                     // function calling.
getch();                                       //returns 0 value
}
void sum_series()                              // function body line ; also called function definition
{
int sum=0;           //initialization of sum to zero
 int i;                    // variable declaration 
for(i=1;i<=100;i++)       //loop running from 1 to 100 with increment 1 each time
{
    sum=sum+i;           // summing all the numbers repetitively
}
printf("sum=%d\n",sum);      //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.*/