944,052 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1797
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Feb 24th, 2007
0

plzzzzzzzzzzz help me............

Expand Post »
hey guys, i need some real bad help for my c++ project......i'm making an analog clock in C++ graphics.........n my clock works just fine, except for the fact that i haven't as yet added an hour hand, :rolleyes: and yeah..my minute hand runs almost as fast as my second hand.:lol:.....plzzzzzzzzzzzz get me outta this, i need ur help......
here's my program..........
p.s.-leave alone the initial few lines, they're just an intro, meant for my teacher..........
n yeah, guys, i'm in an indian school, in XI standard, so my project's supposed to be pretty easy........so plzzzzzzzz make corrections in my project while keeping it in my brain's reach.....all i ask is tht u guys keep it easy...........
this is my program.............

C++ Syntax (Toggle Plain Text)
  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<dos.h>
  4. #include<conio.h>
  5. void main()
  6. {
  7. int gd=DETECT,gm,i,j,x,a,b,c,d,e,f;
  8. initgraph(&gd,&gm," ");
  9. {
  10. setcolor(4);
  11. setbkcolor(0);
  12. settextstyle(4,0,6);
  13. for(a=0;a<=750;a=a+25)
  14. for(b=0;b<=7;b++)
  15. {
  16. {
  17. setcolor(b);
  18. sound(100);
  19. delay(50);
  20. outtextxy(a,a,"COMPUTER PROJECT");
  21. }
  22. clearviewport();
  23. }
  24. for(c=0;c<=350;c=c+5)
  25. for(d=0;d<=7;d++)
  26. {
  27. setcolor(d);
  28. sound(50);
  29. outtextxy(250,250,"made by kanika");
  30. outtextxy(250,300,"and simran");
  31. rectangle(260-c,400-c,200-c,250+c);
  32. }
  33. clearviewport();
  34. {
  35. for(f=0;f<=700;f=f+3)
  36. for(e=0;e<=7;e++)
  37. {
  38. setcolor(e);
  39. circle(360,250,f);
  40. outtextxy(100,230,"AnAlOg ClOcK");
  41. }
  42. }
  43. clearviewport();
  44. nosound();
  45. circle(290,250,200);
  46. outtextxy(260,40,"12");
  47. outtextxy(180,65,"11");
  48. outtextxy(120,135,"10");
  49. outtextxy(100,210,"9");
  50. outtextxy(120,280,"8");
  51. outtextxy(180,350,"7");
  52. outtextxy(260,390,"6");
  53. outtextxy(360,350,"5");
  54. outtextxy(440,280,"4");
  55. outtextxy(460,210,"3");
  56. outtextxy(440,135,"2");
  57. outtextxy(360,65,"1");
  58. for(j=360;j>=0;j=j-5)
  59. for(i=450;i>=0;i=i-5)
  60. {
  61. {
  62. setcolor(4);
  63. setbkcolor(0);
  64. delay(50);
  65. pieslice(290,250,i,i--,100);
  66. setfillstyle(0,0);
  67. floodfill(290,250,0);
  68. circle(290,250,100);
  69. {
  70. delay(300);
  71. pieslice(290,250,j,j--,50);
  72. }
  73. }
  74. }
  75. }
  76. }
  77. getch();


kanika
Last edited by stymiee; Feb 24th, 2007 at 11:58 am. Reason: add code tags
Similar Threads
Reputation Points: 9
Solved Threads: 1
Newbie Poster
kansmish82 is offline Offline
10 posts
since Feb 2007
Feb 24th, 2007
0

Re: plzzzzzzzzzzz help me............

Since you're using non-standard headers, I think most people will have a hard time running your code. And without proper indentation, they'll have a hard time reading it.

To see if I'm understanding the code correctly, I'll repost part of it with comments:
C++ Syntax (Toggle Plain Text)
  1. // don't know what the loop conditions are for...
  2. for(j=360;j>=0;j=j-5)
  3. {
  4. for(i=450;i>=0;i=i-5)
  5. {
  6. {
  7. setcolor(4);
  8. setbkcolor(0);
  9. delay(50); // does this sleep for 50ms?
  10. pieslice(290,250,i,i--,100); // draw second hand
  11. setfillstyle(0,0);
  12. floodfill(290,250,0);
  13. circle(290,250,100);
  14. {
  15. delay(300); // sleep again?
  16. pieslice(290,250,j,j--,50); // draw minute hand
  17. }
  18. }
  19. }
  20. }
