[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 379: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 678: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions_content.php on line 678: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1042: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
DOEACC FORUM • View topic - PROJECT: Binary Search

PROJECT: Binary Search

Learn and Trouble Shoot Problems Related to C-Language here.

PROJECT: Binary Search

Unread postby rajeevmahura » Thu May 22, 2008 6:14 pm

#include<stdio.h>
#include<conio.h>
void main()
{

int beg,end,ub,lb=1,i;
int mid,item,num,data[10];
clrscr();

printf("\n\t\tEnter How Many Numbers Do You Want Enter ");
scanf("%d",&num);

ub=num;

printf("\n\n\t\tPlese Enter Data in Shorting Form \n");
getch();

for(i=1;i<=num;i++)
{
printf("Enter Any Number for data[%d]",i);
scanf("%d",&data[i]);
}

for(i=1;i<=num;i++)
{
printf("\n\t%d",data[i]);
}
printf("\n\n\tEnter The Searching Item ");
scanf("%d",&item);

mid = (lb + ub)/2;

if(item==mid&&item<=mid)
{
for(i=1;i<=mid;i++)
{
if(data[i]==item)
{
printf("Yes %d is Exist at %d Possition",item,i);
}
}
}
else
{
if(item>mid)
{
for(i=mid;mid=='\0';i++)
{
if(data[i]==item)
{
printf("Yes %d is Exist at %d Possition ",item,i);

}
}
}
}

/*if(d==1)
{
printf("No, %d is not Exist in Data ",item);
}*/
getch();
}
--Regards--
Rajeev Mahura
Servers & Storage Professional
http://about.me/rajeevmahura
User avatar
rajeevmahura
 
Posts: 144
Joined: Tue May 20, 2008 5:22 pm
Location: Bangalore | New Delhi
Full Name:
Date Of Birth: 15 Jan 1984
Address:
Profession: DOEACC Trainer
DOEACC Center: DOEACC DELHI
Mobile No: 0

Return to C-Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron