Tuesday 2 January 2018

Learn C language Part 26 How to find multiple items in array in C





#include <stdio.h>

#include <conio.h>



main()

{

int i,v=1,flag=0;

int x[5];

x[0]=32;

x[1]=1;

x[2]=32;

x[3]=12;

x[4]=32;



for(i=0;i<5;i++)

{



if(x[i]==v)

{

printf("%d is found at index %d\n",v,i);

flag=1;

}



if(flag==0 && i==4)

{

printf("%d doesnt exist in the array ",v);

}



}























}

Learn C language Part 25 How to make Reverse Search Function in C





code link :



#include <stdio.h>

#include <conio.h>



int search(int x[],int value);

int revsearch(int x[],int value);

main()



{



int x[6]{11,32,76,32,32,54};







int v;



printf("Enter the number that you want to search =");



scanf("%d",&v);







int s=revsearch(x,v);



if(s==-1)



{



printf("%d doesnot exist in the array",v);



}



else



{



printf("%d is found at %d index",v,s);











}



//main meth0d end...........





int search(int x[],int value)



{





int i,t=-1;



for(i=0;i<6;i++)



{



if(x[i]==value)



{



t=i;



break;



}



}



return t;





}//method end search........................................







int revsearch(int x[],int value)



{





int i,t=-1;



for(i=5;i>=0;i--)



{



if(x[i]==value)



{



t=i;



break;



}



}



return t;





}//method end search........................................

Learn C language Part 24 How to make Search Function in C





#include <stdio.h>

#include <conio.h>



int search(int x[],int value);





main()

{



int x[5]{11,32,76,1,54};

int y[4]{12,75,1,52};

int v;

printf("Enter the number that you want to search =");

scanf("%d",&v);



int s=search(x,v);

if(s==-1)

{

printf("%d doesnot exist in the array",v);

}

else

{

printf("%d is found at %d index",v,s);

}



printf("\nEnter the number that you want to search =");

scanf("%d",&v);



 s=search(y,v);

if(s==-1)

{

printf("%d doesnot exist in the array",v);

}

else

{

printf("%d is found at %d index",v,s);

}









}

//main meth0d end...........







int search(int x[],int value)

{



int i,t=-1;

for(i=0;i<5;i++)

{



if(x[i]==value)

{

t=i;

break;

}



}



return t;



}//method end search.........................................




Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...