-->

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

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 turboc++
----------------------------------------------------------------------------------------------------------
/*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>
void 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
}
total_nu_of_array(arr,size);//calling of function
getch();
return 0;
}

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

printf("total in range 40 and 60  is=%d",count);//printing total element

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>
void 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
}
total_nu_of_array(arr,size);//calling of function
return 0;
}

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

printf("total in range 40 and 60  is=%d",count);//printing total element

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.
#include<stdio.h>
#include<conio.h>
#include<conio.h>
void max_of_array(float array[100],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
}
max_of_array(arr,size);//calling of function
getch();
return 0;
}

void max_of_array(float array[100],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
    }
}

printf("maximum element=%d",max);//printing maxmimum element

getch();

}

------------------------------------------------------------------------------------------
in codeblocks
----------------------------------------------------------------------------
//WAp to find greatest number among ten or more numbers. PAss array as parameter.
#include<stdio.h>
#include<conio.h>
void 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
}
max_of_array(arr,size);//calling of function
return 0;
}

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

printf("maximum element=%d",max);//printing maxmimum element

getch();

}

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

in turbo c++
---------------------------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void 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

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

}
-----------------------------------------------------------------------------------
in codeblocks:
---------------------------------------------------------------------------
//wap to get length of string by passing string as parameter.
#include<stdio.h>
#include<conio.h>
void 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

stringlength(arr);//calling of function with argument
return 0;
}
void stringlength(char array[40])//body line
{
printf("the length=%d",strlen(array));//printing length with strlen()
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>
void sum_of_array(float array[5],int size);//prototype with array and size parameters.array[] also can                                                                      //be used without size
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
}
sum_of_array(arr,size);//calling of function
getch();
return 0;
}
void sum_of_array(float array[5],int size)//body line
{
int k;float s=0;//declaration
printf("elements are\n");
for(k=0;k<size;k++)//loop execution
{
   printf(" element for location=%d is:",k); // for elements in particular location
   printf("%f\n",array[k]);//value printing
   s=s+array[k];//finding sum
}
printf("the sum of elements=%f",s);//printing sum
getch();
}
---------------------------------------------------------------------------------------------------
in codeblockls:
------------------------------------------------------------------------------------------------
//program to enter any five elements and find their sum.
#include<stdio.h>
#include<conio.h>
void 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
}
sum_of_array(arr,size);//calling of function
return 0;
}
void sum_of_array(float array[5],int size)//body line
{
int k;float s=0;//declaration
printf("elements are\n");
for(k=0;k<size;k++)//loop execution
{
   printf(" element for location=%d is:",k); // for elements in particular location
   printf("%f\n",array[k]);//value printing
   s=s+array[k];//finding sum
}
printf("the sum of elements=%f",s);//printing sum
getch();
}

WAP to concatenate /merge two strings without using strcat() function.

in turboc++
-----------------------------------------------------------------------------------------
//WAP to concatenate  two strings  without using(strcat()) function.
#include <stdio.h>
#include<string.h>
#include<conio.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i,j;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    printf("enter second string\n");
    scanf("%s",st1);
     for(i=0;st[i]!='\0';i++);//to get last value of i of first string
    for(j=0;st1[j]!='\0';j++)//loop execution till null character
    {

        st[i]=st1[j];//copying characters
        i++;
    }

    st[i]='\0';//adds an extra null character at the end.

       printf("concatenated string =%s\n",st);//prints the merged string
   getch();
    return 0;
}
---------------------------------------------------------------------------------------------------------
in codeblocks:
-----------------------------------------------------------------------------------------
//WAP to concatenate  two strings  without using(strcat()) function.
#include <stdio.h>
#include<string.h>
int main()
{
    char st[100],st1[100];//two string declaration
    int i,j;
    printf("enter first string\n");
    //fgets(name, sizeof (name), stdin);//to input string with space
    scanf("%s",st); //it also CAN BE USED. IT accepts string with space until it meets new line
    printf("enter second string\n");
    scanf("%s",st1);
     for(i=0;st[i]!='\0';i++);//to get last value of i of first string
    for(j=0;st1[j]!='\0';j++)//loop execution till null character
    {

        st[i]=st1[j];//copying characters
        i++;
    }

    st[i]='\0';//adds an extra null character at the end.

       printf("concatenated string =%s\n",st);//prints the merged string
    return 0;
}