•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 402,375 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,106 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1454 | Replies: 2 | Solved
![]() |
•
•
Join Date: Oct 2006
Posts: 10
Reputation:
Rep Power: 2
Solved Threads: 0
The problem is that when I enter the choice, nothing happens and the answer remains 0. Please help I'm new at this and I tried everything!!
Thanks
Thanks
c Syntax (Toggle Plain Text)
#include <stdio.h> #include <conio.h> main () { int a,b; float answer; char choice; clrscr(); printf ("\nEnter a number: "); scanf ("%d",&a); printf ("\nEnter another number: "); scanf ("%d",&b); printf ("\n"); gotoxy(10,5); printf("\n MENU"); printf("\n+...addition"); printf("\n*...multiplication"); printf("\n/...division"); printf("\nM...modulo division"); printf("\n"); printf("\nEnter your choice"); //scanf("%c",&choice); choice = getch(); switch(choice) {case'+' :{ answer = (a + b); break; } case'*' :{ answer = (a * b); break; } case'/' :{ answer = (a / b); break; } case'M' :{ answer = (a % b); break; } default : break; } printf("\n"); printf("\nThe answer is "); printf("%d",answer); getch(); }
•
•
Join Date: Jun 2005
Location: Novi Sad, Serbia
Posts: 273
Reputation:
Rep Power: 6
Solved Threads: 29
Variable answer is float not int. Instead of
printf("%d",answer); use printf("%f",answer); instead. Dont use nonstandard func (use them only if your teacher explicitly demanded). You need a getchar in front of choice input. Use int main and not main. Last edited by andor : Oct 27th, 2006 at 7:49 am.
If you want to win, you must not loose (Alan Ford)
![]() |
•
•
•
•
•
•
•
•
DaniWeb C Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Creating a popup menu on mouse over (JavaScript / DHTML / AJAX)
- need help to solve this problem (Java)
- dropdown menu problem (HTML and CSS)
- Drop Down Menu - Problem Opening in IE (JavaScript / DHTML / AJAX)
- For some reason program installations cannot create new start menu shortcuts... (Windows NT / 2000 / XP / 2003)
- Windows 98se language problem (Windows 9x / Me)
- Right Click menu editing problem (Windows NT / 2000 / XP / 2003)
- IE causing problem with Win Explorer Display (Web Browsers)
Other Threads in the C Forum
- Previous Thread: Adding \ to string
- Next Thread: dll problem,help me:)


Linear Mode