C :: User Input 6 - Array To Display Even Number From 0 - 6
Apr 5, 2013
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;
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;
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.
i was trying to solve a problem in SPOJ and what i wanted to do is to accept an input number from the user and to convert it into a array of integer.
Code:
#include<stdio.h> int * toarray(int *num); int main(void) { int testCases; }
[code]....
But whenever i try to print the array in the main function i get only two value and the rest address
Code:
1//number of testCases 23456 //input number 6 2293452 4 2293700 1974439125
Process returned 0 (0x0) execution time : 4.152 s Press any key to continue. However, if i tried to print the array from within the function, it prints the numbers just fine.
print the array elements from the main program, so that i would be able to go on with the rest of it
I need to create A program That makes a 12x10 Array Grid Filled With Random Numbers From 0-99.
Then I need To Allow The User To Input A Number Between 0-99 And Then The program will then search through the array and count how many of the users number there is inside the array.
Code:
#include <iostream> using namespace std; int main() { int input; int number; int row=0; int col=0; int Array [12][10];
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'm trying to code a program to read the user's input and have it:
-count vowels -stop counting vowels after '.' or '?' (ie. abcdjwef is 1 a, 1 e; while fje.fwdfeiii is just 1 e) -closes when ENTER is pressed after a '.' or '?' is found (ie. closes after 'abacds. ENTER' as well as 'as.fefsdf ENTER') -display the number of vowels
Is there any way to do this with only 'cin >> userInput' and a while loop checking for punctuation?
I have been stuck at a dead end,I got it to display a single asterik for an inputted number, but how would i go about in adding that asterik for each number?
my code is the following
int userinput = int.Parse(InputOutput.GetInput("Enter values into array")); Int32[] inputChoices = new Int32[9]; for (int x = 0; x < inputChoices.Length; x++) { inputChoices[x] = 0; } if (userinput == 1)
i want to display all the contents of a file excluding one based on user input say i have 4 records in the file numbered 1 to 4....the user chooses 2 to exclude it outputs records 1,3,4,4 when it should be records 1,3,4 what am i doing wrong here is the code.its basically displaying the last record in the file twice
I'm suppose to write a program using (for loop) that asks the user to enter any amount of numbers, so that it can display the smallest and largest. My program successfully finds the largest, but it is always displaying 0 for the smallest, I think Im doing something wrong with the internalization but I dont know what to change it to.
This is what I have ....
#include <iostream> using namespace std; int main() { int amount; int count; int number = 0; int smallest = 0; int largest = 0; cout << "Enter total numbers to process: ";
What I'm trying to do is have the user input a hex number this number will then be converted to a char and displayed to the monitor this will continue until an EOF is encountered.I have the opposite of this code done which converts a char to a hex number. The problem I'm running into is how do i get a hex number from the user I used getchar() for the char2hex program. Is there any similar function for hex numbers?
this is the code for the char2hex program
#include <stdio.h> int main(void) { char myChar; int counter = 0; while(EOF != (myChar = getchar())) { if (myChar == '')
[Code] .....
This is what i want to the program to do except it would do this continuously
#include<stdio.h> int main() { char myChar; printf("Enter any hex number: "); scanf("%x",&myChar); printf("Equivalent Char is: %c",myChar); system("pause"); return 0; }
There's this program I'm trying to code where the user gives input of 2 values.
Sample :-
Value of X: 1234 Value of Y: 234567 Reversed value X: 4321 Reversed value of Y: 765432 New value as Z: 1223344567 (each number was taken in both X and Y)
Now the thing is I could do the reverse, and I've been trying to find out how.
Here's my code,
#include <iostream> using namespace std; int main(){ int x=0, y=0; int reverse_x=0; int reverse_y=0; int z = 0; int l;
[Code]....
What I thought about that area where I've put a comment on, I was wondering if I code a loop for the amount of times x gets divided by 10 until it becomes 0 and store it in the value, same thing for Y, and add the value together to get Z. But if that's how it is then how I could use that concept here.
There's this program I'm trying to code where the user gives input of 2 values.
Sample :- Value of X: 1234 Value of Y: 234567 Reversed value X: 4321 Reversed value of Y: 765432 New value as Z: 1223344567 (each number was taken in both X and Y) Now the thing is I could do the reverse, and I've been trying to find out how.
Here's my code,
#include <iostream> using namespace std; int main(){ int x=0, y=0; int reverse_x=0; int reverse_y=0; int z = 0; int l;
[Code]...
What I thought about that area where I've put a comment on, I was wondering if I code a loop for the amount of times x gets divided by 10 until it becomes 0 and store it in the value, same thing for Y, and add the value together to get Z. But if that's how it is I can't seem to really get that idea how I could use that concept here. I'm not really good with programming, fairly new at this.
I am making program that allows the user to determine how big the array size will be and then asks the user to make up numbers to fill the array. Every time run the program on Dev C++ it says "program has stopped working"
Heres My Code:
//Assignment 19 Program 2 #include <iostream> using namespace std; int main()
I'm working my way through some C exercises to get some practice and have hit a wall. I need to use a function to take a number, such as 1, and print out One.Here's what I've got so far:
Code: #include <stdio.h> int name(int n); char numberOne[] = "One"; int main(void) { int n; }
[code]...
However, when I run the code and enter "1" the only thing that gets printed to the screen is "(lldb)". I've tried changing it to doing it without variables and just printing "One" but that gave the exact same result.
I'm having a bit issue with ispunct in my function. The user can input a phone number in any of the formats below:
4147778888 (414)7778888 (414)777-8888
The program will only print out:
41447778888
What I am trying to do is accept any integer and parentheses. If the user inputs anything else, the program will display an error message. Right now, parentheses displays an error which is obvious but I'm wondering if there is a way I can allow a parentheses to be entered but not any other symbol. ex: . , : ; " '
Code: void getPhoneNum(){ // Local Declarations char string[14]; char* tokPtr;
User will input a number in the range of 2 and 2^63-1 and the program will decide whether it's prime or not by a simple 'YES' or 'NO'.
I figured out a code:
#include <stdio.h> #include <string.h> main() { unsigned long long n,i=3; int temp=0; int t; scanf("%d",&t); //Number of test cases
[Code] ....
Now this code works for normal inputs but whenever I try it with large primes in tat range, like 987654321987654329 or 9223372036854775783 it does not work />.
I tried to print the values of i to check the limit to which it runs.. and I found it 23697, whose square is 561547809 - nowhere near about the input primes.
The basic idea of this exercise is to generate words from a user-input, seven-digit number(a phone number). The code runs, but for some reason, I can't get it to print the numbers into the file.
Code: /*Write a program that will generate a word based on a randomly generated, seven-digit number. there should be 2187 possible words. Avoid "phone numbers" that begin with 0 or 1*/
#include<stdio.h> #define PHONE 7 void wordGenerator(int number[]); void wordGenerator(int number[]) { //loop counters for each digit in the number
im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output
#include <iostream> #include<iomanip> using namespace std;
Write a C++ program that will input from the user a positive number n and find its factorial. Don’t forget to validate the input. The factorial of a positive integer n (denoted by n!) is defines as the product of the integers from 1 to n.
n! = 1* 2 * 3 * ... * (n - 1) * n
You should allow the user to continue working with your program for additional data sets.
Sample output:
Please enter a number: 5 5! = 120 Would you like to continue (Y/N)?Y Please enter a number: 3 3! = 6
Would you like to continue (Y/N)?N Good Bye!!
My code for what i think I'm doing is as follows:
#include <iostream> using namespace std; int main(){ int i=1; int n;
The problem that I am having is that , the program outputs numbers that are perfect numbers and im not sure where i can add a statement to make it so that if it isn't a perfect number it doesn't output...
#include<iostream>// allows user input/output #include<conio.h> #include<fstream>//data file / result file #include<iomanip> #include<cmath> // math function #define in_file "data.txt" #define out_file "result.txt"
find the prime factors of the number input by the user. This time, we are going to have the user input a number, and the program will find all prime numbers from 2 to that number and prime factors of the number input by the user
#include <iostream> #include <cmath> using namespace std;