C++ :: Get Entered Number Become Fragmented And Then Resembled
Nov 22, 2013I have to make a program and how to go with it. What is excepted of me is to have a entered number, become fragmented, and then resembled.
Ex. 1394--> 1 3 9 4 --> 1394
I have to make a program and how to go with it. What is excepted of me is to have a entered number, become fragmented, and then resembled.
Ex. 1394--> 1 3 9 4 --> 1394
I am trying to find the max number entered by the user, and it should terminate when a negative number is entered. For my code, it will just end when the user inputs a lower number than the previous. i.e.- 10 20 15 "The highest number is 20" when it should be "10 20 5 40 15 -1" "The highest number is 40". No arrays or do/while loops either.
#include <iostream>
using namespace std;
int Max(int x);
int main() {
int x;
[Code] ....
Create a program that keeps on reading positive numbers until user enters a zero value, and then outputs the last positive number entered.
I do not know how to output the 'last positive number' and I do not even know am I doing things correctly so far....
Code:
#include <stdio.h>
int main() {
double num;
for(;;) {
printf("Enter a positive number: ");
scanf("%lf",&num);
[Code] ....
How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.
I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
int maxNum=0, minNum=0, value, count=0, sum=0;
double average;
[Code] ....
I'm trying to calculate the number of distinct values entered into an array. If i enter the followings "3,4,5,6,7,7,6,e (anything that's not a number)" . I get a total of 7 but in reality it should be a 5.
Code:
#include <stdio.h>
//---------function to find the distinct values----
int find_distinct(int list[], int size)
{
int i, j,size2, distinct = 0;
for(i = 0; i < size; i++)
[Code]...
I wrote a program with function my own function which count the digits of entered number. The problem is whatever i type it shows 0 digits.Why is that?
Code:
#include <iostream>
using namespace std;
int cikCipari (int skaitlis, int cipars);
int main()
[Code] .....
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */
[Code]...
It says the error is on line 23
A problem that lets the user enter any positive integer, but you do not have to check for this, and then calculates the sum of the digits and displays this to user. For example, if user enters 14503, the outputted sum of the digits would be 13. You need turn in an algorithm, C++ source code and output.
how do i even go about making 1 add to 4? and so on. I'm lost.
when i declare local variable x and use it in array,the error is occure that use of un assign local variable.
namespace ConsoleApplication11
{class Program
{
static void Main(string[] args)
{
int x;
Console.Write("enter how many entries you want");
[Code]...
I am currently taking a C# class. Our current assignment has us entering a player name, and number of hits and displaying these in one set of labels. I have coded everything for the primary function of this program and it works. However, I also have to have a second set of labels that show the highest number of hits entered (if I enter 44, the first and second labels change to 44; if I then enter 27, the first label changes to 27 and the second stays at 44; and if i enter 55, the first label changes to 55 and the second label changes to 55) and the corresponding player name. I have tried searching and reading and I can't seem to figure out how this is done.
View 5 Replies View Relatedim working on our project and this part of the project which says to add a new a room.
Details:
Open the file (ROOMS) that maintains all the ROOMS records.
Ask the user to enter the required data Room_Type and Room_Rate, then save it.
Keep asking the user (Do you want to continue?) until the user enters (N OR n), this should stop the data entry and get the user back to the main menu.
Myproblem :: i keep getting error at the bottom says my while statement is wrong " IntelliSense: no operator "!=" matches these operands"
My other problem:: how do i get back to the main menu?
so what ive done till now is.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
int choice,i=1,Room_rate;
string alphabet;
string Room_type;
[code].....
I have the program working but when I check if the input to make sure it is not a char it creates a infinite loop. I used an if statement to check for the issue and solve it but its not working. I even tried throwing an exception but I learned later they are not used for things like this.
Code:
#include <iostream>
#include <limits>
#include "contacts.h"
using namespace std;
int main()
[Code].....
I am using Dev C++ on a windows computer.
In my code, the user enters the name of a city, and then according to what city it is, the program displays the coordinates of that city
I can't find a way of figuring out and checking which city the user has entered so the code can displays its appropriate latitude and longitude.
So, I am making a name-database-type-thing and I want the user to be able to enter there own file. Like, here:
string fileName;
string name;
cout<<"What is your file name?"<<endl;
getline(cin, fileName);
ifstream nameFile(fileName);
getline(cin, name);
nameFile<<"Name: "<<endl;
Well, that last part is in a loop, so you can enter an unlimited number of names to the .txt file.
So, it won't let me use the string in ifstream. How can I fix this? This maybe unclear, so if it is just say so and I will edit it.
I am making a program that will suggest meal options when choosing specifics contained within, e.g. style, base, main, sauce.
What I would like to know is how to collect the input that has been entered by the user, say you are given 4 lists and each has an option, how could I chain these together in order to cout a suggestion that is in my database?
-------------------------------------------------------------------------------
Example (not my real Q's and A's):
OUTPUT: What meat would you like?
INPUT: "Beef" //<collect this!
OUTPUT: What sauce would you like?
INPUT: "Tomato" //<and this!
OUTPUT: What would you like to have as the main/base?
INPUT: "Pasta" //<and this!
OUTPUT: I can suggest... "Spaghetti Bolognese" //< and return this from the database using the 3 filters
--------------------------------------------------------------------------------
If I entered multiple cin say for variable x, how do I total them all up at the end?
Example: x being the variable.
cin 45
cin 50
cin 22
The total would be 117 but how would I write that in c++?.
/*
* echoString2.c
* Echoes a string entered by user. Converts input to C-style string.
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(void) {
char aString[200];
char *stringPtr = aString;
[Code] ....
and these are my errors
212Untitled1.cpp[Error] stray '222' in program
212Untitled1.cpp[Error] stray '' in program
212Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '' in program
262Untitled1.cpp[Error] stray '222' in program
Untitled1.cppIn function 'int main()':
2125Untitled1.cpp[Error] 'n' was not declared in this scope
I'm making a Project on a Travel Agency and I need to hide the password entered by the user! I am working on Xcode 5.1.1 -> Command Line Tools -> C++ on my MacBook Pro! Here is what I've tried --
string pass ="";
char ch;
cout << "Enter pass";
ch = getchar();
while(ch != 13){//character 13 is enter
[Code]...
But in the first case the display is -
//Assuming the password is Hello Hello ******
And in the second its giving me 3 errors -
1. Apple Mach-O Linker(Id) Error "_stdscr", referenced from:
2. Apple Mach-O Linker(Id) Error "_wgetch", referenced from:
3. Apple Mach-O Linker(Id) Error clang: error: linker command failed with exit code 1 (use -v to see invocation)
Write a program that reads numbers from cin and then sums them, stopping when 0 has been entered. Add the following to your program:
-A counter within the while loop that keeps track of the number of inputs entered.
-A comment that determines if the total value is less than 100 or greater than 100, as in the sample output
-Switch statements to determine the total number of inputs
Sample output:
Enter numbers, one per line. Enter 0 to end:
7
8
6
5
5
9
8
0
The total was 48.
The total number of inputs read is 8.
The total is less than 100.
The code that I've got so far lets me keep track of the inputs entered, and displays the total of the values, but I'm not sure how to do the part where it determines if the value is greater or less than 100.
#include <iostream>
using namespace std;
int main() {
int val, total=0;
int i=0;
cout << "Enter numbers, one per line. Enter 0 to end:
";
[Code] .....
I am new to c++ programming, and I wrote this program. It runs perfectly but the problem is I want the program to stop If I entered letters other than A,B or C
The code as follows:
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std ;
int main() {
// Deceleration Statements
[Code] ....
The question I am given is this:
Given a line of words (total character number is less than 100,
start from odd position 1,
and end with newline char "
").
Write a program to reformat it that new output is formed by each char from its odd position first, then its even position char.
how I can ignore strings from being entered by the user. When the use enter's a string it always evaluates it as even. I though I might use a cin.ignore(); but I am unaware of how to use it.
#include <iostream>
using namespace std;
int main() {
cout << "Enter a number: ";
int num = 0;
[Code] ....
Converting ascii value entered by user.
How to convert it to float basic of c programming techniques only ....
I am experiencing some errors with my first c++ program. im getting some compilation errors that i cannot figure out.
In file included from w2.cpp:7:
Fraction.h:17: error: variable or field 'enter' declared void
Fraction.h:17: error: expected primary-expression before 'struct'
Fraction.h:18: error: variable or field 'display' declared void
and so on ..........
Code:
#include "fraction.h"
//using namespace std;
/*
int main() {
struct Fraction fraction;
cout << "Fraction Simplifier" << endl;
cout << "===================" << endl;
enter(&fraction);
[Code] .....
Write a program to enter the number till 100 till the user want and at the end it should display the count of positive and negative and zero entered.
View 8 Replies View RelatedI'm trying to code a Singly-Linked List(Double Pointers) selection sort program and I can't tell what the problem is. My compiler says no errors but when I run the program, it crashes right after I enter the values.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct node{
int elem;
struct node* link;
[Code] ....
The compiler that I'm using is Dev-C++.