-->

WAP to enter student id, student name and address for any 10 students. Then search a data and its location.

in codeblocks:
--------------------------------------------------------------------------------------------------
// program to search data in given  detail of some  students       //comment abt. program
#include <stdio.h>                                 //header file
#include<string.h>
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct
    int english,maths,physics,chemistry,nepali,total;   //marks member declaration
    float percentage;                       //member for total and percentage

}access[100];                 //'access' is a variable to access members. This can hold maximum 100 members.it is called array of struct.
int main()
{
   int n,i,loc=0;                                         //variable declaration
   char naam[70];
    printf("enter total value of n\n");
   scanf("%d",&n);                                  //accepts total value
   for(i=0;i<n;i++)
   {                                                 //execution of loop with inputs
    puts("enter roll number \n");
   scanf("%d",&access[i].roll);                      //gets data in different member
   puts("enter name \n");
   scanf("%s",access[i].name);                       //gets name
   puts("enter address \n");
   scanf("%s",access[i].address);                    //gets address
   printf("enter english marks\n");
   scanf("%d",&access[i].english);                  //gets respective marks
   printf("enter maths marks\n");
   scanf("%d",&access[i].maths);
   printf("enter Physics marks\n");
   scanf("%d",&access[i].physics);
   printf("enter chemistry marks\n");
   scanf("%d",&access[i].chemistry);
   printf("enter nepali marks\n");
   scanf("%d",&access[i].nepali);
   access[i].total=access[i].english+access[i].maths+access[i].physics+access[i].chemistry+access[i].nepali;//finds total and stores
      access[i].percentage=(float)access[i].total/5;               //finds percentage and stores in respective member
   }
   printf("entered data are\n");                  //loop execution to display data
   for(i=0;i<n;i++)
   {
   printf("roll=%d,name=%s,address=%s, english=%d,maths=%d,physics=%d,chemistry=%d,nepali=%d\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali);
   }                                                //displays data

   printf(" data with total and percentage are\n");     // displays data with total and percentage
  for(i=0;i<n;i++)
   {
   printf("roll=%d,\tname=%s,\taddress=%s,\tenglish=%d,\tmaths=%d,\tphysics=%d,\tchemistry=%d,\tnepali=%d,\ttotal=%d,\tpercentage=%f\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali,access[i].total,access[i].percentage);
   }
   printf("to be searched is\n");
   scanf("%s",naam);         //data input to be searched
   for(i=0;i<n;i++)
   {
       if(strcmp(naam,access[i].name)==0)//data comparison
        {
           loc=1;
           break;                    //terminating the loop
        }
   }
   if(loc==1)
   {
       printf("data found and location=%d",i);//printing the location of data
       printf("and data are,roll=%d,\tname=%s,\taddress=%s,\tenglish=%d,\tmaths=%d,\tphysics=%d,\tchemistry=%d,\tnepali=%d,\ttotal=%d,\tpercentage=%f\n",access[i].roll,access[i].name,access[i].address,access[i].english
          ,access[i].maths,access[i].physics,access[i].chemistry,access[i].nepali,access[i].total,access[i].percentage);
")
   }
   else
   {
       printf("not found\n");
   }

    return 0;
}

program to add two times given in hrs,mm and ss using struct

in codeblocks
------------------------------------------------------------------------------------------
//program to add two times given in hrs,mm and ss using struct
#include <stdio.h>
#include <stdlib.h>
struct timeaddition
{
    int hrs;
    int mm;
    int ss;
}time1,time2,ttime;
int main()
{
    int totalmm;
    printf("enter first time in hrs,minutes and seconds\n");
    scanf("%d%d%d",&time1.hrs,&time1.mm,&time1.ss);
    printf("enter second time in hrs,minutes and seconds\n");
    scanf("%d%d%d",&time2.hrs,&time2.mm,&time2.ss);
    totalmm=time1.mm+time2.mm+(time1.ss+time2.ss)/60;
    ttime.ss=(time1.ss+time2.ss)%60;
    ttime.mm=totalmm%60;
    ttime.hrs=time1.hrs+time2.hrs+totalmm/60;
    printf("total hrs=%d minutes=%d and seconds=%d\n",ttime.hrs,ttime.mm,ttime.ss);
    return 0;
}

struct initialization

in turboc++
------------------------------------------------------------------------------
//struct initialization
#include <stdio.h>
#include<string.h>
struct onl
{
    int a;
    float b;
    char name[30];
}var;
int main()
{
     var.a=98;
     var.b=5.4;
    strcpy(var.name,"raman");
    printf("a=%d\n",var.a);
     printf("b=%f\n",var.b);
     printf("name=%s",var.name);
    return 0;
}
/*note:
We donot need to use strcpy()if we use initialization
in same line as the var is.
same we can apply in union as well.
*/

concept of register storage

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


//program to understand register variable .
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void function();
int main()
{
    function();//function calling
    getch();
    return 0;
}
void function()//function body line
{

     register int a=4;//local variable, it can not be accessed from outsides and stored in RAM. We can store that in register location
    register float b=7.89;//local variable// can not be accessed from outsides stored in register
    printf("a=%d,b=%f",a,b);//printing value
}

/*note:
If we declare variable as register then it is stored in register and not not RAM. Its execution becomes faster.
*/


-------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------
//program to understand register variable .
#include <stdio.h>
#include <stdlib.h>
void function();
int main()
{
    function();//function calling
    return 0;
}
void function()//function body line
{

     register int a=4;//local variable, it can not be accessed from outsides and stored in RAM. We can store that in register location
    register float b=7.89;//local variable// can not be accessed from outsides stored in register
    printf("a=%d,b=%f",a,b);//printing value
}

/*note:
If we declare variable as register then it is stored in register and not not RAM. Its execution becomes faster.
*/

concept of static storage

in turboc++
--------------------------------------------------------------------------------------
//program to understand static variable .
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void function();
int main()
{
    function();//function calling
    function();
   getch();
    return 0;
}
void function()//function body line
{

     int a=4;//local variable, it can not be accessed from outsides. change this with static int a=4.

    printf("a=%d\n",a);//printing value
    a=a+1;
}
/* note:
It gives
a=4
a=4
where as it has to be 5 second time.
The computer can not retain its value on second calling.It loses its content (5) and prints same 4.

---------------------------
where as if we take static int a=4
the increased value remains there in memory untill the program is terminated.
We get
a=4
a=5
*/


-------------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------------------------------
//program to understand static variable .
#include <stdio.h>
#include <stdlib.h>
void function();
int main()
{
    function();//function calling
    function();
    return 0;
}
void function()//function body line
{

     int a=4;//local variable, it can not be accessed from outsides. change this with static int a=4.

    printf("a=%d\n",a);//printing value
    a=a+1;
}
/* note:
It gives
a=4
a=4
where as it has to be 5 second time.
The computer can not retain its value on second calling.It loses its content (5) and prints same 4.

---------------------------
where as if we take static int a=4
the increased value remains there in memory untill the program is terminated.
We get
a=4
a=5
*/

External storage (also called global storage or variables:

in turboc++
-------------------------------------------------------------------------
//program to understand global variable .
#include <stdio.h>
#include <stdlib.h>
extern int a=5;// or simply int a //global variable; can be used with keyword extern
float b=4.5;//global variable;can be used with extern keyword
void function();
int main()
{
    printf("value of a and b from main function are=%d and %f\n",a,b);
    function();//function calling
    return 0;
}
void function()//function body line
{

        printf("from user defined function a=%d,b=%f\n",a,b);//printing value
}

















---------------------------------------------------------------------------------------------
in codeblocks:
------------------------------------------------------------------------------------------
//program to understand global variable .
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
extern int a=5;// or simply int a //global variable; can be used with keyword extern
float b=4.5;//global variable;can be used with extern keyword
void function();
int main()
{
    printf("value of a and b from main function are=%d and %f\n",a,b);
    function();//function calling
    getch();
    return 0;
}
void function()//function body line
{

        printf("from user defined function a=%d,b=%f\n",a,b);//printing value
}

Automatic (also called local variables):

in turbo c++
-----------------------------------------------------------------------------
//program to understand local variable .
#include <stdio.h>
#include <stdlib.h>
#include<conio.h>
void function();
int main()
{
    function();//function calling
   getch();
    return 0;
}
void function()//function body line
{

    auto int a=4;//local variable, it can not be accessed from outsides. we can also use keyword auto.
    float b=7.89;//local variable// can not be accessed from outsides
    printf("a=%d,b=%f",a,b);//printing value
}







---------------------------------------------------------------------
in codeblocks
--------------------------------------------------------------------
//program to understand local variable .
#include <stdio.h>
#include <stdlib.h>
void function();
int main()
{
    function();//function calling
    return 0;
}
void function()//function body line
{

    auto int a=4;//local variable, it can not be accessed from outsides. we can also use keyword auto.
    float b=7.89;//local variable// can not be accessed from outsides
    printf("a=%d,b=%f",a,b);//printing value
}

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

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

in turboc++
----------------------------------------------------------------------------------------------
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[100]);  //function prototype with pointer type. We can avoid it size.
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line

    printf("reverse=%s\n",stringrev(name));//prints the reversed name by calling the function
     getch();
    return 0;
}
char *stringrev(char string[100])
{
    strrev(string);
    return string;                              //returning its string
}

---------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------
//WAP to reverse a string using(strrev()) function.Pass string as parameter and return its reverse
#include <stdio.h>
#include<string.h>
#include<conio.h>
char *stringrev(char string[100]);
int main()
{
    char name[100];//two dimensional declaration
    printf("enter string\n");
    //fgets(name, sizeof (name), stdin);
    scanf("%[^\n]s",name); //it also CAN BE USED. IT accepts string with space until it meets new line

    printf("reverse=%s\n",stringrev(name));//prints the name
     getch();
    return 0;
}
char *stringrev(char string[100])
{
    strrev(string);
    return string;
}

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

in turboc++
-----------------------------------------------------------------------------------------
/*WAP to input elements and search a number in that.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
int search_in_array(float array[200],int size,int number);//prototype with array and size and number parameters
int main()
{

float arr[200];int k,num;            // array declaration with maximum limit 200
int size,f;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
printf("enter number to be searched\n");
scanf("%d",&num);                //number input to be searched
f=search_in_array(arr,size,num);//assigning return value to variable f
if(f==0)                        //testing the value
{
printf("number not found \n");//calling of function
}
else
{
    printf("number found and lcoation=%d",f);
}
getch();
return 0;
}
int search_in_array(float array[200],int size,int number)//body line
{

int k;//declaration
int found;

for(k=0;k<size;k++)//loop execution

{
 if(number==array[k])
        {
            found=0; //assigning 0 on its finding
            break;
        }
        else
        {
            found=1;//else assigning 1
        }
}
if(found==0)//testing the condition
{
    return k;//returning the location
}
    else
{
        return 0;//returning nothing
}
    getch();
}






--------------------------------------------------------------------------------------------
in codeblocks:
--------------------------------------------------------------------------------------------------------------
/*WAP to input elements and search a number in that.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
int search_in_array(float array[200],int size,int number);//prototype with array and size and number parameters
int main()
{

float arr[200];int k,num;            // array declaration with maximum limit 200
int size,f;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
printf("enter number to be searched\n");
scanf("%d",&num);                //number input to be searched
f=search_in_array(arr,size,num);//assigning return value to variable f
if(f==0)                        //testing the value
{
printf("number not found \n");//calling of function
}
else
{
    printf("number found and lcoation=%d",f);
}
getch();
return 0;
}
int search_in_array(float array[200],int size,int number)//body line
{

int k;//declaration
int found;

for(k=0;k<size;k++)//loop execution

{
 if(number==array[k])
        {
            found=0; //assigning 0 on its finding
            break;
        }
        else
        {
            found=1;//else assigning 1
        }
}
if(found==0)//testing the condition
{
    return k;//returning k value
}
    else
{
        return 0;//returning nothing
}
    getch();
}

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.

in truboc++
-----------------------------------------------------------------------------------------

/*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.*/
#include<stdio.h>
#include<conio.h>
int total_nu_of_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter weights of students\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data/weight inputs
}
printf("total in given range=%d",total_nu_of_array(arr,size));//calling of function
getch();
return 0;
}

int total_nu_of_array(float array[200],int size)//body line
{

int k;//declaration
int count=0;

for(k=0;k<size;k++)//loop execution

{
if(array[k]>40 && array[k]<60)//condition testing
    {
        count++;//counting if the condition is true
    }
}

return count;//returning total count

getch();

}






---------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
/*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.*/
#include<stdio.h>
#include<conio.h>
int total_nu_of_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter weights of students\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data/weight inputs
}
printf("total in given range=%d",total_nu_of_array(arr,size));//calling of function
getch();
return 0;
}

int total_nu_of_array(float array[200],int size)//body line
{

int k;//declaration
int count=0;

for(k=0;k<size;k++)//loop execution

{
if(array[k]>40 && array[k]<60)//condition testing
    {
        count++;//counting if the condition is true
    }
}

return count;//returning total count

getch();

}

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

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

//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{

float arr[100];int k;            // array declaration with maximum limit 100
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution

{
   printf("enter element for location=%d\n",k); // for elements in particular location
   scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
getch();
return 0;
}

float max_of_array(float array[5],int size)//body line
{

int k;//declaration
int max;
max=array[0];//assigning first value to max.

for(k=0;k<size;k++)//loop execution

{
if(max<array[k])//condition testing
    {
        max=array[k];//assigning value if the condition is true
    }
}

return max;//returning maxmimum element

getch();

}









----------------------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter. and it returns some value.
#include<stdio.h>
#include<conio.h>
float max_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{

float arr[100];int k;            // array declaration with maximum limit 100
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution

{
   printf("enter element for location=%d\n",k); // for elements in particular location
   scanf("%f",&arr[k]);//data inputs
}
printf("maximum value=%f",max_of_array(arr,size));//calling of function
return 0;
}

float max_of_array(float array[5],int size)//body line
{

int k;//declaration
int max;
max=array[0];//assigning first value to max.

for(k=0;k<size;k++)//loop execution

{
if(max<array[k])//condition testing
    {
        max=array[k];//assigning value if the condition is true
    }
}

return max;//returning maxmimum element

getch();

}


wap to get length of string by passing string as parameter.

in turboc++
-----------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                     
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
getch();
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

---------------------------------------------------------------------------------------------------------
in codeblocks:
----------------------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
int stringlength(char array[40]);//prototype with array string; we can also use simply array[]
int main()
{
char arr[20];            // array declaration with maximum limit 20
                       
printf("enter string\n");
gets(arr);//gets string

printf("the length=%d",stringlength(arr));//calling of function with argument
return 0;
}
int stringlength(char array[40])//body line
{
return strlen(array);
getch();
}

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

in turboc++
-----------------------------------------------------------------------------------------
//program to enter any five elements and find their sum.
#include<stdio.h>
#include<conio.h>
int sum_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[20];int k;            // array declaration with maximum limit 20
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
   printf("enter element for location=%d\n",k); // for elements in particular location
   scanf("%f",&arr[k]);//data inputs
}
printf("the sum=%d",sum_of_array(arr,size));//calling of function
getch();
return 0;
}
int sum_of_array(float array[5],int size)//body line
{
int k;float s=0;//declaration
for(k=0;k<size;k++)//loop execution
{
   s=s+array[k];//finding sum
}
return s;//returning sum(s)
getch();
}
------------------------------------------------------------------------------------------------------------
in codeblocks:
------------------------------------------------------------------------------------------------------------
//program to enter any five elements and find their sum.
#include<stdio.h>
#include<conio.h>
int sum_of_array(float array[5],int size);//prototype with array and size parameters
int main()
{
float arr[20];int k;            // array declaration with maximum limit 20
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
for(k=0;k<size;k++)//loop execution
{
   printf("enter element for location=%d\n",k); // for elements in particular location
   scanf("%f",&arr[k]);//data inputs
}
printf("the sum=%d",sum_of_array(arr,size));//calling of function
return 0;
}
int sum_of_array(float array[5],int size)//body line
{
int k;float s=0;//declaration
for(k=0;k<size;k++)//loop execution
{
   s=s+array[k];//finding sum
}
return s;//returning sum(s)
getch();
}

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

