Anonymous
int play( void )//if the play is entered by user { int life = 1, m, x1, x2, x3, s;//assigning values for life, m for selection //x1,x2,x3 for random values from the randx function re: while ( life ) //check the life value to enter the while loop { cleardevice(); if ( car.op1 == 0 ) // { x1 = randx();//getting the random values car.op1++;//calling the obstacle in class and incrementing } else { opp1( x1 );//if not equal to zero print the obstacle } if ( car.op2 == 0 )//for obstacle 2 { x2 = randx(); car.op2++; } else if ( car.op2 < 1 ) //for obstacle valueless than 1 { car.op2++; } else { opp2( x2 ); } if ( car.op3 == 0 ) //for obstacle no 3 { x3 = randx(); car.op3++; } else if ( car.op3 < 1 ) {car.op3++;} else { opp3( x3 ); } setcolor( 10 ); bgmove(); //calling move function for car to appearin sceen if ( check( x2, car.op2, car.cp ) || check( x1, car.op1, car.cp ) || check( x3, car.op3, car.cp ) ) { //checking the collision condition from the check function life--; if ( life == 0 ) { over();//calling the over fuction for finishing the game } car.op1 = 1; //initializing the obstacle car.op2 = -16; car.op3 = -32; goto re;//using goto to repeat the processes always } if ( kbhit() )//check the key stroke { m = getch(); switch ( m ) //key stroke decision using switch case { case LEFT: left();//for left arrow break; case RIGHT: right(); //for right arrow key break; case 'q': exit( 0 ); //to exit the game when ever the user want to } } else { delay( 100 ); } } getch(); return ( 0 ); } void menu()//for the menu appearance { int s = 1, t = 0, a, p = 140;//here s is for keystroke selection in switch case do//to contiue the program after finish { //here a is for the rectangle to move up and down do //p for rectangle use in menu { cleardevice(); setcolor( YELLOW ); settextstyle( 1, 0, 4 ); outtextxy( 230, 30, "MENU" );Mr.007, [28.06.21 23:33] Mr.007, [28.06.21 22:47]
Wow ur game developer?
Anonymous
Or is it ur graduate project?
Anonymous
How to get good at competitive programming
First thing give urself time! Take 6 months to one year! Be strong in fundemantals! After that get ur self comfartable with using libraries and macros! Register in online comletative programming platforms like hackerearth.com, this group! Discuss with peers! Practise practise!
shriman_deepak
#include<iostream> using namespace std; int main() { int num1,num2; cout<<"enter 1st number"<<"enter 2nd number"; cin>>num1;num2; cout<<"this is difference of num1 and sum2" <<(num1+num2) ; return 0; }
shriman_deepak
plzz help me to find my mistake there
Anonymous
plzz help me to find my mistake there
I think there is no error in program, may be ur not assigning num 2 in input stream cin
shriman_deepak
PREM SAGAR
Wow ur game developer?
i need to which algorithm
Anonymous
How to get good at competitive programming
Competitive programming is useless in my opinion. In real world you dont see a situation often where you have to devise an algorithm within an hour or faster than others. What is more important is to learn Algorithms like Graph Algorithms, String Algorithms, Greedy and Dynamic Programming, NP Completeness and so on. This would help you in competitive programming but.more importantly it will give you a toolset to tackle real life problems. The latter is more important than the former. The former is just a side effect which comes with practice. Competitive programming at best is used to hire freshers in this extremely competitive market. But once you are in a job and gain 3 years of experience you would lose all urge to excel in that.
Anonymous
There is this set of 291 coding questions from must do interview questions from geeks ...I'm solving them...am I going the right way
It wont hurt. As a fresher it might even help you land a job. But dont make excelling at competitive programming an ambition. If anything it encourages bad coding practices which must be avoided at all costs in the professional world. Instead of blindly solving those questions, try to understand how they must be solved. That would prove more useful in the longer run.
shriman_deepak
U guys are so experienced...🙂
Anonymous
Yes...but if I Join mtech...I'll have to compete with btech guys who have been coding from their first year..how do I compete
Learn programming (from good sources) and learn good coding practices. Learn to use tools like the compiler, debugger, static analysis, run time analysis, unit testing frameworks and so on. Solve those questions in a proper way following coding guidelines. You would solve them slower but framing a solution faster than others is not the point. Writing code in a secure, adaptive and readable manner is more important. If you do all of the above or atleast work on it, take it from me that you would be more employable than a Summa cum Laude or Magna cum Laude graduates from many of those Indian colleges. And if you are talking about a BTech program in India, let me assure you that those colleges (except for a few) don't churn out the best programmers around. They still use Yashwant Kanitkar, Balaguruswamy, Herbert Schildt, Ivor Horton and Sumit Arora textbooks which are nothing but horribly written programming textbooks. These graduates will have a lot of unlearning to do to be good programmers.
Anonymous
I too believe assignments in collage level dont improve coding skills! Those are just superficial things! But ofcourse competative programming is diffrent thing it is motivating spark which will improve u over time to ur transition to real programmer over time! Real programming needs optimised codes compliant with diffrent testing standards at run time!
Anonymous
Anyway this is off topic. So dont discuss this here anymore. I wont be replying on this topic anymore.
Manav
https://pastebin.com/PKUHqU1A
Manav
can any one help me with this program
shriman_deepak
int main() { int a=9; int b=20; cout<<"hello world"<<endl; cout<<a+b<<endl ; cout<<a-b<<endl; cout<<a*b<<endl; cout<<a/b<<endl; cout<<a%b<<endl; cout<<a++<<endl; cout<<a--<<endl; cout<<++a<<endl; cout<<--a<<endl;
Manav
there is an error use binary operator
shriman_deepak
here i am getting output of a%b WHY ?
shriman_deepak
there is an error use binary operator
all output is ok except that %
shriman_deepak
not getting 0
Ravi
all output is ok except that %
Put a%b into bracket, then try
Ravi
not getting 0
then what
shriman_deepak
then what
getting nothing
shriman_deepak
a/b gives 0
Ravi
a/b gives 0
That is obvious.
shriman_deepak
but a%b gives nothing
shriman_deepak
hello world 29 -11 180 0 9 9 10 10 9
shriman_deepak
this is the output
Ravi
there is the output
Ravi
it is correct whats the problem
Anonymous
TAKINADA
is output is 0
Not 0 output must be 9
shriman_deepak
a%b is 9
oh sorry my mistake
shriman_deepak
TAKINADA
hello world 29 -11 180 0 9 9 10 10 9
Please count your operations and answers and compare them if equal no such as problem that you suggested, if smth wrong in your code compiler gives you error
Anonymous
https://pastebin.com/PKUHqU1A
What help do you need? Just posting code without asking specific questions wont get you any help.
Manav
Error in this program
Manav
Overloaded operator << didn't work
Pavel
Overloaded operator << didn't work
Compile error or logical error?
Anonymous
Overloaded operator << didn't work
Because you have made it a member function. Make it a friend function instead.
Manav
Compile
Anonymous
I tried it but it's not working
Show us the code where you have made it a friend function. Post it on pastebin.com again
Manav
Ok
Anonymous
It works but why it is not works as a member function
Because when you use the statement cout << box; you are not making a member function call. If you want it to work as a member function then you have to call it like box.operator<<(cout,box) for the way you have defined it. You may as well get rid of the second redundant argument because this pointer is an implicit argument
Manav
Ok
Anonymous
Ok
You have other things like Argument Dependent Lookup and stuff which helps with finding the correct operator<< overload when defined as a friend function and your class itself is in some namespace. You can look it up later.
Manav
Ok I'll check
Alberto
Is it possible to return a struct from a function in C? I tried, can you tell me what is wrong?
Anonymous
Do any of you know neural network
RITESH
WAP TO DEMONSTRATE TO USE OF DEFAULT CONSTRUCTOR ? Please help me
Anonymous
Is it possible to return a struct from a function in C? I tried, can you tell me what is wrong?
Yes it is possible. The problem with your code is that the struct you want to return is defined inside the function. Move the struct definition outside. And your command function should be declared as struct list_commands command();
RITESH
WAP TO DEMONSTRATE TO USE OF CONSTRUCTOR OVERLOADING ? Please tell me in c++ coding
?
/get cbook
Anonymous
/get cnotes
Anonymous
/get
Anonymous
/get cbook
Nameful
/get rekt
Anonymous
A program to perform algebraic expression please
Mickey🕷
Good day. I'm having a problem with a code that I am doing. I was practising the use of the # operator. If I copy and paste the code from the book I'm using, the code is giving me an error. Please help me see where I could be going wrong.
Mickey🕷
#include <iostream> using namespace std; #define MKSTR ( x ) #x int main (){ cout << MKSTR (HELLO C++) << endl; return 0; }