-->

program to reverse a a string using function.

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

// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
void string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    string_reverse();                       // function calling
    return 0;                              // returning value 0
}
void string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string");                   // message declaration
  gets(string);                           // gets string from user
  strrev(string);                        // reverses the string and stores in memory
  puts(string);                      // displays  that reversed string
}
---------------------------------------------------------------------------------------------------

using Turbo c++
----------------------------------------------------------------------------------------------------
// program to reverse a string          // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
#include<conio.h>
void string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    string_reverse();                       // function calling
   getch();                                   //holds the output
    return 0;                              // returning value 0

}
void string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string");                   // message declaration
  gets(string);                           // gets string from user
  strrev(string);                        // reverses the string and stores in memory
  puts(string);                      // displays  that reversed string
}

program to get length of string using function

using codeblocks

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

// program to get length of a string          // title of program

#include <stdio.h>                           // header file to control input and output

#include<string.h>                           //header file to handle string function

void string_length();                       // function prototype

int main()                                  // main function returning integer value

{

    string_length();                       // function calling

    return 0;                              // returning value 0

}

void string_length()                       // function body

{

  char string[100];                       // string declaration

  puts("enter string");                   // message declaration

  gets(string);                           // gets string from user

  printf("length=%d",strlen(string));     // displays length with the help of strlen() function

}

---------------------------------------------------------------------------------------------
using turbo c++
---------------------------------------------------------------------------------------------------------
// program to get length of a string          // title of program
#include <stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
#include<conio.h>                          // header file to control console input and output
void string_length();                       // function prototype
int main()                                  // main function returning integer value
{
    string_length();                       // function calling
    getch();                                 // holds input and output
    return 0;                              // returning value 0
}
void string_length()                       // function body
{
  char string[100];                       // string declaration
  puts("enter string");                   // message declaration
  gets(string);                           // gets string from user
  printf("length=%d",strlen(string));     // displays length with the help of strlen() function

}

programs for storage classes

programs for storage classes

click the link below.

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

Storage class:- We understand here some programs which use different storage concept.


1) Automatic (also called local variables):

2) External storage (also called global storage or variables:

3)static storage:-

4)register storage:-

Recursive function programs

Recursive function programs
click the link given below.
---------------------------------------------------------------------------------------------

Recursive function:-

1)Find factorial value of a number using recursive function.

2)Find fibonacci series using recursive function.
3)WAP to find sum of natural numbers using recursive function.

4)

program using FUNCTION WITH ARGUMENTS AND RETURN VALUES.

program using FUNCTION WITH  ARGUMENTS AND  RETURN VALUES.


click the link given below.
---------------------------------------------------------------------------------------------------------------------------

1) WAP to pass array as parameter to input any five numbers and then find their sum.

                                                                                                                                        solution
2) wap to get length of string by passing string as parameter.
                                                                                                                                        solution

3)WAp to find greatest number among ten numbers. PAss array as parameter.

                                                                                                                                        solution
4)WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg. Pass Weight as an array as parameter.

                                                                                                                                            solution

5)WAP to search a number in a list of numbers using array as a parameter.
                                                                                                                                           solution

6)WAP to reverse a string.Pass string as parameter and return its reverse.

                                                                                                                                          
                                                                                                                                         solution

7) Wap to concatenate two strings.Pass string as parameter and return the result.

                                                                                                                                           solution

8)WAP to copy a string .Pass strings as parameter. Return that as output.

                                                                                                                                          solution

9)WAP to convert string into lowercase.PAss string as parameter and return as an output.

                                                                                                                                        solution

program using FUNCTION WITH NO ARGUMENTS AND RETURNING SOME VALUES.

program using FUNCTION WITH NO ARGUMENTS AND  RETURNING SOME VALUES.

click the link given below.
------------------------------------------------------------------------------------------------------------------
1)WAP to get factorial value of a number using function.It returns value with no parameter.

                                                                                                                          solution

2)WAP to get reverse of a number using function.

                                                                                                                         solution


                                                                                                                        
4) WAp to know a number is prime or composite or not using function.

                                                                                                                        solution

5)WAP to get square root of a number using function.


                                                                                                                        solution


                                                                                                                        

6)WAp to concatenate two strings. Use no arguments and return its output.

                                                                                                                      solution

                                                                                                                        
8)wap to find factorial value of a number using function.

                                                                                                                      solution

9)WAp to convert string into lowercase.Use no arguments and return value..

                                                                                                                     solution

10)WAP TO GET LENGTH OF STRING USING FUNCTION

       
                                                                                                                                         solution
11)Write a program to reverse a a string using function.

                                                                                                                                    SOLUTION 

program with FUNCTION WITH ARGUMENTS AND RETURNING NO VALUES.

FUNCTION WITH  ARGUMENTS AND  RETURNING NO VALUES.


click the link for program(below).
----------------------------------------------------------------------------------------------------------

1) WAP to pass array as parameter to input any five numbers and then find their sum.

                                                                                                                                        solution

2) wap to get length of string by passing string as parameter.
                                                                                                                                        solution


3)WAp to find greatest number among ten numbers. PAss array as parameter.

                                                                                                                                        solution

4)WAP to input weight of 100 students and count number of students who have weight in between 40 and 60 kg. Pass Weight as an array as parameter.


                                                                                                                                        solution


5)WAP to search a number in a list of numbers using array as a parameter.

                                                                                                                                           solution



6)WAP to input 'n' numbers and sort them in an order. PAss array as a parameter.
                                                 
                                                                                                                                           solution


7)WAP to input strings and sort them in alphabetical order. Pass string as a parameter.

                                                                                                                                         solution

8)WAp to find transpose of a matrix. Here , pass matrix as parameter.
 
                                                                                                                                        solution

9)WAP to find sum of two matrices. Here pass matrix as parameter.

                                                                                                                          solution

program to know a number is prime or composite or not using function.


using codeblock
-----------------------------------------------------------------------------------
//program to know a number is prime or composite or not using function..
#include<stdio.h>                      //header file
void prime_number();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
prime_number();                                     // function calling.
return 0;                                       //returns 0 value
}
void prime_number()                           // function body line ; also called function definition
{
 int i,number,count=0;                    // variable declaration
printf("enter a number\n");               //message display to input a number
scanf("%d",&number);                      //gets input
for(i=2;i<number;i++)                     //executing from 2 to <n
{
    if(number%i==0)                       //testing for next number
    {
        count=1;                        //assigning to  1 to count
   
    }
   
}   
 if(count==0)                                //testing count ;whetehre it has 0 or 1
 {
    printf("%d is prime, ",number);
 } 
 else
 {
     printf("%d is not prime number,i.e. it's a composite",number);
 }
}

---------------------------------------------------------------------------------------------------------
using turbo
--------------------------------------------------------------------------------------------------------
//program to know a number is prime or composite or not using function..
#include<stdio.h>                      //header file
#include<conio.h>
void prime_number();                // function prototype/declaration with return type zero.
int main()                              //main function
{
prime_number();                                     // function calling.
getch();                                       //holds the output
return 0;                                       //returns 0 value
}
void prime_number()                           // function body line ; also called function definition
{
 int i,number,count=0;                    // variable declaration
printf("enter a number\n");               //message display to input a number
scanf("%d",&number);                      //gets input
for(i=2;i<number;i++)                     //executing from 2 to <n
{
    if(number%i==0)                       //testing for next number
    {
        count=1;                        //assigning to  1 to count
   
    }
   
}   
 if(count==0)                                //testing count ;whether it has 0 or 1
 {
    printf("%d is prime, ",number);
 } 
 else
 {
     printf("%d is not prime number,i.e. it's a composite",number);
 }
}

program to find value of y raised to x using function.


using codeblocks
------------------------------------------------------------------------------------------------------------
//program to find value of y raised to x using function.
#include<stdio.h>                      //header file
#include<math.h>                        //for pow() function
void x_power_y();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
x_power_y();                                     // function calling.
return 0;                                       //returns 0 value
}
void x_power_y()                           // function body line ; also called function definition
{
 int x,y,output;                    // variable declaration
printf("enter a number;base(x)\n");    //message display to input a number
scanf("%d",&x);                //gets input
printf("enter power(y)\n");
scanf("%d",&y);                     //gets value for power.
output=pow(x,y);                    //finds power using pow() function
  printf("y raised to x=%d\n",output);    //display of output.
}

------------------------------------------------------------------------------------------------------
using turbo c++
-----------------------------------------------------------------------------------------------------------
//program to find value of y raised to x using function.
#include<stdio.h>                      //header file
#include<math.h>                        //for pow() function
void x_power_y();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
x_power_y();                                     // function calling.
return 0;                                       //returns 0 value
}
void x_power_y()                           // function body line ; also called function definition
{
 int x,y,output;                    // variable declaration
printf("enter a number;base(x)\n");    //message display to input a number
scanf("%d",&x);                //gets input
printf("enter power(y)\n");
scanf("%d",&y);                     //gets value for power.
output=pow(x,y);                    //finds power using pow() function
  printf("y raised to x=%d\n",output);    //display of output.
}
-----------------------------------------------------------------------------------------------------------------

on some online compiler, this program works even without math,h
But Better if we put it.

program to find factorial value of a number using function.

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

//program to find 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 i,n,facto=1;                    // variable declaration with 1 initialization
printf("enter a number\n");    //message display to input a number
scanf("%d",&n);                //gets input
for(i=1;i<=n;i++)       //loop running from 1 to n with increment 1 each time
{
       facto=facto*i;        //  multiplication of numbers repetitively
}
  
  printf("factorial value=%d\n",facto);    //display of output.
}
------------------------------------------------------------------------------------------------------------

using turboc++
-------------------------------------------------------------------------------------------------------------
//program  to find 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  value
}
void factorial()                             // function body line ; also called function definition
{
 int i,n,facto=1;                    // variable declaration with 1 initialization
printf("enter a number\n");    //message display to input a number
scanf("%d",&n);                //gets input
for(i=1;i<=n;i++)       //loop running from 1 to n with increment 1 each time
{
       facto=facto*i;        //  multiplication of numbers repetitively
}
  
  printf("factorial value=%d\n",facto);    //display of output.
}


----------------------------------------
factorial value of a number 6= 6x5x4x3x2x1 or
                                                 1x2x3x4x5x6

program to print multiplication table of a number using function

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

//program to print multiplication table of a number using function
#include<stdio.h>                      //header file
void m_table();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
m_table();                                     // function calling.
return 0;                                       //returns 0 value
}
void m_table()                             // function body line ; also called function definition
{
 int i,n;                    // variable declaration
printf("enter a number\n");    //message display to input a number
scanf("%d",&n);                //gets input
for(i=0;i<=10;i++)       //loop running from 0 to 10 with increment 1 each time
{
    printf("%d*%d=%d\n",n,i,n*i);           // displaying all the multiplied numbers
}
     
}

----------------------------------------------------------------------------------------------
using turboc++
--------------------------------------------------------------------------------------------------------
//program to print multiplication table of a number using function.
#include<stdio.h>                      //header file
#include<conio.h>
void m_table();                          // function prototype/declaration with return type zero.
void main()                              //main function
{
m_table();                                     // function calling.
getch();                                       //returns 0 value
}
void m_table()                             // function body line ; also called function definition
{
 int i,n;                    // variable declaration
printf("enter a number\n");    //message display to input a number
scanf("%d",&n);                //gets input
for(i=0;i<=10;i++)       //loop running from 0 to 10 with increment 1 each time
{
    printf("%d*%d=%d\n",n,i,n*i);           // displaying all the multiplied numbers
}
     
}

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

marking scheme

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

click here to goto drive.

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.*/

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.*/

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.*/