i'm trying to write a calculator. the user will enter the terms and they will be stored in arrays. i will be storing those terms in string arrays and then later turn them to double to work with them. but the user should be able to enter terms like sin(252) and the program should be able to recognize it and calculate it.
So I have an issue with a homework assignment that I am coding. I am attempting to get a function to iterate through an array and search for a number that was stored in an array by the user. So far I can take the number, get the numbers displayed but in my menuChoice2 function, for some reason the program is not confirming whether or not the number is entered, and is only telling me that the number has not been found, instead of confirming that the number is in the array.
Here is my code thusfar:
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> // Variables that are Globally declared int menuChoice = 0; int usernum[1000] = { ' ' };
[Code] .....
To be clear I am not getting any errors but something is telling me that the error is in the formatting of menuChoice2.
I'm doing an exercise which involves for the user to enter the size of the dynamic array and then enter the numbers, but then it needs to create another dynamic array with the same numbers expect if the number repeats it only has one of it. I've done the first part of the exercise but I'm having trouble with creating the new array.
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:
Write a program that asks the user to type 10 integers of an array. The program will then display either "the array is growing", "the array is decreasing", "the array is constant", or "the array is growing and decreasing."
(Hint: compare consecutive numbers in array and check whether it is increasing or not or constant) I wrote the program very well, but do I have to use "bool" like in c++ ? I haven't known how to code in c++ yet.So, I don't want to use "bool" in C.
I also wrote code about it but it looks like backslash and one,two,three,four,five how can I do it like this ?
The problem deals with writing a program to geta series of integers from a user and storing those values into an array. Then use a function called selection_sort, when given an array with n elements, the function must sort the array from smallest to largest values.
I have code, and im trying to get it to compile but im getting these implicit declaration errors and conflicting types. Here is my code and the compiler errors.
Code: Compilation started at Sun Feb 10 20:14:48
gcc -Wall -o ex9-1 ex9-1.c ex9-1.c: In function 'main': ex9-1.c:16:5: warning: implicit declaration of function 'selection_sort' [-Wimplicit-function-declaration] ex9-1.c:20:2: warning: implicit declaration of function 'prinf' [-Wimplicit-function-declaration] ex9-1.c: At top level:
[Code] ...
Compilation exited abnormally with code 1 at Sun Feb 10 20:14:49
Code: #include <stdio.h> int main(void) { int a[100], i, j, N; printf("How many numbers will you be entering: "); scanf("%d", &N);
Making a game of checkers on C++ win32, visual studio
when i want a piece to move, i type:
cout << "What piece do you want to move? (C4)" << endl;
i type in 'cin' after to get the players input, but how do i get it to store the players input in a certain variable? im going to have a list of variables:
string a1 string a2 string a3
etc
so if the user types in a2, it automatically goes to that variable and then asks the user "where do you want the piece to be moved to?".
I am making a multiple quiz program. So everything is working fine, except for the part where i'm trying to add a highscore for each user which is being stored in a binary file. I have added a sample of the program containing the error. This isn't the actual program, which is very long.
class user { //The collection of all info pertaining to the users char user_id[50]; public: int hscore1; user() { strcpy(user_id,"NULL"); hscore=0;
I am trying to make a program that will allow a user to enter their name, from this point, three options should be present for the user to choose, then from that point, two more options should be present. I have if else statements in a switch case and I get the "undeclared" error for the a in the first " if(specificage == a) ".
I am trying to write up something to have a user to enter a four digit number. Only four digits, Ex: 0001, 0116, or 9999. There is no getting around the selection 0001 or 0002. I understand if not done correctly, the first three 0's will be ignored.
I've been just playing around with what I have below but I just don't remember how to do it nor can I find a good example online to figure it out. I know it is not correct just typing to try to remember. I am aware that it is gibberish right now, this is just me brainstorming.
int number; cout<<("Please enter the four digit number(Ex: 0001): "); cin>> setw(2) >> number; cout<<)"Please enter four digit date. Two digits for month and two digits for year: "); cin>> date; if (number< || number > 30) cout << "Invalid choice. Try again." << endl; cin.clear();
I'm trying to validate my input. I require for the user to enter six doubles and if they don't then I want them to re-enter the information. Here is my code:
Code: while (1>0) { printf("Please enter arguments in the order: negative mass, positive mass, initial x-position, initial y-position, initial x-velocity, initial y-velocity: ");
if ( scanf("%lf %lf %lf %lf %lf %lf",&MassMinus,&MassPlus,&Pos[0][0],&Pos[0][1],&Vel[0][0],&Vel[0][1]) != 6) { printf("Not all numbers were assigned!
[Code] .....
At the moment it just waits if you enter less than six numbers and if you enter any more than 6 it just ignores anything after the sixth number (so pretty much does nothing). Also if I entered 1 2 a b 3 4 instead of entering six numbers it would register that as 1 2 0 0 3 4 but I want it to make the user input the numbers again. I'm also aware that "while (1>0)" isn't good programming form but I'm not really sure what to use instead?
I am simply trying to prompt a user to enter M for Male or F for Female. However, when I test run the program (what I've got so far below), any letter inputted is accepted and continues the program..?
#include <iostream> using namespace std; int main() { char gender; int maleBodyWeight;
B. Circle in a Square Write a C++ program that will ask the user to enter the area of a square. Then the program will display the biggest area of a circle that will fit in a given square. Using math.h library is not allowed.
When the user gives no input, they have to press enter twice before "Done." is printed.
cout << "What do you want the name of your page to be? "; std::getline(cin, pageTitle); if (cin.get() == ' ') pageTitle = "Welcome to Website."; cout << "Done. ";
Is there a way to print "Done." after pressing enter once?
Write a C++ program that asks the user to enter an even number only. If the user enters an odd number the program should use input validation to ask the user to enter another number.
- The user can enter as many numbers as he wants
- The program should also keep a count of how many numbers entered and display how many odd and even numbers entered.
Having problem with my code. i keep getting an error towards the bottom of the code. i need the user to enter a word. and with that word convert it to numbers. once i have convert it if it is bigger than 20 i have to add the two digits together and get print out the array that response to it.
example" ALEX A=1 L=12 E=5 X=23
1+12+5+23= 41 //since its bigger than 20 you add 4 and 1 together so it will be 5. after that you print the 5th element of array
#include <iomanip> #include <iostream> #include <string> using namespace std; int main() { string name;
My program was to allow the user to enter a value as a C string in the form: xxx,xxx,xxx,xxx,xxx.xx, where x can be any digit. Well, so far here is my attempt. I think the question is, would I have to implement a switch statement for the digits, the comma, and the decimal, so that when a user inputs, let say 52,000.00 the switch statements would read the 1st digit, checks for decimals/commas and if not, proceed to read 2nd digit, and repeat?
Code: #include <iostream> #include <string> int main() { using namespace std; char buffer[256]; char tempBuff[256] = {'
Enter as many numbers as you want as long as the user doesn't type 'e' to exit.
Problem: When I enter a number, it works fine, but if I enter e then it'll go in an infinite loop since the letter is being stored in an int variable. How can I (when I press 'e') make it convert to a char to make it end the program?
#include <iostream> using namespace std; int main() { int num; cout << "Enter a number or press e to exit:";
[Code] ....
Our class has just started c++ and we have not learned arrays and classes yet, so I'm guessing there is a way to do this without it? Or no?
how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...
a program that allows the user to enter a statement and outputs statistics; number of vowels, number of constants, percentage of vowels and constants, number of words, number of punctuation characters
Create a program that will ask the user to enter a decimal value (1-999999) then display its corresponding binary numbers. Repeat this process until the value entered is equal to 0. Use the following Function Prototype:
void BinCodes(int value); Sample Input/Output: Enter a Decimal: 35 Binary: 100011 Enter a Decimal: 184 Binary: 10111000 Enter a Decimal: 0