![]() |
| | #1 |
| Registered User Join Date: Jun 2008
Posts: 5
| a sample program i programmed.. we are mostly mathematical based so GAMES are not familiar to me in programming: /*Asks the user to input a binary number then converts it into decimal*/ Code: #include<stdio.h>
main()
{ int nBin, nDec, nMult, nDigit;
printf("Enter Binary Number:");
scanf("%d", &nBin);
nDec=0;
nMult=1;
while(nBin!=0)
{nDigit=nBin%10;
nDec+=nDigit*nMult;
nMult*=2;
nBin/=10;
}
printf("Decimal: %d", nDec);
getchar();
getchar();
}
Last edited by jumbo2410; 07-29-2008 at 09:05 AM. Reason: MacGyver told me... |
| jumbo2410 is offline | |
| | #2 | |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| Figure out how to use code tags. This is the 2nd time. Put them around the code only, not your entire post, because it messes up the format and makes my eyes grow weaker trying to read it. And that's not what you want, right? Of course you don't want me going blind. Example: Quote:
__________________ | |
| MacGyver is offline | |
| | #3 |
| Registered User Join Date: Nov 2005
Posts: 146
| With plain printf it will be hard. You do want to use some non standard C library for mowing your worm. I guess you could read some reference manual for ncurses library, and accomplish what you want with it |
| Maz is offline | |
| | #4 |
| Registered User Join Date: Jun 2008
Posts: 208
| Do you care about C standarts?
__________________ gavra. |
| gavra is offline | |
| | #5 |
| Registered User Join Date: Jun 2008
Posts: 5
| yes I do... |
| jumbo2410 is offline | |
| | #6 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Then you will struggle - the C standard library has no options for moving the cursor around on the screen. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #7 |
| Registered User Join Date: Jul 2008
Posts: 7
| i think you can use some libraries such as conio.h, time.h, stdlib.h, and graphics.h... DJ! |
| jaypeebee18 is offline | |
| | #8 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
-- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
![]() |
| Tags |
| basic variables, c program, game, programming, snake program |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using variables in system() | Afro | C Programming | 8 | 07-03-2007 12:27 PM |
| [Help] Simple Array/Pointer Program | sandwater | C Programming | 3 | 03-30-2007 02:42 PM |
| simple silly program | verbity | C Programming | 5 | 12-19-2006 06:06 PM |
| Idiot Trying To Write A Simple Program | verd | C Programming | 4 | 02-05-2005 07:06 AM |
| Simple simple program | Ryback | C++ Programming | 10 | 09-09-2004 05:48 AM |