0

Can anyone please help me with solving this code in C++.

#include <iostream> using namespace std; void menu(){ char menu; int choice; cout<<"Enter the P for the Number\n A for another menu\n S for sequance \n t for first 3 number sequance"<<endl; cin>>menu; if(menu=='p'||menu=='P'){ cout<<"1 for if you put the right number\n 2 if not"<<endl; cin>>choice; if(choice==1){ cout<<"We consider your choice correct"; else { cout<<"your choice is false"; } else if (menu=='a'||menu=='A') { int color; cout<<"1 for red color"<<endl<<"2 for blue"; cin>>color; if(color==1){ cout<<"you choose red color"; else{ cout<<"you choose blue color"; } } } else if (menu == 's'|| menu =='S'){ int a , b ; cout<<"Enter first and last number"; cin>>a<<b; for(int p = a ; p<=b;p++){ cout<<p; } } } } } int main() { menu(); return 0; }

19th Jun 2021, 10:59 AM
Juan lorenzo
Juan lorenzo - avatar
3 Answers
+ 2
If you write clean code then you will never get problem. You have lots of problem in your code. https://code.sololearn.com/ca81a15a14A4/?ref=app
19th Jun 2021, 11:13 AM
A͢J
A͢J - avatar
+ 1
Juan lorenzo, can you please also give a description what your code is going to? it would also be great if you give us some information what the problem exactely is, also share with us any error messages that may appear. thanks!
19th Jun 2021, 11:07 AM
Lothar
Lothar - avatar
0
Yeah a menu-driven program to prompt the user with a menu and respond as per the user’s choice. If user chooses p then prompt him for a number and display whether it’s perfect or not. Iterate the code if user wishes so. If user chooses a then prompt him with another menu: if user chooses s then input start and end of a sequence and print its terms. If user chooses t then input first three terms of a sequence and print its next 5 terms. Print an invalid message if user inputs wrong choice. NOTE: Functions are must to use #include <iostream> using namespace std; void menu(){ char menu; int choice; cout<<"Enter the P for the Number\n A for another menu\n S for sequance \n t for first 3 number sequance"<<endl; cin>>menu; if(menu=='p'||menu=='P'){ cout<<"1 for if you put the right number\n 2 if not"<<endl; cin>>choice; if(choice==1){ cout<<"We consider your choice correct"; else { cout<<"your choice is false"; } else if (menu=='a'||menu=='A') { int color; cout<<"1 for red color"<<endl<<"2 for blue"; cin>>color; if(color==1){ cout<<"you choose red color"; else{ cout<<"you choose blue color"; } } } else if (menu == 's'|| menu =='S'){ int a , b ; cout<<"Enter first and last number"; cin>>a<<b; for(int p = a ; p<=b;p++){ cout<<p; } } } } } int main() { menu(); return 0; }
19th Jun 2021, 11:11 AM
Juan lorenzo
Juan lorenzo - avatar