in turboc++
-------------------------------------------------------------------------------------------------------
//WAP to find sum of two matrices of order mxn. Here pass matrix as parameter.
#include<stdio.h>
#include<conio.h>
void sum_of_matrix(int matrix[100][100],int matrix1[100][100],int row,int col);//function prototype
int main()
{
int mat1[100][100],mat2[100][100];              //matrix declaration of max size 100x100
int i,j;
int total_row,total_col;             //declaration of variable
printf("enter total number of rows(m)\n");
scanf("%d",&total_row);                     // for total number of rows of matrix
printf("enter total columns(n)\n");;
scanf("%d",&total_col);                     // for total number of columns of matrix
printf("enter elements of first matrix mat1\n");
for(i=0;i<total_row;i++)
{
  for(j=0;j<total_col;j++)                  // nested loop for input of elements
       {
           scanf("%d",&mat1[i][j]);   // getting inputs from user
        }
}
printf("enter elements of second matrix mat2\n");
for(i=0;i<total_row;i++)
{
  for(j=0;j<total_col;j++)                  // nested loop for input of elements
       {
           scanf("%d",&mat2[i][j]);   // getting inputs from user
        }
}

sum_of_matrix(mat1,mat2,total_row,total_col);//function calling
getch();

return 0;
}

void sum_of_matrix(int matrix[100][100],int matrix1[100][100],int row,int col)
{
    int i,j;
printf("sum of two matrices are\n");
for(i=0;i<row;i++)
{
  for(j=0;j<col;j++)           
       {
           printf(" %d ",matrix[i][j]+matrix1[i][j]); // sum and display of matrix
        }
        printf("\n");                    // display in next row
}
getch();
}

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

in turboc++
--------------------------------------------------------------------------------------------------------
//WAP to transpose  a matrix/array of order mxn.
#include<stdio.h>
#include<conio.h>
void tran_matrix(int array[100][100],int row,int col);//fucntion prototype
int main()
{
int matrics_1[100][100];              //matrix declaration of max size 100x100
int i,j;
int total_row,total_col;             //declaration of variable
printf("enter total number of rows(m)\n");
scanf("%d",&total_row);                     // for total number of rows of matrix
printf("enter total columns(n)\n");;
scanf("%d",&total_col);                     // for total number of columns of matrix
printf("enter elements of matrix\n");
for(i=0;i<total_row;i++)
{
  for(j=0;j<total_col;j++)                  // nested loop for input of elements
       {
           scanf("%d",&matrics_1[i][j]);   // getting inputs from user
        }
}
tran_matrix(matrics_1,total_row,total_col);//function calling
getch();
return 0;
}

void tran_matrix(int array[100][100],int row,int col)
{
    int i,j;
printf("before transpose\n");             // message display
for(i=0;i<row;i++)
{
  for(j=0;j<col;j++)           
       {
           printf(" %d ",array[i][j]); // display of matrix
        }
        printf("\n");                    // display in next row
}
printf("after transpose\n");             // for transposed matrix
for(i=0;i<col;i++)
{
  for(j=0;j<row;j++)
       {
        printf(" %d ",array[j][i]);    // display of matrix with trasnposed elemnts
       }
       printf("\n");
}   
getch();
}
-------------------------------------------------------------------------------------------
in codeblocks:-
-----------------------------------------------------------------------------------------------------
//WAP to transpose  a matrix/array of order mxn.
#include<stdio.h>
#include<conio.h>
void tran_matrix(int array[100][100],int row,int col);//fucntion prototype
int main()
{
int matrics_1[100][100];              //matrix declaration of max size 100x100
int i,j;
int total_row,total_col;             //declaration of variable
printf("enter total number of rows(m)\n");
scanf("%d",&total_row);                     // for total number of rows of matrix
printf("enter total columns(n)\n");;
scanf("%d",&total_col);                     // for total number of columns of matrix
printf("enter elements of matrix\n");
for(i=0;i<total_row;i++)
{
  for(j=0;j<total_col;j++)                  // nested loop for input of elements
       {
           scanf("%d",&matrics_1[i][j]);   // getting inputs from user
        }
}
tran_matrix(matrics_1,total_row,total_col);//function calling
return 0;
}

