//program for binary
search#include<stdio.h>#include<conio.h>#include<process.h>main(){int
n,p[20],i,j,t,beg,end,mid,s;clrscr();printf("enter the
range");scanf("%d",&n);beg=1;end=n; for(i=1;i<=n;i++) { printf(" \n enter%d
element:",i); scanf("%d",&p[i]); }printf("\n enter element to be
searched");scanf("%d",&s); if(beg==end) { printf("\n element found at
position%d",i); getch(); exit(0); } while(beg!=end) { mid=(beg+end)/2;
if(s==p[mid]); { printf("\n element found at position %d",mid);
getch(); exit(0); } if(s>p[mid]) beg=mid+1; else end=end-1; }
for(i=beg;i<=end;i++) { if(s==p[i]) { printf("\n position of element is
%d",i); } else { printf(" \nelement not found"); } } getch(); }enter
the range3
enter1 element:1
enter2 element:6
enter3 element:5
enter element to be searched6
element found at position 2
S.U.Sudarshan
To: [EMAIL PROTECTED]: [EMAIL PROTECTED]: Fri, 21 Dec 2007 07:51:42
-0700Subject: Re: [c-prog] plz prepare a program
Michael Sullivan wrote:> On Fri, 2007-12-21 at 06:41 +0000, p.angel88 wrote:>>
write a program which copies one string value to another string >>
variable(without using the help of strcpy)> > Sounds like homework to me. We
had to write an entire string library> (of our own creation) as homework in the
Programming II class at Rogers> State University. It's not difficult. Here's a
tip; use char> pointers...This sort of training shouldn't be happening at the
University level. It is an insult to educators worldwide, especially those who
hold Ph.D.'s, that they have to teach the basics over and over again. Our
education system needs to be completely revamped to wipe out the concept of
grades (1st-12th) and eliminate the distinct segmentations between "grade
school" (1-12), "college/university", and "the workforce".You know you aren't
learning anything useful when you have to "reinvent the wheel" to get a grade.
Children today have already figured this out and
this:http://cubicspot.blogspot.com/2007/09/education-and-business.htmlIs part
of the unsurprising and expected outcome.In terms of programming in C/C++, I've
got four (six?) words for educators: Safe C++ Design Principles. Use an
existing platform to build the next generation platform. Then build on the new
platform. And so on.-- Thomas HruskaCubicleSoft PresidentPh: 517-803-4197*NEW*
MyTaskFocus 1.1Get on task. Stay on
task.http://www.CubicleSoft.com/MyTaskFocus/
_________________________________________________________________
Post free property ads on Yello Classifieds now! www.yello.in
http://ss1.richmedia.in/recurl.asp?pid=219
[Non-text portions of this message have been removed]