Skip to main content

Posts

Showing posts from March, 2014

8 Common Programming Mistakes

8 Common Programming Mistakes Learning to program can be tough--just ask anyone who's done it! Fortunately, a lot of problems happen over and over again--I've put together 8 of the most common problems that you'll run into as a new programmer. 1. Undeclared Variables int main() { cin>>x; cout< >x; cout< >a; cin>>b; cout<<"The sum is: "< >b; cin>>a; sum=a+b; cout<<"The sum is: "< >x; "Why doesn't my loop ever end?" If you use a single equal sign to check equality, your program will instead assign the value on the right side of the expression to the variable on the left hand side, and the result of this statement is the value assigned. In this case, the value is 'Y', which is treated as true. Therefore, the loop will never end. Use == to check for equality; furthermore, to avoid accidental assignment, put variables on the right hand side of the expression and you'll get...

Moving car

// moving car animation #include #include void main() { int gd=DETECT,gm; int i ,j=0; initgraph(&gd,&gm,"akshay"); settextstyle(GOTHIC_FONT,HORIZ_DIR,4); getch(); i=0; while(i<=420) { rectangle(150+i,350,200+i,400); rectangle(50+i,275,150+i,400); circle(175+i,410,10); circle(75+i,410,10); setcolor(j++); delay(100); i=i+10; cleardevice(); } getch(); closegraph(); }

Mouse programming within a window

click to see the coding of mouse programming within a window

Mouse Programming

click to see mouse programming

snake game

click to see the coding of snake game                 click to see the snake game coding