void tran_matrix(int array[100][100],int row,int col)
{
    int i,j;
printf("before transpose\n");             // message display
for(i=0;i<row;i++)
{
  for(j=0;j<col;j++)           
       {
           printf(" %d ",array[i][j]); // display of matrix
        }
        printf("\n");                    // display in next row
}
printf("after transpose\n");             // for transposed matrix
for(i=0;i<col;i++)
{
  for(j=0;j<row;j++)
       {
        printf(" %d ",array[j][i]);    // display of matrix with trasnposed elemnts
       }
       printf("\n");
}   
getch();
}

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

in turboc++
---------------------------------------------------------------------------------------
//WAP to input strings and sort them in alphabetical order. Pass string as a parameter.
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void stringsort(char array[40][40],int size);
//prototype with array string; we can also use simply array[]
int main()
{
char arr[40][40];            // array declaration with maximum limit 40
int i,n;
printf("enter total number of strings\n");
scanf("%d",&n);//size of total strings
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",arr[i]);//gets string//input of string
}
stringsort(arr,n);//calling of function with argument
getch();
return 0;
}
void stringsort(char array[40][40],int size)//body line
{
    int i,j;
    char tempo[20];
    for(i=0;i<size;i++)
    {
        for(j=i+1;j<size;j++)//comaprison of strings
        {
            if((strcmp(array[i],array[j])>0))//condition testing
            {
                strcpy(tempo,array[i]);
                strcpy(array[i],array[j]);//string copying to different location
                strcpy(array[j],tempo);
            }
        }
    }
printf("sorted string are\n");//output of sorted string
for(i=0;i<=size-1;i++)
{
printf("%s\n",array[i]);
}
getch();
}
------------------------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------------------------------
//WAP to input strings and sort them in alphabetical order. Pass string as a parameter.
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void stringsort(char array[40][40],int size);//prototype with array string; we can also use simply array[]
int main()
{
char arr[40][40];            // array declaration with maximum limit 40
int i,n;
printf("enter total number of strings\n");
scanf("%d",&n);//size of total strings
printf("enter strings\n");
for(i=0;i<=n-1;i++)
{
scanf("%s",arr[i]);//gets string//input of string
}
stringsort(arr,n);//calling of function with argument
return 0;
}
void stringsort(char array[40][40],int size)//body line
{
    int i,j;
    char tempo[20];
    for(i=0;i<size;i++)
    {
        for(j=i+1;j<size;j++)//comaprison of strings
        {
            if((strcmp(array[i],array[j])>0))//condition testing
            {
                strcpy(tempo,array[i]);
                strcpy(array[i],array[j]);//string copying to different location
                strcpy(array[j],tempo);
            }
        }
    }
printf("sorted string are\n");//output of sorted string
for(i=0;i<=size-1;i++)
{
printf("%s\n",array[i]);
}
getch();
}

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

in turboc++
---------------------------------------------------------------------------------------------------------------
//WAP to input 'n' numbers and sort them in an order. PAss array as a parameter.
#include<stdio.h>
#include<conio.h>
void sorting_in_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
sorting_in_array(arr,size);//calling of function
getch();
return 0;
}

void sorting_in_array(float array[200],int size)//body line
{

int i,j,k;float te;//declaration

for(i=0;i<size;i++)//loop execution
{
    for(j=i+1;j<size;j++)
    {
        if(array[i]>array[j])//value comparison
        {
            te=array[i];
            array[i]=array[j];//swapping of values
            array[j]=te;
        }
    }
}
printf("sorted numbers are\n");
for(k=0;k<size;k++)//loop execution
{
   printf("%f\n",array[k]);//data print in sorted (ascending order)format
}
    getch();
}










------------------------------------------------------------------------------------------------------------------
in codeblocks:
-------------------------------------------------------------------------------------------------------------
//WAP to input 'n' numbers and sort them in an order. PAss array as a parameter.
#include<stdio.h>
#include<conio.h>
void sorting_in_array(float array[200],int size);//prototype with array and size parameters
int main()
{

float arr[200];int k;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
sorting_in_array(arr,size);//calling of function
return 0;
}

void sorting_in_array(float array[200],int size)//body line
{

int i,j,k;float te;//declaration

for(i=0;i<size;i++)//loop execution
{
    for(j=i+1;j<size;j++)
    {
        if(array[i]>array[j])//value comparison
        {
            te=array[i];
            array[i]=array[j];//swapping of values
            array[j]=te;
        }
    }
}
printf("sorted numbers are\n");
for(k=0;k<size;k++)//loop execution
{
   printf("%f\n",array[k]);//data print in sorted (ascending order)format
}
    getch();
}

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

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

/*WAP to input elements and search a number in that.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
void search_in_array(float array[200],int size,int number);//prototype with array and size and number parameters
int main()
{

float arr[200];int k,num;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
printf("enter number to be searched\n");
scanf("%d",&num);                //number input to be searched
search_in_array(arr,size,num);//calling of function
getch();
return 0;
}

void search_in_array(float array[200],int size,int number)//body line
{

int k;//declaration
int found;

for(k=0;k<size;k++)//loop execution

{
 if(number==array[k])
        {
            found=0; //assigning 0 on its finding
            break;
        }
        else
        {
            found=1;//else assigning 1
        }
}
if(found==0)//testing the condition
{
    printf("number found and number %d location is %d\n",number,k);//printing the location
}
    else
{
        printf("given number is not in the list");//printing not message
}
    getch();
}




-------------------------------------------------------------------------------------------------------------------
in codeblocks:
------------------------------------------------------------------------------------------------------
/*WAP to input elements and search a number in that.
Pass Weight as an array as parameter.*/
#include<stdio.h>
#include<conio.h>
void search_in_array(float array[200],int size,int number);//prototype with array and size and number parameters
int main()
{

float arr[200];int k,num;            // array declaration with maximum limit 200
int size;               // says about size of array to be entered
printf("enter size of array\n");
scanf("%d",&size);//input of size
printf("enter elements\n");
for(k=0;k<size;k++)//loop execution
{
   scanf("%f",&arr[k]);//data inputs
}
printf("enter number to be searched\n");
scanf("%d",&num);                //number input to be searched
search_in_array(arr,size,num);//calling of function
return 0;
}

void search_in_array(float array[200],int size,int number)//body line
{

int k;//declaration
int found;

for(k=0;k<size;k++)//loop execution

{
 if(number==array[k])
        {
            found=0; //assigning 0 on its finding
            break;
        }
        else
        {
            found=1;//else assigning 1
        }
}
if(found==0)//testing the condition
{
    printf("number found and number %d location is %d\n",number,k);//printing the location
}
    else
{
        printf("given number is not in the list");//printing not message
}
    getch();
}