C++ :: Program To Create Integers As User Requests?
Nov 19, 2013
I know it would be easier to create an int array, but I want the program to create integers as the user requests. For example, if the user enters 4, the program creates 4 integers with the names input. Each integer is better as an individual integer, not an element in an array.I'm not sure if this is a possibility with C++.
1. Write a c++ program to create a vector of integers. copy the vector contents into list, sort the contents, then copy selected items into another vector(like elements less than 10 etc)
This is the problem :- Write a program that keeps reading integers until user enters -1, then it prints the maximum and the minimum among all numbers (-1 should be ignored).
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 ?
Write a C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.
This is a sample output. Notice how the program prints a counter (1, 2, 3, ) for user keep track of how many numbers were entered so far. Include this feature in your program.
I have tried different ways to get the result from while loops, do while, and if-else statements. We have not done any max/min problem in class and the book was kind of vague. We have not learned arrays yet in class and I can't figure a way to compare the integers the user inputs as it is an infinite(from what I am reading) amount aloud. The problem I am seeing is the loop works and stops with the sentinel value but the INT_MIN is using the sentinel value. I also have not addressed the input of negative numbers yet with the first program I wrote, maybe one of my problems.
Code: /*File:HW2Q3.c, A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/ /*header files*/ #include<stdio.h> #include<limits.h> /*****start program*****/ int main() {
[Code] ....
I have also tried this way as well, min value still comes back as -1 the sentinel value, and the else statement is being ignored. I am sure it is something silly but I am lost and confused at this point.
Code: /*File:HW2Q3.c, A C program that takes multiple integers from the user and finds the minimum value. The numbers entered by the user are positive integers. When the user is done entering all the numbers, the user enters the sentinel value of -1.*/ /*header files*/ #include<stdio.h> #include<limits.h>
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);
I have a struct called Array and I'm to create a function to create a dynamic array that's fill with randomly generated integers from 0 to 50 (inclusive) and a function to destroy the array for freeing its memory. Below the code that I have written so far.
Code:
* Struct */ typedef struct {int *pArray; //the dynamic array int length; //the size of the dynamic array}Array; /* Function to create a dynamic array */ Array *initializeArray (int length) {int i; }
i want to create a program that allows a user to list all create new items, list those items, delete an item, modify an item, search for an item how can i do that This is my work so far
I want to create a grading program that the user inputs a name and then on that value (name) there is a vector of doubles to represent his/her mark and then calculates an average how would I go about doing this?
I need to create a program that will prompt the user for an input, then it will save their input to a file and then it will prompt the user to input "Open" and then the file containing their first input, will open up and show their input.
I'm trying to create a program that prints a number of dots specified by the user, there 4 options to do any loop type or to exit the menu. i'm having problems making it so that after you enter a value and it displays the specified number of dots it clears the results. Also we have to make it so that if a negative integer is entered it still prints out the appropriate amount of dots ie: user puts -9 it prints 9 dots, i know you use the abs() function but it doesn't seem to be working for me. I'm assuming my problem with the abs function is i'm not using it correctly. Use case 1 as the example for the rest because I'm trying to implement everything on one case at a time
Code:
int main() { //initialization statements int Num1 = 0; char dot = '.';
Create a program that will let the user input an amount in the form (367). The Program should determine the no. of coins for each dominations : 50,25,10,5,1. (using Turbo C)
Im trying to create a program that has the user input a 5 digit number. If it's between 10000 & 99999, it will do one thing..(just saying 'yes' for now. Outside those numbers will prompt the user to input again. However, if the user inputs the exact digits 76087, it should display 'term'.
This current code is displaying 'term' whenever the user inputs the 5 digits.
Code:
#include <iostream> using namespace std; int main() { int pin; cout << "Welcome to Movie Food Enter your 5-digit pin code: " ;
I have an assignment in which i must create a program which prompts for user input of current and birth date, which will compare said dates and output if its your birthday or not. I've completed a large portion of it, but cannot figure out how to get the user input of month as an integer such a 2 into February.
#include <iostream> using namespace std; class DayOfYear { public: void input();
I need to create a program that prints a certain number of asterisks based on user input. The user inputs 5 and I want my program to output "*****". How would I do this in C? I've tried printf("%#**", myvariable) but this does not work it only prints "*".
C programming: I want to creat a program that asks the user to input the integer lengths of three sides of a triangle, and if so whether the triangle is a right-angled, acute or obtuse one. i am having some doubts about the if, else if statements. I never seem to know how and in what order to use them.
Code:
#include <stdio.h> #include <stdlib.h> #include <math.h> int main(int argc, char *argv[]){ int SideA; int SideB; int SideC; }
I'm using Visual C++ 2010 Express on Windows 8. What I want to do at the moment, is to create a class to make WinHttp requests easier. This is the code that I'm basically using to build the class: [URL] ....
This is what I got so far. (Completely untested). Example of how I hope that it will work:
Write a program that reads four integers from a file ‘input.txt’.
The program will then create a single integer number from the four integers. The output of the program will be the single number and single number + 600.
#include <iostream> using namespace std; int main () { int number , a; cout<<"enter en integer number"; cin>>number; cout<<"add 600 to the number" cin>>a=number+600; return 0; }
#include <iostream> #include <fstream> #include <cstdlib> #include <ctime> using namespace std; int main () { ofstream fout("datain.txt",ios::out); int array[6][6];
-Write a program using while loops that prompts the user for a set of integers.
-Your program will ask for one integer at a time. If the number 0 is entered, the list is complete and your program will output two results: the sum of the even integers and the sum of the odd integers.
-After each integer is entered by the user, your program will print out whether the integer entered by the user is less than, equal to, or greater than the previous integer. Assume for the first integer entered by the user that the “previous integer” was 0.
-Your program must handle a variable number of inputs (in other words, you cannot hard code for the test cases).
This is what I have so far:
#include <iostream> using namespace std; int main() { int a; int b;
I got everything in this code running except for my remove function. What the project does is adds or removes an integer to a chain of integers created by the user. My add function works the first time but after that if I try to remove or add I believe it is pointing to the improper location and I don't know how to fix this....
Here is my code:
Header: // adds "number" to the array pointed to by "arrayPtr" of "size". // Note the size of the array is thus increased. void addNumber(int *& arrayPtr, int number, int &size); // removes a "number" from the "arrayPtr" of "size". // if "number" is not there -- no action