-->

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

in turboc++
-----------------------------------------------------------------------------------------------------------

//WAP to concatenate two  strings using(strcat()) function.Pass no parameters and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat();//prototype of function(must as pointer)
int main()
{
    printf("merged string=%s\n",stringcat());//prints with calling
     getch();
    return 0;
}
char *stringcat()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input

   
    return strcat(name,name1);//returning the concatenated string
}









----------------------------------------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass no parameters and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat();//prototype of function(must as pointer)
int main()
{
    printf("merged string=%s\n",stringcat());//prints with calling
     getch();
    return 0;
}
char *stringcat()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input

   
    return strcat(name,name1);//returning the concatenated string
}

WAP to get square root of a number using function.

in turboc++
----------------------------------------------------------------------------------------

//program to get  square root of a number using function.Use no argument and return some value
#include <stdio.h>  //header file
#include<math.h>
#include<conio.h>
 float square_root();//function prototype
int main()                 //main function
{
    printf("square root=%f",square_root());          // function calliing with output
    getch();
    return 0;             // returning 0 value
}

float 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
        return square;      //return of square
   
}










-------------------------------------------------------------------------
in codeblocks
--------------------------------------------------------------------------------------------------
//program to get  square root of a number using function.Use no argument and return some value
#include <stdio.h>  //header file
#include<math.h>
#include<conio.h>
 float square_root();//function prototype
int main()                 //main function
{
    printf("square root=%f",square_root());          // function calliing with output
    getch();
    return 0;             // returning 0 value
}

float 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
        return square;      //return of square
   
}

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

turboc++
-------------------------------------------------------------------------------------------------

//program to know a number is prime or composite or not using function.use no parameter;use return value
#include<stdio.h>                      //header file
#include<conio.h>
int prime_number();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
    int result;
result=prime_number();                                     // function calling.
if(result==0)                        //condition testing
{
    printf("it is prime\n");         //printing output
   
}
else
{
printf("it is not prime\n");
}
getch();
return 0;                                       //returns 0 value
}
int 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
 {
    return count;                    //returning count
 }
 else
 {
     return;                      //returns nothing
 }
}







--------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------
//program to know a number is prime or composite or not using function.use no parameter;use return value
#include<stdio.h>                      //header file
#include<conio.h>
int prime_number();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
    int result;
result=prime_number();                                     // function calling.
if(result==0)                        //condition testing
{
    printf("it is prime\n");         //printing output
   
}
else
{
printf("it is not prime\n");
}
getch();
return 0;                                       //returns 0 value
}
int 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
 {
    return count;                    //returning count
 }
 else
 {
     return;                      //returns nothing
 }
}

WAP to get reverse of a number using function.

using turboc++
--------------------------------------------------------------------------------------------
//program to get reverse of a number using function.use no arguments and return some value

#include<stdio.h>                      //header file
#include<conio.h>
int reverse();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
printf("reverse =%d",reverse());            // function callingwith output.
getch();
return 0;                                       //returns 0 value
}
int reverse()                              // function body line ; also called function definition
{
int s=0,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
    s=s*10+rem;
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
 
return s;            //returning value       
}






---------------------------------------------------------------------------------------------------------------
using codeblocks:
-------------------------------
//program to get reverse of a number using function.use no arguments and return some value

#include<stdio.h>                      //header file
int reverse();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
printf("reverse =%d",reverse());            // function callingwith output.
return 0;                                       //returns 0 value
}
int reverse()                              // function body line ; also called function definition
{
int s=0,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
    s=s*10+rem;
    n=n/10;                 //finding next integer number and trasnforming that into 'n'
}
 
return s;            //returning value       
}

wap to find factorial value of a number using function.

in turboc++
-----------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h>                      //header file
#include<conio.h>
int factorial();                          // function prototype/declaration with return type int.
int main()                              //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
return 0;                                       //returns 0 value
}
int 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
}
return factorial_value;      // returning output of function
}



------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------
//program to get factorial value of a number using function.use no arguments and return some value
#include<stdio.h>                      //header file
int factorial();                          // function prototype/declaration with return type int.
int main()                              //main function
{
printf("factorial value=%d",factorial()); // function calling with value.
getch();
return 0;                                       //returns 0 value
}
int 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
}
return factorial_value;      // returning output of function
}

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

in turboc++
------------------------------------------------------------------------------------------



// program to convert a string  into lowercase        // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
char  *string_lwr();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("LOWERCASE=%s",string_lwr());                       // function calling with output
   getch();
   return 0;                              // returning value 0
}
char *string_lwr()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user

 return strlwr(string);                     //returns string

}












----------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------

// program to convert a string  into lowercase        // title of program
#include<stdio.h>                           // header file to control input and output
#include<string.h>                           //header file to handle string function
char  *string_lwr();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("LOWERCASE=%s",string_lwr());                       // function calling with output
    return 0;                              // returning value 0
}
char *string_lwr()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user

 return strlwr(string);                     //returns string

}

