Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
AE Trono
Pls. Correct this C++ code (Binary Search)?
include <iostream.h>
#include <conio.h>
int unknownsearch (int Num[10], int SearchValue);
void main ()
{
int Num[10] = {9,15,25,33,64,66,72,77,81,96};
int SearchValue;
cout << "Enter Search Value:";
cin >> SearchValue;
if (unknownsearch (Num, SearchValue))
cout << "The Number Exists";
else
cout << "The Number Does Not Exist";
getche ();
}
int unknownsearch (int Num[10], int SearchValue)
{
while (First<=Last) {
int Mid = (First+Last)/2;
if (SearchValue > Num[Mid])
First = Mid+1;
else if (SearchValue < Num[Mid])
Last = Mid-1;
else
return Mid;
}
return -(First+1);
}
5 AnswersProgramming & Design1 decade agoNeed Help In Using The Ternary Operator "?" In C++?
I Just Started C++ Today And Im Having Difficulty Solving This Simple Problem Since Im Not Fam. In Using The "?" Operator Can Someone Pls Give Me The Code, With A Lil Explanation Thanks!
Here's The Problem
Write A Program That Accepts 3 Diff Variables And Outputs The Highest Using The Ternary Operator.
1 AnswerProgramming & Design1 decade agoHelp, Looping Characters In Turbo C
I Need Help On How To Use Loop To Output A Series Of Asterisks...
The Output Should Look Like This (Using Looping), Thanks In Advance...
*****
****
***
**
*
1 AnswerProgramming & Design1 decade ago