|
Search
|
||||||
Need a little help with programming in C#HTML & Coding HTML, XHTML, CSS, XML and other coding issues you may code into. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
Need a little help with programming in C#
If anyone knows how to program in C#, I have a question.
This is the part of my code in question: Code:
/* while loop will keep prompting user inputs EOF */
while (flag != EOF)
{
/* user prompt will loop if while statement is true */
printf("Enter annual interest rate (in decimal): ");
flag = scanf("%f" ,&annual_interest);
printf("Calculate compounding years, months or days?\n");
printf("Enter '1' for years, '2' for months, '3' for days: ");
flag = scanf("%f", &compound);
if (compound = 1)
{ printf("Enter number of years compounding: ");
flag = scanf("%f" ,&years);
}
else if (compound = 2)
{ printf("Enter number of months compounding: ");
flag = scanf("%f", &months);
years = months / 12;
}
else if (compound = 3)
{ printf("Enter number of days compounding: ");
flag = scanf("%f", &days);
years = days / 365;
}
But my problem is that the "if" statements seem to be ignored for some reason. I know that the user is assigning "compound" and the "if" statements should be reading "compound" to see which one of the statements are true. But it simply runs as if there were no "if" statements at all. I tried commenting out the first "if" statement and it prompted me for "months" regardless of what number I assign "compound" as. the same happens if I don't comment out the first "if" statement, in which case it would keep prompting me for "years". Does anyone know what I am doing wrong? Thanks!
__________________
Spike |
| Advertisement |
|
#2
|
||||
|
||||
|
okay nm, it was a totally stupid error that I overlooked.
if anyone is wondering, i used "=" as an equality instead of "==". "=" is only used for assignments.
__________________
Spike |
|
#3
|
||||
|
||||
|
Glad I could help
![]() Actually, I am in the process of learning C, so I was going to whip out my book and see if I could figure it out.
__________________
A wise man can learn more from a foolish question than a fool can learn from a wise answer. ~Bruce Lee |
|
#4
|
||||
|
||||
|
I do PERL. Well I try to do PERL.
__________________
"I think there is a world market for maybe five computers."-Thomas Watson, chairman of IBM, 1943. "There is no reason anyone would want a computer in their home."-Ken Olson, founder of DEC, 1977. |
![]() |
| Tags |
| programming |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Programming computer question | Dave601 | General Hardware | 5 | Oct 24th, 04 8:17 PM |
| Programming Problem | Dave601 | Windows XP | 3 | Feb 12th, 04 2:40 AM |
| What programming languages do you know? | xtremegamer | HTML & Coding | 19 | Dec 3rd, 03 2:07 AM |