Home / Software / Computer programming / C# HELP - Factors of a number.
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 [2]  All - (Bottom) Print
Author Topic: C# HELP - Factors of a number.  (Read 4839 times)
BC_Programmer
Mastermind


Thanked: 697
Posts: 15,881

Computer: Specs
Experience: Beginner
OS: Windows 7


Pinkie Pie is best pony

BC-Programming.com 1 1
« Reply #15 on: February 27, 2009, 11:57:05 AM »

Quote
do not hijack somebody elses

And BC,  you never do that?

er... That's different, I "ease" the thread innocently in a different direction.  ;D

And I usually have accomplices.
IP logged

My Blog

BASeBlock 2.3.0 (NOW WITH MACGUFFINS!)
Jesz31
Starter



Posts: 4


« Reply #16 on: March 13, 2009, 07:05:10 PM »

hello guyz... i need your help??? what is wrong in this program>>>
when I press N it will go to choice but I can't input any letters because it will terminate
help.. me plz....

#include<stdio.h>
#include<conio.h>
main()
{
int a,d,c,s,h,ls,car,scifi,ans;
char ch;
#define p printf
#define g gotoxy
#define c cprintf
choice:
{clrscr();
g(17,2);p(" >>()> JESSAR_AMA VIDEO RENTALS <()<< ");
g(25,3);p("CONTACT No.09092957632");
g(15,7);p("PRESS[");textcolor(WHITE+BLINK);c("A");p("]for ACTION:");
g(15,9);p("PRESS[");textcolor(WHITE+BLINK);c("D");p("]for DRAMA:");
g(15,11);p("PRESS[");textcolor(WHITE+BLINK);c("C");p("]for COMEDY");
g(15,13);p("PRESS[");textcolor(WHITE+BLINK);c("S");p("] for SUSPENSE:");
g(15,15);p("PRESS [");textcolor(WHITE+BLINK);c("L");p("] for LOVE STORY:");
g(15,17);p("PRESS [");textcolor(WHITE+BLINK);c("H");p("] for HORROR:");
g(15,19);p("PRESS [");textcolor(WHITE+BLINK);c("F");p("] for  FICTION\n");
p("\n              Enter your choice:_");gotoxy(33,21);
scanf("%c",& ch);}
switch(ch)
{
case 'A': clrscr();
g(29,1);textcolor(BLUE+BLINK);c("***************");
g(29,3);textcolor(BLUE+BLINK);c("***************");
g(43,2);textcolor(BLUE+BLINK);c("*");
g(29,2);textcolor(BLUE+BLINK);c("*");
g(30,2);textcolor(WHITE);c("ACTION MOVIES");
g(30,5);p("Are you sure?[Y/N]");
scanf("%s",&ans);
if (ans=='N')
{
goto choice;
}
break;

case 'D': clrscr();
g(29,1);textcolor(RED+BLINK);c("**************");
g(29,3);textcolor(RED+BLINK);c("**************");
g(42,2);textcolor(RED+BLINK);c("*");
g(29,2);textcolor(RED+BLINK);c("*");
g(30,2);textcolor(WHITE);c("DRAMA MOVIES");break;

case 'C': clrscr();
g(29,1);textcolor(YELLOW+BLINK);c("***************");
g(29,3);textcolor(YELLOW+BLINK);c("***************");
g(43,2);textcolor(YELLOW+BLINK);c("*");
g(29,2);textcolor(YELLOW+BLINK);c("*");
g(30,2);textcolor(WHITE);c("COMEDY MOVIES");break;

case 'S': clrscr();
g(29,1);textcolor(GREEN+BLINK);c("******************");
g(29,3);textcolor(GREEN+BLINK);c("******************");
g(45,2);textcolor(GREEN+BLINK);c("*");
g(29,2);textcolor(GREEN+BLINK);c("*");
g(30,2);textcolor(WHITE);c("SUSPENSE MOVIES");break;

case'L':clrscr();
g(29,1);textcolor(RED+BLINK);c("*******************");
g(29,3);textcolor(RED+BLINK);c("*******************");
g(47,2);textcolor(RED+BLINK);c("*");
g(29,2);textcolor(RED+BLINK);c("*");
g(30,2);textcolor(WHITE);c("LOVE STORY MOVIES");break;

case 'H': clrscr();
g(29,1);textcolor(YELLOW+BLINK);c("***************");
g(29,3);textcolor(YELLOW+BLINK);c("***************");
g(43,2);textcolor(YELLOW+BLINK);c("*");
g(29,2);textcolor(YELLOW+BLINK);c("*");
g(30,2);textcolor(WHITE);c("HORROR MOVIES");break;

case 'F': clrscr();
g(29,1);textcolor(GREEN+BLINK);c("****************");
g(29,3);textcolor(GREEN+BLINK);c("****************");
g(44,2);textcolor(GREEN+BLINK);c("*");
g(29,2);textcolor(GREEN+BLINK);c("*");
g(30,2);textcolor(WHITE);c("FICTION MOVIES");break;

default:gotoxy(17,40);textcolor(RED+BLINK);cprintf("             SORRY THE MOVIE TYPE YOU WANT IS NOT AVAILABLE!!!");
}

getch();}


IP logged
ultimatum
Topic Starter
Intermediate



Thanked: 3
Posts: 217




PC Technology
« Reply #17 on: March 14, 2009, 01:39:14 PM »

I'm not sure what language this is, but why are you entering 'N', the menu should initiate right away and be waiting for your input.

Why do you have this line "int a,d,c,s,h,ls,car,scifi,ans;"? Why are these letters type of int? or is that a continuation of the program?
IP logged

Its not what you know, its what you can do that counts!
Geek-9pm
Sage



Thanked: 373
Posts: 8,930

Computer: Specs
Experience: Expert
OS: Windows XP


Geek After Dark

Geek 9pm blog
« Reply #18 on: March 27, 2009, 09:12:38 PM »

If you want other people to help you, try to avoid this sort of thing:
Code: [Select]
#define p printf
#define g gotoxy
#define c cprintf

If makes things hard to read and you can make a very bad error.

Aldo, it helps if you use a High-Level approach for something that is not going to be used to launch rockets .
Make a case block as clean and neat as you can. avoid details.
Something like this:

Code: [Select]
case 'A' : dofirst;(); break;
case 'D' : dosecond();  break;
case 'E' : dothird(); break ;
case 'N' : goto choice;

Using inline code makes it hard to debug. Start out with void functions  that are 'stubs', they don't do anything, but they are place holders where you will expand the code later as you work out the logic flaws. The concept is to HIDE details the are not relevant to the logic of what you are doing.
This way you separate the logic from the decoration.

IP logged

Pages: 1 [2]  All - (Top) Print 
Home / Software / Computer programming / C# HELP - Factors of a number. « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.101 seconds with 19 queries.