The problem is that you'll draw the minute hand every time you draw the second hand. You need to move the innermost block into the outer for loop (after the inner loop), then possibly readjust your loop conditions. Pseudo-code:
C++ Syntax (Toggle Plain Text)
  1. for(/* ... */)
  2. {
  3. for( /* ... */ )
  4. {
  5. /* whatever to draw second hand goes here */
  6. }
  7. /* whatever to draw minute hand goes here */
  8. }
That way the minute hand only gets updated when the second hand has gone all the way around. For the hour hand, do something similar with yet another loop encompassing these.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006
Feb 24th, 2007
0

Re: plzzzzzzzzzzz help me............

plzzzzzzzzzzz read the forum rules, especially
thread titles & homework requests (you want us to finish it for you?)
Code Tags and Formatting C / C++ code (you want us to read your code?)
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006
Feb 25th, 2007
-1

Re: plzzzzzzzzzzz help me............

hey thnx for tryin to help.............cant thnk u enuff
n here are the answers to ur queries......
// don't know what the loop conditions are for...(this one's for the pieslice function....scroll down n u'll c it rite after the commands for the clock's body.....this is solely to change the values so as to make the minute hand move)
  1. for(j=360;j>=0;j=j-5)
  2. {
  3. for(i=450;i>=0;i=i-5)
  4. {
  5. {
  6. setcolor(4);
  7. setbkcolor(0);
  8. delay(50); // does this sleep for 50ms?(yeah......it does)
  9. pieslice(290,250,i,i--,100); // draw second hand
  10. setfillstyle(0,0);
  11. floodfill(290,250,0);
  12. circle(290,250,100);
  13. {
  14. delay(300); // sleep again?(this is to maintain a time gap between the second n minute hands)
  15. pieslice(290,250,j,j--,50); // draw minute hand
  16. }
  17. }
  18. }
  19. }
Last edited by Ancient Dragon; Feb 25th, 2007 at 7:43 am. Reason: add code tags
Reputation Points: 9
Solved Threads: 1
Newbie Poster
kansmish82 is offline Offline
10 posts
since Feb 2007
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

Indent your code and use [code] tags when you post, it'll make everyone happier. And it'll show you how what you posted and what I posted are different.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

hey leave tht plzzzzzzzzzz n help me get outta this mess i've landed in..........u temme how to correct this program....a few corrections that i made are as follows.....

  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<dos.h>
  4. #include<conio.h>
  5. void main()
  6. {
  7. int gd=DETECT,gm,i,j,x,a,b,c,d,e,f;
  8. initgraph(&gd,&gm," ");
  9. {
  10. setcolor(4);
  11. setbkcolor(0);
  12. settextstyle(4,0,6);
  13. for(a=0;a<=750;a=a+25)
  14. for(b=0;b<=7;b++)
  15. {
  16. {
  17. setcolor(b);
  18. sound(100);
  19. delay(50);
  20. outtextxy(a,a,"COMPUTER PROJECT");
  21. }
  22. clearviewport();
  23. }
  24. for(c=0;c<=350;c=c+5)
  25. for(d=0;d<=7;d++)
  26. {
  27. setcolor(d);
  28. sound(50);
  29. outtextxy(250,250,"made by kanika");
  30. outtextxy(250,300,"and simran");
  31. rectangle(260-c,400-c,200-c,250+c);
  32. }
  33. clearviewport();
  34. {
  35.  
  36. for(f=0;f<=700;f=f+3)
  37. for(e=0;e<=7;e++)
  38. {
  39. setcolor(e);
  40. circle(360,250,f);
  41. outtextxy(100,230,"AnAlOg ClOcK");
  42. }
  43. }
  44. clearviewport();
  45. nosound();
  46. circle(290,250,200);
  47. outtextxy(260,40,"12");
  48. outtextxy(180,65,"11");
  49. outtextxy(120,135,"10");
  50. outtextxy(100,210,"9");
  51. outtextxy(120,280,"8");
  52. outtextxy(180,350,"7");
  53. outtextxy(260,390,"6");
  54. outtextxy(360,350,"5");
  55. outtextxy(440,280,"4");
  56. outtextxy(460,210,"3");
  57. outtextxy(440,135,"2");
  58. outtextxy(360,65,"1");
  59. for(j=360;j>=0;j=j-5)
  60. for(i=450;i>=0;i=i-5)
  61. {
  62. {
  63. setcolor(4);
  64. setbkcolor(0);
  65. delay(100);
  66. pieslice(290,250,i,i--,100);
  67. circle(290,250,100);
  68. setfillstyle(0,0);
  69. floodfill(290,250,0);
  70. }
  71. delay(6000);
  72. pieslice(290,250,j,j--,50);
  73. circle(290,250,150);
  74. setfillstyle(0,0);
  75. floodfill(290,250,0);
  76. }
  77. }
  78. }
  79. getch();


