I am having problems printing "->" on the beginning of each line, im trying to do it as a loop and ending it when the user types "q". also i would like to know how to ignore text from the user when the input begings with a specific character. heres what ive done so far, and not currrently working as expected.
Code: #include <stdio.h> int main (void) { char prompt; printf("~~~ FRACTION CALCULATOR ~~~
i need to prompt the user of my program to input numbers into an array so that later on these numbers can be added or subtracted with other numbers to form a new array. My problem is I don't know how to make the user input numbers which will then be saved into the array for later use. Here is the parts of my code that relate to the problem:
Code:
float Xv, Yv, Zv, Xu, Yu, Zu ; float vector1[VECTOR_LENGTH] = {Xv, Yv, Zv} ; scanf("%1f %1f %1f", &Xv, &Yv, &Zv); printf("The first element in the array vector1 is: %3f ", vector1[0]);
The point of that printf function is to see if what they have entered is actually registering as what i want it to. This does not work however and the value for this always comes up as 0.
how to scan numbers into an array so that they can be used for later use?
//Introductory20.cpp - displays the contents of a two-dimensional array, column by column and row by row
#include <iostream> using namespace std; int main() { int nums[2][4] = {{17, 24, 86, 35}, {23, 36, 10, 12}};
[Code] .....
I need modifying a program that should display the contents of the two- dimensional array, column by column and also row by row. I need to complete the program using a WHILE statement in the outer loops and a FOR statement in the nested loops.
display the 3rd element of a two dimensional array of integers named T of size 2x5?? i don't know how to start because i'm just advance studying with array
How will you code a program that displays the maximum value in a two dimensional array of integers. the program will ask the user to input the 4x5 array?
i know how to code it. but i dont know what to do to find the maximum value. :( how to find the maximum?
1.Create one 2-dimensional array. The array will consist of numbers from 1 to 10. And will also contain the number in words. Display the values of the 2-dimensional array.
Sample output: 1 - One 2 - Two 3 - Three
Paste the program code here:
2.Create a program that will accept two integer numbers. These integer numbers will be the limit of the multiplication table. Store the values in a two dimensional array.
Sample output: Enter x: 3 Enter y: 2 123 246
Paste the program code here:
3. Determine the output produced by the following program segment.
int ROWS = 3; int COLS = 4; int [ ] [ ] val = {{8,16,9, 52},{3,15,27,6},{14,25,2,10}}; for (int i=0; i < ROWS; i++) { for (int j= 0; j<COLS; j++) System.out.print (val [i][j] + " " ); System.out.println (); }
How can I send information and receive from external command prompt from my program??. I want to run an external command prompt, a code that's is not mine, to send information to this command prompt, then make my program hit enter at the command prompt and then receive back information from the command prompt.
I'm trying to change some information from binary file but I get segmentation fault. Suppose there are two teams which names are same. The names are wanted to change. But, I get segmentation fault.
team_name, city , stadium ,fdate, colors the team is in binary file manunited,manchester,old_trafford,1878,black-rd chelsea,london,stamford_bridge,1905,blue-whte manunited,manchester,old_trafford,1878,black-rd
I have a two dimensional array , who's parameters are decided by the user . Hence i cannot initialize it . Now i want to take input for the first the row and then check some condition and then move on and take input for the next row.
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.
In pseudocode and in C code, declare two 1-dimensional parallel arrays of Integers to store the age and weight of a group of people that will hold the information of up to 10 people. Use a For loop to iterate through the array and input the values. This is the code i have, but my array is showing up as 11 and not 10?
I am trying to make the code below display the result with decimals. I tried using setprecision, but I am not too sure where to put it. I placed it in cout section where the answer is but it still doesn't come out correctly.
#include <iostream> using namespace std; //*Delcare function prototype* int ConvertToCentimeters (double, double ); //declare exception class* class NegativeNumber
If the user puts in a 6. I need the array to display the even number from 0 - 6. Right now what it does is it displays the first six even numbers. Okay as I'm writing this I'm starting to see where my problem might be..
Code: void sumIntegers () { int arr[50]; int i = 0; int num = 0; int sum = 0;
c++.....in my program i have 3 string-s (string houses,string ink,string buildings)and i must add function substr()... In the program i need to add a function that receives a parameter of type string. The task function is that the resulting string is inserted characters '=' to split a string of characters into subsets 5 letters long. If you come to the end and no more letters after the equal sign is not added. The function should not display anything but the resulting string is returned as a result. Example:
A function recive: "housesinkbuildings" .The function returns: "house=sinkb=uildi=ngs" in The main program Add call of this function so that it is specified as a parameter string consists houses,ik, buildings.
I'm coding a hangman game. I'm trying to store user entries so i can output them to show the user what they have already entered. Problem is that it's not display anything at all.
I'm trying to store multiple characters of course, and then display all characters stored.
Here is a simple drinks machine programm. It basically consists in the user selecting a drink that it's presented, if the user selects correctly the number representing a certain drink, the machine shows the user what was the drink he selected, after his choise the machine asks for money insertion, if the user inserts the incorrect amount of money, the machine shows an error saying that user need to insert the correct amount of money.
My problem is that, if the user selects a different number other than those presentend, the machine displays an error saying that he needs to choose a valid drink, but i can't find a way to reprompt the user again after the error has been displayed. here's the code.
// ***Drinkins Machine*** by Roxmate #include <iostream> #include <cstdlib> using namespace std; int main() { // initializes the variables coca, fanta, iced and drink to be used in switch function,so that the user can choose what drink he wants. int coca = 1;
How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors. I know the command for the one dimensional vector as:
I am trying to write a program to get user's input but only accepts alphabetic characters, nothing else and I want it to ask the user to enter a valid word until they have finally entered a valid one. I have the following code for it but it does not work properly.
void CheckBound (char word1[], int SIZE1) { int i; int w1[SIZE4]= {0}; int found; for (i=0;i<strlen(word1);i++) {
#include <iostream> #include <limits> int getInt() { int x = 0; while(!(cin >> x))
[Code] ....
But this function prompts the user to only input integer values. I was thinking if I could maybe try tweaking with this one so that the user could only enter letters..no luck though. So how can I have the user input letters only?
I am having a problem printing out the results for my code, It is supposed to print out the largest and smallest value in the array, but keeps giving me a value not entered and I don't know why.
//This program lets the user enter 10 numbers and then display the highest and lowest number.
#include <iostream> #include<stdio.h> using namespace std; int main() { const int NUM_ENTERED = 9; int number[NUM_ENTERED], highestValue = number[0], lowestValue = number[0], count=0;