C :: Program That Have Starting Menu For A Calculator Using If / Else Statement
Sep 21, 2014
I just started learning C and trying to create a program in C that will have a starting menu for a calculator. The problem is that I could do that with a switch/case but the assignment requires me to use if/else.
Here's what I have so far:
Code:
#include <stdio.h>
int calc();
int menu();
int main() {
printf("Hello. Welcome to the program.
");
printf("Press RETURN key to continue...
[Code]...
How should I go from now using if/else to have those 4 choices?
View 5 Replies
ADVERTISEMENT
May 4, 2014
I'm trying to write a program that has a menu with a switch statement. I'm getting "case label'1' not within a switch statement" and subsequent errors for the other two choices and the default.
int main(){
int choice;
Matrix A,B,C;
cout <<"What would you like to do? "<< endl;
[Code]....
View 2 Replies
View Related
May 12, 2013
The premise of this assignment is to create a menu driven, array of functions calculator. This is the code I have thus far (I haven't finished all of my comments yet, I've been to focused on clearing errors).
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*prototypes*/
void sum (int a, int b);
void dif (int a, int b);
void pro (int a, int b);
void quo (int a, int b);
void printMenu();
[Code] .....
I am using Visual Studio as a compiler, and I have the following errors:
error C2144: syntax error : 'int' should be preceded by ')'
error C2660: 'sum' : function does not take 0 arguments
error C2059: syntax error : ')'
error C2144: syntax error : 'int' should be preceded by ')'
[Code] .....
I can only assume that I am making simple mistakes.
View 4 Replies
View Related
Nov 1, 2013
I am using a switch statement as a menu. If I enter a non-integer value as my choice, I expect the error message , "Invalid entry", to display but instead the output keeps running.
View 2 Replies
View Related
Aug 19, 2013
I am trying to write a menu program that will be broken down into a series of calls to function for each of the menu items. Two of the menu items will be simple programs which I wrote.
I want two of the functions to run one of the two programs I am trying to include as items in the menu.
So far I am only familiar with variables, loops, if statements, and I just learned how to write functions.
The problem I am have is that I don't quite understand how to write a function that will run one of the two programs. Also I am having a hard time writing the program in away that would allow the user to select the menu items.
View 2 Replies
View Related
Apr 7, 2014
I'm creating a program that is based on a menu system. Basically each menu is its own user-defined function. The problem is at each menu you can input 'b' to go to the previous menu. I just have it call the function of that menu.
However, do the functions need to complete themselves eventually? If I just keep calling functions will I just keep going further and further deeper into ever running functions?
If so how do I avoid this and yet keep the option to go back to a previous menu/function?
View 2 Replies
View Related
Aug 17, 2012
I'm using a dev c++ bloodshed compiler. How can we write a menu using switch statement?
View 1 Replies
View Related
Sep 20, 2013
how to re-prompt a user with a switch statement menu that I prompted them earlier with. There are 4 options and after the user chooses an option the menu is supposed to pop up again unless the user chooses option 4, how do I do this? For reference I'll put up my source code.
Code:
int main(){
int init_bal,choice,balance,investment, donation;
printf("Welcome!
[Code]....
View 2 Replies
View Related
Aug 17, 2012
The following code prevents windows from letting the monitor go into sleep mode when the program is active and wakes the monitor up after a scanner scans something.
Code:
protected override void WndProc(ref Message m) {
if (m.Msg == W32.Const.WM_SYSCOMMAND &&
(m.WParam.ToInt32() & 0xfff0) == W32.Const.SC_MONITORPOWER && m.LParam.ToInt32() != -1)
{
return;
[Code] ....
When the program is started normally it works fine. But when the program is started from a network share it goes to sleep anyway and the OnScan does not work anymore. Removing the Send Message line makes On Scan work again but then the monitor wont wake up on a scan of course.
What could be the problem here when started from the network?
View 1 Replies
View Related
Aug 26, 2014
'm trying to program a BMI calculator in C for my assignment where the weight must be in KG and an int , and the height must be in m and a double value. The program should allow the user to input his weight(kg) and height(m) separated by a space and be able to calculate and display the BMI. My code is shown below :
#include<stdio.h>
int
main(void) {
int weight;
double height,bmi;
bmi = weight / ( height * height ) ;
scanf("%d%lf" , &weight , &height );
printf("BMI = %f", bmi);
return 0;
}
However , after running the program , I constantly get a 1.#INF00 value for my result.The compiler did not show any errors so why I'm getting this value.I input my weight and height in this format "45 1.65" 45 being the weight and 1.65 being the height.
View 3 Replies
View Related
Jan 29, 2014
I am supposed to get 2 numbers then have the person choose what they want to do to the numbers. Here is the code:
//Mike Karbowiak
//12/24/13
//Mathematics
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
[Code] ....
The errors I am getting so far are:
error C2660: 'Add' : function does not take 0 arguments
error C2660: 'Subtract' : function does not take 0 arguments
error C2660: 'Multiply' : function does not take 0 arguments
error C2660: 'Divide' : function does not take 0 arguments
View 3 Replies
View Related
Nov 6, 2014
I'm working on below program and I want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one user defined function called computeConeVolume that contains the calculation. In other words I want to remove the one line calculation and replace it with a function call, then write and add the function below main with the calculation, surrounded any other syntax that I need to complete it.
The function should contain local variables and a constant declared and must have the calculation, it may not do anything else such as input or output. Should be able to declare "global" variables anywhere but no variables above or outside of main() and the function are allowed. A value-returning function should be used because it's a little simpler to understand, but you can employ a void function. Need to have a function prototype at the top of the code, then main, then your function.
//Cone Volume Calculator Program
#include <iostream>
using namespace std;
int main( ) {
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;
[Code] ....
View 6 Replies
View Related
Apr 26, 2013
I am basically trying to make a program for a calculator. I am struggling with how to do the sine calculation. this calculation will take place at line 158.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double firstNumber = 0.0;
double secondNumber = 0.0;
char operation =' ';
[Code] ....
View 1 Replies
View Related
Mar 21, 2014
I have to make a calculator program that has 5 different functions (this is obviously the easy part, once all the input is assigned to their respective variables), which are addition, subtraction, mod, multiplication and division (negatives are not allowed, and must be error-checked; spaces must be ignored). I need to take the equation from the user, echo it back and then solve the problem.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
[Code].....
View 4 Replies
View Related
Dec 14, 2013
i try to write a postfix calculator program using stack in C++ the in put must be the infix expression but can dont know how to write a infix expression in put.
this is my code :
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
using namespace std;
}
[code]....
View 2 Replies
View Related
Oct 29, 2014
So, I was trying to code a menu for a personal movie database. But I'm having some problems.So, this is what I did,
Code:
#include<stdio.h>
int main();
{
do
{printf("Menu
[Code]...
But this is not working.Furthermore I would also like add a sub menu.
View 7 Replies
View Related
Apr 27, 2013
I hate vague errors where I don't even know where to start looking for an error. Error happens immediately and it says "Unhandled exception at 0x5981c9c7 (msvcr100d.dll) in experiment.exe: 0xC0000005: Access violation reading location 0xabababab."
#include <iostream>
#include <string>
#include <conio.h>
[Code].....
View 2 Replies
View Related
Feb 21, 2014
I am new to C programming, I have been given an assignment to create a simple calculator by splitting the program in 3 files. It should have 2 .c files and 1 .h... I went through the internet extensively and could only come up with this.
main.c:
Code:
//Calculator main.c
#include <stdio.h>
#include <conio.h>
#include "Functions.h"
int main() {
float x = 0, y = 0;
int operation;
[Code]...
Functions.c
Code:
#include "Functions.h"
extern float x, y;
float addition (float a, float b) {
return a + b;
[Code]...
Functions.h
Code:
#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
float Sum(float a, float b);
float difference (float a, float b);
float remainder (float a, float b);
float product (float a, float b);
#endif
When I do a 'cl main.c' on the Developer Command window for VS2013, i get an error that reads :
main.obj
main.obj : error LNK2019: unresolved external symbol _difference referenced in function _main
main.obj : error LNK2019: unresolved external symbol _product referenced in function _main
main.obj : error LNK2019: unresolved external symbol _addition referenced in function _main
main.exe : fatal error LNK1120: 3 unresolved externals
View 5 Replies
View Related
Nov 10, 2013
I want to incorporate a button into my current program that opens up a calculator in a different window. I have the code for the calculator and the program. I have never worked with buttons or windows.
View 4 Replies
View Related
Mar 13, 2014
I just started learning the basics of programming. While encountering one of the practice problems in the book by Alex Allain I got a little confused. The question is as follows:
Write a menu program that lets the user select from a list of options, and if the input is not one of the options, reprint the list.
The author assumes you can answer this question only using if statements and/or loops (while, for and do).
This is the code I've written thus far:
Code: #include <iostream>
using namespace std;
int main()
{
int option;
char reset;
[Code] ....
For some reason, the nested while loop keeps repeating even when you input a valid option (1, 2 or 3). I can't seem to figure out why this happens.
View 4 Replies
View Related
Feb 29, 2012
To add my program into the context menu (when the user right click on excel file). I used the following code:
Code:
public static bool AddContextMenuItem(string Extension, string MenuName, string MenuDescription, string MenuCommand)
{
bool ret = false;
RegistryKey rkey = Registry.ClassesRoot.OpenSubKey(Extension);
if (rkey != null)
{
string extstring = rkey.GetValue("").ToString();
[Code] .....
I used the following function to retrieve the excel file path has been rightclick choose to load the program:
Code:
public static void OpenExcelFileWithEasyForm(string filePath)
{
try
{
string excelFilePath = Path.Combine(Path.GetDirectoryName(filePath), string.Format("{0} (EasyForm){1}", Path.GetFileNameWithoutExtension(filePath), Path.GetExtension(filePath)));
[Code] .....
But I still do not load the excel file into my program by selecting the program from ContextMenu (right click on excel file and choose program). Although if select the path to excel file from the program, the data from excel file is loaded into the program.
I'm still missing something at function OpenExcelFileWithEasyForm(). How to complete this function to load the excel file into my program when selecting programs in ContextMenu.
View 1 Replies
View Related
Oct 16, 2013
Can not seem to get the program to perform the calculations within the cases. Also, how do you set up the a prime function program within the menu. Have been trying for five days now.
#include <iostream>
#include <cmath>
#include <cstdlib>
using namespace std;
void showChoices();
double prime(double, double);
double abs(double, double);
double pow(double, double);
[Code]...
View 1 Replies
View Related
Apr 7, 2014
This is what I have so far, it gives me a nice menu to select from and it all works but after I make a selection it closes the program. I tried to return to it but it won't work for me
#include <stdio.h>
int main() {
int choice;
int deposit;
int balance = 500; {
printf(" CHOOSE FROM THE FOLLOWING
[code]....
View 14 Replies
View Related
Mar 23, 2014
I decided to create a simple program to display a menu with options, while that is easy enough I had some difficulty when selecting an option that has options inside which also has an option again. While I had many issues in the past I'm finally finished with it and it works fine, but being new to programming and not knowing various other methods available.
Code:
//:::::::::::::::::::::Simple Menu Program::::::::::::::::
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <iostream>
#include <string>
//function prototypes
[Code] .....
View 1 Replies
View Related
Feb 13, 2015
I tried to write a menu program as a switch-case structure with a separate function for a switch-case structure itself. The outcome for it currently is an undesired one
Code:
#include <iostream>
using namespace std;
int menu(int answer);
int main()
[Code].....
The output I get is one where it's just an infinite loop of "Bad choice! Please try again later.".
View 7 Replies
View Related
Jun 1, 2013
I just recently finished up a program that implements Dijkstra's Algorithm and I thought I would make a nice little menu for the user.
so the user can input their locations, I use Getline just in case their location contains spaces. However, when the user selects 2, It skips over the first input for the "Source" location and only lets the user input for the "Destination".
Any reason why this would happen? Am I missing something with Getline? Anyway, here's the code...
template <typename V, typename E>
void Graph<V, E>::Driver() {
bool done = false;
int menu(0);
InputFile();
[Code] ......
View 2 Replies
View Related