kanika
p.s.-will be real gratefull to u if you can help me further
Last edited by Ancient Dragon; Feb 25th, 2007 at 7:48 am. Reason: add code tags
Reputation Points: 9
Solved Threads: 1
Newbie Poster
kansmish82 is offline Offline
10 posts
since Feb 2007
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

Kanika, please use code tags. Your code is unreadable without indentation. It's been mentioned three times in this thread already. Some comments in the code to describe what sections do would be nice as well. And since it's currently 2:00 AM here, I'll look at it when I get up in the morning.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

maybe by the time u do read it, i'll b gone.......but yes, thnx for trying to b of sum help.............
as for the indentations, m new here, joined ystrday, so i hav no idea how u do tht..........
Reputation Points: 9
Solved Threads: 1
Newbie Poster
kansmish82 is offline Offline
10 posts
since Feb 2007
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<dos.h>
  4. #include<conio.h>
  5. void main()
  6. {
  7. int gd=DETECT,gm,i,j,x,a,b,c,d,e,f;
  8. initgraph(&gd,&gm," ");
  9. {
  10. setcolor(4);
  11. setbkcolor(0);
  12. settextstyle(4,0,6);
  13. for(a=0;a<=750;a=a+25)
  14. for(b=0;b<=7;b++)
  15. {
  16. {
  17. setcolor(b);
  18. sound(100);
  19. delay(50);
  20. outtextxy(a,a,"COMPUTER PROJECT");
  21. }
  22. clearviewport();
  23. }
  24. for(c=0;c<=350;c=c+5)
  25. for(d=0;d<=7;d++)
  26. {
  27. setcolor(d);
  28. sound(50);
  29. outtextxy(250,250,"made by kanika");
  30. outtextxy(250,300,"and simran");
  31. rectangle(260-c,400-c,200-c,250+c);
  32. }
  33. clearviewport();
  34. {
  35.  
  36. for(f=0;f<=700;f=f+3)
  37. for(e=0;e<=7;e++)
  38. {
  39. setcolor(e);
  40. circle(360,250,f);
  41. outtextxy(100,230,"AnAlOg ClOcK");
  42. }
  43. }
  44. clearviewport();
  45. nosound();
  46. circle(290,250,200);
  47. outtextxy(260,40,"12");
  48. outtextxy(180,65,"11");
  49. outtextxy(120,135,"10");
  50. outtextxy(100,210,"9");
  51. outtextxy(120,280,"8");
  52. outtextxy(180,350,"7");
  53. outtextxy(260,390,"6");
  54. outtextxy(360,350,"5");
  55. outtextxy(440,280,"4");
  56. outtextxy(460,210,"3");
  57. outtextxy(440,135,"2");
  58. outtextxy(360,65,"1");
  59. for(j=360;j>=0;j=j-5)
  60. for(i=450;i>=0;i=i-5)
  61. {
  62. {
  63. setcolor(4);
  64. setbkcolor(0);
  65. delay(100);
  66. pieslice(290,250,i,i--,100);
  67. circle(290,250,100);
  68. setfillstyle(0,0);
  69. floodfill(290,250,0);
  70. }
  71. delay(6000);
  72. pieslice(290,250,j,j--,50);
  73. circle(290,250,150);
  74. setfillstyle(0,0);
  75. floodfill(290,250,0);
  76. }
  77. }
  78. }
  79. getch();



