-->

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