C/C++ :: Beginning Structures Take Values By User?
Dec 14, 2014
I'm trying to learn structure type in C. In this trying, the code must take 9 value from user but it takes 6 values then returned. I scrutinized but I can't find my error.
How do I write a ROM BIOS routine which accepts a row number from the user and place the cursor to the beginning of the row number which the user gave?
I am currently having problems creating a loop that will allow my user to choose to return to the beginning of the program or quit.
#include <iostream> using namespace std; int main() { int j; do {float a; cout << "+----Welcome to Basic Operations----+ | Select Your Operation |
[Code] .....
I have not yet finished designing the interface for a couple of the operations, but right now i am hung up on trying to return to the beginning. I believe it is because the j was defined inside do and isn't carried out of the do statement for while.
Write a program that accepts three values (int) from the keyboard into three variables a, b and c. After loading the variables, your program will arrange the values into a, b, and c, so that a contains the larger, be the next and c the smallest.
You can use any other variables in addition to a, b c, as you see fit.
You will have to use some variation(s) of the if construct.
There are many ways to program this, but your challenge will be to achieve this without doing all possible comparisons. In fact, three comparisons woudl be enough, if you , for example, determine the largest number first, and keep track of its position in some way , so you can compare the other two.
I think I might use a code similar to the one below.
switch (expression) { case constant1: group of statements 1; break; case constant2:
I am having trouble returning use input from iterations after the first series of input from the user. My readCourseArray function can only have one parameter and it is information from the structure Student. This information is gathered from a function which is not in the code below because it works fine. I have hard coded a few lines to try to figure out why I am not getting any input after the first pass of the readCourseArray function. I have tried to delete the tempArray in the function after each pass assuming that that could be the issue. But it was not. At least from what I have gathered. I have tried ignoring new line characters which I never really though was an issue but I tried anyways.
I guess what I am asking is: Is my problem coming from the function itself or from my assignment of the cArray to the return tempArray values?
Like I said, the first pass will print out all of the user input (if I put the code in) but all others will return bad values. I did have a do/while to print out the values but it caused the program to crash. I assume because it hit a bad value and needed to break.
#include <iostream> #include <string> using namespace std; struct Student { string firstName, lastName, aNumber; int numberCourses; double GPA;
I have to create a program that incorporates an array of structures in order to simply read input from the user and then reprint that information to the screen. This is a fairly simple problem, but the issue is that the professor requires that we solve it in a very specific way.
I must have three functions in total: one to receive input from the user, one to print the received values, and of course the main function which calls the other two. Also, the input and output functions must be defined using the following prototypes:
typedef struct// Component { float cost; int code; char name[30];
[Code] ....
I know that this problem could be easily solved by simply passing the entire 'comp' array to the inputData function, or passing a pointer to it, or having it return a pointer, but I am not allowed to do any of these things. I must use the function as defined by the prototype.
Goal: Write a program that compares the values stored in the first array to the user inputted values in the second array.
In order to fix this error: [URL]...
I had to change my array initialization to one with a star in front of it:
char a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"}; to: char *a1[]={"a","d","b","b","c","b","a","b","c","d","a","c","d","b","d","c","c","a","d","b"};
I also changed my 2nd array to one with a star in front of it: char *a2[20];
What does this mean exactly? Putting a star in front of an array?
Also, I am now getting an "unhandled exception" when I try to get input for my 2nd array:
My question is how strtok will work in the beginning?
According to this to determine the beginning and the end of a token, the function first scans from the starting location for the first character not contained in delimiters (which becomes the beginning of the token). And then scans starting from this beginning of the token for the first character contained in delimiters, which becomes the end of the token. The scan also stops if the terminating null character is found.
This end of the token is automatically replaced by a null-character, and the beginning of the token is returned by the function. strtok will replace the first * with '' and the next call will start from the second * puts '' there and again the same with the third * ?
I have a small project for school due today but i cant get my head around programming
Ive to create a program where ive to get the values from the user and add them to an equation. I have also to add a selection statement where it will ask for the material being tested which will have its value set in the program.
I am writing another program and I cannot find for the life of me how to loop the program back to the start of a function.
Code: #include <stdio.h> #include <stdlib.h> int main(void) { int choice; char band1, band2, band3, band4; printf ("This program calculates the resistor value based on the colours of the wire. (enter the integer near the command) "); printf ("What would you like to do?
[Code].....
This is my current iteration of the program. Obviously, I haven't finished writing the case 1 of the first switch, but for the other ones. I thought that return main would cause the program to loop back to the beginning after executing the case, but I see that it is not the case (pun not intended). Anyways, what would I have to insert to cause the program to loop again (other than for case 3)? And another question, why is it that in scanf in the first case, the program only accepts two characters before finishing?
I've been struggling with linked list for a few days. I've tried performing a few operations. Here is my code. the add_begin() function doesn't seem to work.
#include<iostream> using namespace std; struct node { int data; node *next;
I'm writing a program that converts hex to letters and writes the letters to a file.To write I'm currently using ofstream("output.txt" ios::app)But the issue with this is, is that everytime I run the program, it appends and doesn't write from the beginning of the text file.So what I want to know is, how do I clear the contents of a text file, before writing to it?
You are to write a program that will allow a user to enter infinite numbers (greater than zero)(One number at a time). You must have a way for the user to stop entering values.Once the user stops, you will immediately display the following:
The lowest number entered is: The highest number entered is: The number of values entered is: The average of the numbers entered is: */
main() { int userNumber=0, sum=0, count=0, highNum=0, lowNum=0, lastNum = 0; double average; printf("Enter a number greater than 0: (Enter -1 to stop) "); scanf_s("%i", &userNumber);
[Code]....
My program outputs everything I need except the lowest number entered. I have been spending a considerable amount of time on this problem to no avail.
I'm trying to insert into the database I created, values entered by the user. But I can't find how to insert them it looks like this:
//Go for the user infos cout << "What is your ID ? : "; cin >> id; cout << "What is you letter ? : "; cin >> letter; cout << "Your letter is "<<letter<< " and your ID is "<<id<<"
[Code] ....
I don't know how to proceed, I receive a error here for the sql2 statement
error C2296: '<<' : illegal, left operand has type 'const char [36]'
What do I put to have UserNumber == 1-10? In other words I want it to say...
if UserNumber equals 1 through 10 <<<<This is where I'm having the issue.
Do this Else Do this
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Start: Console.WriteLine("Please enter a number between 1 and 10"); int UserNumber = int.Parse(Console.ReadLine());
How do you add a value to the beginning of a string instead of the end?
This is for an assignment and I have to convert the user input (always assuming its a valid decimal number) to binary and store it in a string. I've got up to dividing by two to get the remainder ...
I'm just starting c++, doing tutorials. So many tutorials. I've noticed that the tutorials all assume the same thing: That the user will always do exactly as he/she is told when asked for input.
Example: "Please enter your age:"
Now, the example code might be expecting the user to type some numbers, but what if the user feels like typing out the letters of their age?
"I am ninety five thank you very much, sonny"
I could specify to the user that I only want the information in number form, but what if the user is just being a dick?
What if the user types, "none o' yer business."?
So... how to approach "fool-proofing" player input?
Keep track of the sum of values entered (as well as the smallest and the largest) and the number of values entered. When the loop ends, print the smallest, the largest, the number of values,and the sum of values. Note that to keep the sum, you have to decide on a unit to use for that sum; use cm.
I am trying to set the width of the data values which the user will input when using the program but I don't know how to get it to show the values when I tryto set the width of the variables in a nice column .
My program had a requirement to ignore an input beginning with a # sign. The input is entered by user from keyboard. I wanted to know how to use cin.ignore to achieve this.
So I'm making my first program w/ C++ and its a game guessing game. I've learned how to use booleans, chars, strings, if/else, loops, and input. Anything past that I dont know. I've gotten my game to work properly except for the fact that when you guess incorrectly, the program closes. I want the program to go to the beginning of the program again so the user can restart. So far i've gotten the loop to beginning thing to work but not well. It'll only repeat twice before closing again and it'll say the user got the wrong answer even if it was correct. Here's my code
#include <iostream> #include <string> #include <random> #include<ctime> using namespace std;
I am having some trouble creating a listbox in visual studio. I declared an array, set initial values, and now I would like to be able to update those values. It is a pizza inventory app, so I need to update the initial values once the user has added inventory. This is the code I have for the "Update Inventory" button:
// read in value and convert to double double dblInput = Convert.ToDouble(txtInput.Text); // loop through ingredients and add inventory to selected ingredient for (int i = 0; i < dblInventory.Length; i++) { // is item at i checked for update? if(lstInventory.GetItemCheckState(i) == CheckState.Checked)