kanika
p.s.-will be real gratefull to u if you can help me further
Last edited by Ancient Dragon; Feb 25th, 2007 at 7:49 am. Reason: code tags
Reputation Points: 9
Solved Threads: 1
Newbie Poster
kansmish82 is offline Offline
10 posts
since Feb 2007
Feb 25th, 2007
0

Re: plzzzzzzzzzzz help me............

Indentation is just using tabs or spaces to mark where blocks start and end. Look at the difference (btw, there's some comments I added too):
  1. #include<iostream.h>
  2. #include<graphics.h>
  3. #include<dos.h>
  4. #include<conio.h>
  5. void main() // should be int main()
  6. {
  7. int gd=DETECT,gm,i,j,x,a,b,c,d,e,f;
  8. initgraph(&gd,&gm," ");
  9. { // why start a block here?
  10. setcolor(4);
  11. setbkcolor(0);
  12. settextstyle(4,0,6);
  13. for(a=0;a<=750;a=a+25)
  14. for(b=0;b<=7;b++)
  15. {
  16. { // why create a block here?
  17. setcolor(b);
  18. sound(100);
  19. delay(50);
  20. outtextxy(a,a,"COMPUTER PROJECT");
  21. }
  22. clearviewport();
  23. }
  24. for(c=0;c<=350;c=c+5)
  25. for(d=0;d<=7;d++)
  26. {
  27. setcolor(d);
  28. sound(50);
  29. outtextxy(250,250,"made by kanika");
  30. outtextxy(250,300,"and simran");
  31. rectangle(260-c,400-c,200-c,250+c);
  32. }
  33. clearviewport();
  34. { // why create a block here?
  35.  
  36. for(f=0;f<=700;f=f+3)
  37. for(e=0;e<=7;e++)
  38. {
  39. setcolor(e);
  40. circle(360,250,f);
  41. outtextxy(100,230,"AnAlOg ClOcK");
  42. }
  43. }
  44. clearviewport();
  45. nosound();
  46. circle(290,250,200);
  47. outtextxy(260,40,"12");
  48. outtextxy(180,65,"11");
  49. outtextxy(120,135,"10");
  50. outtextxy(100,210,"9");
  51. outtextxy(120,280,"8");
  52. outtextxy(180,350,"7");
  53. outtextxy(260,390,"6");
  54. outtextxy(360,350,"5");
  55. outtextxy(440,280,"4");
  56. outtextxy(460,210,"3");
  57. outtextxy(440,135,"2");
  58. outtextxy(360,65,"1");
  59. for(j=360;j>=0;j=j-5)
  60. for(i=450;i>=0;i=i-5)
  61. {
  62. { // why create a block here?
  63. setcolor(4);
  64. setbkcolor(0);
  65. delay(100);
  66. pieslice(290,250,i,i--,100);
  67. circle(290,250,100);
  68. setfillstyle(0,0);
  69. floodfill(290,250,0);
  70. }
  71. delay(6000);
  72. pieslice(290,250,j,j--,50);
  73. circle(290,250,150);
  74. setfillstyle(0,0);
  75. floodfill(290,250,0);
  76. }
  77. }
  78. }
  79. getch(); // this isn't even in main()
Now, could you restate the prbblems you currently have? I can't run your program because of the headers you're using, but I'll try to help out again...

[edit:] Ok, I just noticed you didn't even put the code tags on your last post. Before I even consider helping you again, you need to learn to use them. It's really easy. When you post your code, you put [code] before it and [/code] after it. That will preserve the indentation when you copy your source and paste it in the post window. Using them is part of the rules of the forum, so you'd better start using them.
Reputation Points: 683
Solved Threads: 53
Posting Virtuoso
Infarction is offline Offline
1,580 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Access Reading Violation
Next Thread in C++ Forum Timeline: Libraries





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC