Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
C++
main()
{
char c;
printf("enter y for yes and n for no \n");
scanf("%c",&c);
if(c=='y')
 {
execute some statements

}
else
{
some statements
}
}
Posted
Updated 6-Mar-23 7:03am
v3
Comments
Prerak Patel 17-Oct-11 8:02am    
Not a question. Read some books, do Google and do it on your own.

Unsigned char Checksum (const char *s,int nLength)
{
Unsigned char result;
result=0;
for(int i=0;i<Length;i++)
{
result ^=*s++
}
return result;
}
 
Share this answer
 
You'll have to take input from user in JS prompt then do some thing like this in PHP

echo("Enter Y for yes and N for no")

if(//prompt value here == "Y")
//statement
else

//statement
 
Share this answer
 
php dose not have a console to enter user input it just work under server side web page
 
Share this answer
 
If you want to run php in the console has a simple solution that works from version 4 of php until today (my version is 7.2) that is the readline.
Unfortunately he needs the user to press enter after typing
PHP
$c = readline("Enter y for yes and n for no and press enter to confirm\n");
$c = strtolower($c);
if ($c == 'y' || $c == 'yes' ) {
    echo 'You chose yes' . PHP_EOL;
} else {
    echo 'You chose no [' . $c . ']' . PHP_EOL;
}
echo 'exiting program...' . PHP_EOL;


You can also use the stream_get_line function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900