C/C++ :: Assigning Variable From Multiple Choice Answer

Oct 29, 2014

I tried to create a multiple choice list and I want to assign the value of the answer option chosen by the user so I can use it later on in the code. Later on in the code i've asked how many people (p) want a drink and multiplied it by the chosen size to calculate the price c = p * n where c is cost, n is price and p is number o of people At the bottom i tried to assign parameters where depending on what option the user has chosen n will be assigned to the chosen value...

{
printf("
SELECT TYPE OF PAINT:
"); /*multiple choice of paint */
printf("1. Large
");

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Randomized Multiple Choice

Feb 20, 2012

I have gotten my code sorted out, and now it works. But to be adaptable to 3pi robots, which I will be loading it into eventually, the user has to be given three letter (a, b, c) multiple choices for answer input to the math questions. The three choices have to be randomized everytime the program loops too. Currently it just runs on number input.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
int menu();
void addition(int *Preward); // function to return truth values
void subtraction(int *Preward);

[Code] ....

View 4 Replies View Related

C# :: Multiple Choice Symptom Checker?

Mar 9, 2015

I'm doing a project through college which is a diagnostic and support tool for Windows OS's. The application at the moment has a simple expert system which is a Combobox with strings that relate to common PC problems. Then those strings are put through a switch statement and relevant commands are shown to fix the problem i.e. "My printer is not working" will disable all buttons except for printer management, spooler folder etc.

My supervisor who marks my project has said this isnt good enough and wants a more layered hierarchy approach so he's looking for 3-4 groupboxes with tickboxes inside them and users tick the boxes that relate to their problem which will give the functions to support. The only way I can see to do this at the moment is a massive nested switch statement that is really not worth the time. There are 60+ functions in my program so you can imagine how long the switch would be trying to pick and iterate through all of the possible answers.

I'm just trying to figuire out an easier way to do this, rather than a massive switch statement. Something like WebMD which has 4-5 tick boxes and can give out the same answer for different symptoms.

I've attached a Flow Chart I made of the hierarchy Im trying to go for [URL] .....

View 1 Replies View Related

C++ :: Multiple Choice Function - Using Character As Parameter

Feb 20, 2012

I have a multiple choice function below that is part of a larger program but I am having trouble having it operate with characters as inputs and arguments. It has to be a character input, but I kinda want it to act like an integer, how do i do that?

Code:
void addition(int *Preward) //function that is called by the users selection {
int random1, random2;
int order;
int one, two, three;
int rando1, rando2;
char a, b, c; // ERROR

[Code] ....

View 2 Replies View Related

C :: Create Multiple Choice Quiz Works But With A Warning

Apr 10, 2013

I am trying to create a multiple choice quiz so I can learn the menu at my new job, while doing a side project but I am having a warning when outputting. Speaking of side projects, is this a kind of side project people are looking for on a resume?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
}

[code]....

View 8 Replies View Related

C++ :: Grading Multiple Choice Test - Getting Infinite Loop?

Nov 4, 2013

I am writing a program for grading a multiple choice test. The test data is pulled in from another file. My problem is that its only pulling in the first line of data and running an infinite loop without reading the next line of the data file.

My code is as follows:

PrintPurpose ( );
cout << student << " ";
cout << answers << " ";
inData >> key;

[Code].....

View 1 Replies View Related

C++ :: How To Create True False And Multiple Choice Questions Using Text Files

Jan 7, 2015

So im trying to create a quiz using c++ that incorporates three different types of questions. These are the standard one answer question, true false questions and multiple choice questions.

How to create the true false and multiple choice questions?

One way that i came up with looks like this

Question A answer1 B answer2;

View 2 Replies View Related

C++ :: Write A Loop Assigning Variable X To All Positions Of String Variable

Sep 8, 2013

I have to write a loop assigning a variable x to all positions of a string variable and I'm stuck. I don't have extensive experience with arrays and I'm also a bit confused about C-String. The problem is below.

"Given the following declaration and initialization of the string variable, write a loop to assign 'X' to all positions of this string variable, keeping the length the same.

char our_string[15] = "Hi there!";

(Please note this is a 'C-string', not C++ standard string.)"

View 5 Replies View Related

C :: Scanning CSV File And Assigning Variable To It

Dec 26, 2013

How to scan a CSV file and assigned variable to each of the integer scanned in a csv file

an example of the csv file:
0001,40,,10

How do I scan the CSV file and assign 0001 to variable student id, the 40 to variable module 01,the 1 without input entered to module02 and 10 to module03

View 6 Replies View Related

C++ :: Assigning Reference Variable To Another Of Same Type

Jun 4, 2012

What is wrong with assigning a reference variable to another reference variable of the same type? I guess I have not understood references very well.

1- In below code, the initialization list gets error because agent "object reference variable" cannot be initialized with a reference variable of the same type.

Code:
class Intention {
public:
Intention(Agent& agent,int Id, string name);

[Code] ....

In other places I have the same problem. In below code the assignment gets error (no overloaded function for assigning a reference to another reference?)

Code:
void Agent::setWorld(World& world) {
this->world = world;
}

//Note: this->world has a type of World&

2- In this other one, I want to assign reference of a vector member to a reference variable of the same type.

Code:
vector<Intention> intentions;
...
Intention& currentIntention = intentions[intentionsIterator]

View 6 Replies View Related

C :: Assigning Array With A Variable Number Of Elements

Jul 18, 2014

I have a simple problem about memory allocation.In the function Nr_elements() i assign a value which represent the elements of array. The pointer p is initialised with the address of variable n, but when i compile i dont know why but dont work. This function return a pointer.

Code:
#include<stdio.h>
#include<stdlib.h>
int *Nr_elements();
int *allocate(int);
void deallocate(int *);
[code]....

View 3 Replies View Related

C :: Variable Access Across Multiple Files

Sep 7, 2013

I was trying out programs based on extern and as i understand, this is useful when accessing variables across multiple files having only one definition. But i tried a simple program as below without "extern" and thing seem to work when i expected it would fail during linking process

Code:
file5.c
1 #include <stdio.h>
2 #include "var.h"
3
4 int main() {
5
6 printf("
File5.c a = %d", a);

[Code] .....

As i have included "var.h" in all header files without extern, "int a" would be included in both the .c file and during linking, compiler should have thrown a warning or error message but it compiles file without any issue. Shouldn't var.h have the following "extern int a"?

View 8 Replies View Related

C++ :: Maintain Variable Between Multiple Process

Mar 9, 2013

In the existing code,fork has call parallel to create process.my job is to store all the process id into vector so that we can verify the status of the jobs. I was able to save all the jobs but as the callback happen so I have lost my all value which was store into vector.

How can i maintain variable between multiple process.

View 1 Replies View Related

C/C++ :: Multiple Malloc Calls On One Variable?

Feb 13, 2013

I'd like to know what happens if I use multiple calls to malloc() on one pointer (without free) in a single function. Here is the example:

void *data_thread(void *sockfd_ptr) {
  int sockfd = *(int *) sockfd_ptr;
  const int BUFSIZE = 5;
  char recvmessage[BUFSIZE];
  char *headerstr = NULL;
  char *newheaderstr = NULL;

[code]....

what happens with newheaderstr every time malloc() is called. There isn't a realloc() or anything. I didn't think it looked right to keep using malloc() like that.

View 4 Replies View Related

C++ :: Passing Multiple Variable To Function That Has Stringstream And Text

Dec 24, 2013

I have a quick question about passing multiple variable to a func that has (stringstream & text). Here is the code:

void PrintText(stringstream & txt) {
cout << txt.str() << endl;
}
void main() {

[Code] ....

How to make second one work?

View 11 Replies View Related

C++ :: Get Correct Answer For Every Value Of X / N And A

Jun 10, 2014

I am expecting to get correct answer for every value of x, n and a[i] where

-10^9 <= a[i] <= 10^9
1 <= x <= 10^18
and 1 <= n <= 10000

Every value here is an integer value

#include<cstdio>
#include<iostream>
#include<cmath>
#include <float.h>

#define sBig long long int

[Code] .....

View 1 Replies View Related

C++ :: End Loop After Answer Is 0

Mar 23, 2014

I am writing a program to tell how long it will take for a loan to be paid off supposing the desired loan is 100,000, the annual percentage rate is 6, and the monthly payment is 1,000. What happens is after I run the program, I get the output of "-24.60" after the last month is paid off. I'm trying to get it to where the last monthly payment is only enough to make the loan 0. Then I want the program to end.

#include <iostream>
#include <iomanip>
using namespace std;

[Code]....

View 4 Replies View Related

C :: Correct Answer Does Not End Game

Feb 21, 2013

Okay so I thought I had this assignment completed properly last week. Last night I found a bug while playing the game.why won't the game end when the player guesses the correct number? The game allows you to finish using the max number of guesses even though you already guessed the correct number.

Code:

#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define MAXGUESSES 6
#define MAXGAMES 20
#define MAXNUMBER 100
}

[code]....

View 9 Replies View Related

C++ :: Reading Int Choice In With A String Buffer Instead Of Cin?

Sep 25, 2013

How do you read an int choice in with a string buffer instead of cin?

View 2 Replies View Related

C/C++ :: Tic Tac Toe Game - Creating A Menu/choice

Nov 11, 2014

Im trying to create something like a menu in a tic tac toe game. I want the computer to ask the user "who starts first" is it the X or the O who starts first? Then the user should type in either X or O but if he types something else i want to ask again .

this is what ive done :

int main () {
printf("
");printf("
");
printf(" %c | %c | %c
", board[1], board[2], board[3]);

[Code] .....

View 10 Replies View Related

C++ :: Program Menu Choice Skips Over Input

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

C++ :: How To Randomize Answer Order With Push Back

May 8, 2014

How to now randomize the answer order within this code ? I only included the relevant piece of code of the task in question.

questions.push_back(
"Question [1]"
" "
"What port does HTTPS use ? "
"1. 25 "
"2. 443 "
"3. 23 ");

answers.push_back("2");

View 3 Replies View Related

C/C++ :: Instead Of String - Accept Answer With Space In Between Words

Jun 13, 2014

string answer;
cout<<"5.Newton's which law states that F=ma?";
cin>>answer;
if (answer == "newton's second law")

[Code].....

View 6 Replies View Related

C++ :: Expression Creator That Prints The Work Out Too With Answer

Nov 24, 2014

I am trying to create an expression creator that prints the work out too, not just the answer.

Code:

#include <iostream>
#include <windows.h>
using namespace std;
void p1();
void p2();
void p3();
double P,P2,p,ans,ans2,ans1,restart;

[Code] .....

View 4 Replies View Related

Visual C++ :: Finding Temperature At The End Of Interval But Can't Seem To Get Answer?

Oct 30, 2013

I've been trying to get the numbers for hours now but i can seem to get it right. Here's the problem below:

During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.

Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )

These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.

the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES

Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval

i have a:

...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50

I can't seem to find the temp at the ending interval? What i tried doing:

Code:
#include<iostream>
#include<cmath>
using namespace std;
int main () {
double intervals=0.00;
double tempPerMin=0.00;

[Code] ....

The temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it.

View 3 Replies View Related

C/C++ :: 5x5 Multiplication Table Starting With The Number Of User Choice?

Feb 23, 2014

#include <stdio.h>
#include <stdlib.h>
int n;
int m;
char input[20];
int num;
int main() {
int num0;

[code]....

I'm supposed to write C program that will generate a 5 X 5 multiplication table starting with the number of the users choice. The program is supposed to operate within a loop and run until the user indicates that they no longer wish to enter any more numbers. I can get the program to run but am wondering what I need to do to get the program to ask for another number and how to make the program stop when the user no longer wants to play. Should I start with "Do you want to enter a number" if yes, run back through loop if no, goodbye?

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved