![]() |
| | #1 |
| Registered User Join Date: Nov 2009 Location: Ireland
Posts: 19
| assignment help. [urgent] Code:
#include <stdio.h>
void main()
{
int maxfactorial=0, minfactorial=0, line=0, factorial=0, i=0;
printf("enter max factorial\n");
scanf("%d", &i);
printf("enter min factorial\n");
scanf("%d", &minfactorial);
printf("--------------------------------------------------------------------");
while (line<=0){
printf("\nFactorial Value Factorial expression Result");
line=line+1;
}
maxfactorial=i;
factorial=i;
while ( factorial>=minfactorial){
printf("\n%d" ,maxfactorial);
maxfactorial=maxfactorial-1;
factorial=factorial-1;
}
}
|
| Ciaran789 is offline | |
| | #2 |
| Registered User Join Date: Aug 2006 Location: Liverpool UK
Posts: 553
| Problem? Considering this is urgent you have not really filled us in on the details, like what is the problem you are having? I cant be bothered going through an assignment question, just say what the issue is with code you posted |
| rogster001 is offline | |
| | #3 | |
| DESTINY Join Date: Jul 2008 Location: in front of my computer
Posts: 803
| Quote:
Code: #include <stdio.h>
int fact(int num)
{
int i,facto=1;
for(i=1;i<=num;i++)
facto=facto*i;
return facto;
}int main(void)
{
int maxfactorial=0, minfactorial=0, line=0, factorial=0, i=0;
printf("enter max factorial\n");
scanf("%d", &i);
printf("enter min factorial\n");
scanf("%d", &minfactorial);
printf("--------------------------------------------------------------------");
while (line<=0){
printf("\nFactorial Value Factorial expression Result");
line=line+1;
}
maxfactorial=i;
factorial=i;
while ( factorial>=minfactorial){
printf("\n%d%60d" ,maxfactorial,fact(maxfactorial));
maxfactorial=maxfactorial-1;
factorial=factorial-1;
}
return 0;
}
__________________ HOPE YOU UNDERSTAND....... By associating with wise people you will become wise yourself It's fine to celebrate success but it is more important to heed the lessons of failure We've got to put a lot of money into changing behavior PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D. IDE- Microsoft Visual Studio 2008 Express Edition | |
| BEN10 is offline | |
| | #4 |
| The Beautiful C++ Utopia Join Date: Oct 2007
Posts: 16,515
| Don't give out solutions! Newbies learn nothing if you do it. It is they who must learn, not us. We get nothing by simply handing out solutions except create more dumb programmers out there who do not deserve their title.
__________________ WARNING: Any and all code samples I post are not tested unless explicitly mentioned otherwise. Use at your own risk. Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2010 Ultimate, C++0x "Thanks Elysia. You're a programming master! How the hell do you know every thing?" "Thanks for all your help. It's obvious yall really know what you're talking about when it comes to OOP/C++ stuff." Quoted... at least once. Why did the Java creators shoot themselves in the foot? |
| Elysia is offline | |
| | #5 |
| Registered User Join Date: Nov 2009 Location: Ireland
Posts: 19
| thanks, i understand that bit now. one more question. do i need to use a loop to print the factorial expression? |
| Ciaran789 is offline | |
| | #6 |
| Registered User Join Date: Nov 2009
Posts: 14
| Well, yes. The loop should go from the number (x from x!) down to 1. But I don't get why you did this: Code: int maxfactorial=0, minfactorial=0, line=0, factorial=0, i=0;
...
while (line<=0){
printf("\nFactorial Value Factorial expression Result");
line=line+1;
}
Last edited by Junky; 11-29-2009 at 08:50 AM. |
| Junky is offline | |
| | #7 |
| Registered User Join Date: Nov 2009 Location: Ireland
Posts: 19
| i put the while loop in because it was the only way i could get it to work. im not that good at programming yet.only in my first year. |
| Ciaran789 is offline | |
| | #8 |
| The Beautiful C++ Utopia Join Date: Oct 2007
Posts: 16,515
| Start by making a flowchart.
__________________ WARNING: Any and all code samples I post are not tested unless explicitly mentioned otherwise. Use at your own risk. Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2010 Ultimate, C++0x "Thanks Elysia. You're a programming master! How the hell do you know every thing?" "Thanks for all your help. It's obvious yall really know what you're talking about when it comes to OOP/C++ stuff." Quoted... at least once. Why did the Java creators shoot themselves in the foot? |
| Elysia is offline | |
| | #9 |
| Registered User Join Date: Nov 2009
Posts: 14
| |
| Junky is offline | |
| | #10 |
| Registered User Join Date: Nov 2009 Location: Ireland
Posts: 19
| thanks for the help guys. |
| Ciaran789 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Menu | Krush | C Programming | 17 | 09-01-2009 02:34 AM |
| Assignment Operator, Memory and Scope | SevenThunders | C++ Programming | 47 | 03-31-2008 06:22 AM |
| Screwy Linker Error - VC2005 | Tonto | C++ Programming | 5 | 06-19-2007 02:39 PM |
| Help with a pretty big C++ assignment | wakestudent988 | C++ Programming | 1 | 10-30-2006 09:46 PM |
| A mini-compilier I made stuck in an infinite loop (lots of code) | dan06 | C++ Programming | 1 | 10-27-2006 01:21 PM |