Write a program to reverse a a string using function. Use no arguments and return value

in turboc++
----------------------------------------------------------------------------------

// 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
char  *string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("reverse=%s",string_reverse());                       // function calling with output
    return 0;                              // returning value 0
}
char *string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user

 return strrev(string);                     //returns string

}

----------------------------------------------------------------------------
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
char  *string_reverse();                       // function prototype
int main()                                  // main function returning integer value
{
    printf("reverse=%s",string_reverse());                       // function calling with output
    return 0;                              // returning value 0
}
char *string_reverse()                       // function body
{
  char string[100];                       // string declaration
  printf("enter string\n");                   // message declaration
  gets(string);                           // gets string from user
 
 return strrev(string);                     //returns string

}

WAP TO GET LENGTH OF STRING USING FUNCTION

in turbcoC++
-----------------------------------------------------------------

//program to find length of a string. USe no arguments and return its value
#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
int string_length();                       // function prototype
int main()                                  // main function returning integer value
{
   printf("length=%d", string_length());                       // function calling
    getch();                                 // holds input and output
    return 0;                              // returning value 0
}
int string_length()                       // function body
{
  char string[100];                       // string declaration
  int length;
  puts("enter string");                   // message printing
  gets(string);                           // gets string from user
  length=strlen(string);     // displays length with the help of strlen() function
   return length;            //returns value to length
}








-------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------
//program to find length of a string. USe no arguments and return its value
#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
int string_length();                       // function prototype
int main()                                  // main function returning integer value
{
   printf("length=%d", string_length());                       // function calling
    getch();                                 // holds input and output
    return 0;                              // returning value 0
}
int string_length()                       // function body
{
  char string[100];                       // string declaration
  int length;
  puts("enter string");                   // message printing
  gets(string);                           // gets string from user
  length=strlen(string);     // displays length with the help of strlen() function
   return length;            //returns value to length
}

1)WAP to get factorial value of a number using function.It returns value with no parameter.

in turboc++
------------------------------------------------------------------------
//program to find factorial value of a number using function with returning value.
#include<stdio.h>                      //header file
#include<conio.h>
int factorial();                          // function prototype/declaration with return type int.
int main()                              //main function
{
printf("value=%d",factorial());// function calling and printing output.
getch();
return 0;                                       //returns 0 value
}
int 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
}
  return facto;         //returning facto value
}



----------------------------------------------------------------------------------------------
in codeblocks
--------------------------------------------------------------------------------------------------
//program to find factorial value of a number using function with returning value.
#include<stdio.h>                      //header file
int factorial();                          // function prototype/declaration with return type int.
int main()                              //main function
{
printf("value=%d",factorial());// function calling and printing output.
return 0;                                       //returns 0 value
}
int 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
}
  return facto;         //returning facto value
}

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

in turbo c++
----------------------------------------------------------------------------

//WAP to convert a string into lowercase using(strlwr()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringlwr(char string[]);//prototype of function(must as pointer)
int main()
{
    char name[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //string input
    printf("string in lowercase=%s\n",stringlwr(name));//prints with calling
     getch();
    return 0;
}
char *stringlwr(char string[])
{
    strlwr(string);
    return string;
}

----------------------------------------------------------------------------------------------------
in codeblocks:
------------------------------------------------------------------------------------------------
//WAP to convert a string into lowercase using(strlwr()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringlwr(char string[]);//prototype of function(must as pointer)
int main()
{
    char name[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //string input
    printf("string in lowercase=%s\n",stringlwr(name));//prints with calling
     getch();
    return 0;
}
char *stringlwr(char string[])
{
    strlwr(string);
    return string;
}

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

in turboc++
---------------------------------------------------------------


//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //string input
    printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
     getch();
    return 0;
}
char *stringcpy(char string[],char string1[])
{
    strcpy(string,string1);
    return string;
}






---------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------
//WAP to copy a string using(strcpy()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcpy(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //string input
    printf("copied string=%s\n",stringcpy(name1,name));//prints with calling
     getch();
    return 0;
}
char *stringcpy(char string[],char string1[])
{
    strcpy(string,string1);
    return string;
}

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

in turboc++
--------------------------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input
    printf("merged string=%s\n",stringcat(name,name1));//prints with calling
     getch();
    return 0;
}
char *stringcat(char string[],char string1[])
{
    strcat(string,string1);
    return string;
}










------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------
//WAP to concatenate two  strings using(strcat()) function.Pass string as parameter and return its result
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringcat(char string[],char string1[]);//prototype of function(must as pointer)
int main()
{
    char name[100],name1[100];// declaration
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//can be used
    gets(name); //first string input
    printf("enter second string\n");
    gets(name1);//second string input
    printf("merged string=%s\n",stringcat(name,name1));//prints with calling
     getch();
    return 0;
}
char *stringcat(char string[],char string1[])
{
    strcat(string,string1);
    return string;
}