C :: How To Arrange Input / Output Order

Sep 22, 2014

for our school project, we have to make a program which involves three students and the prices each of them paid for the meals. The program has to calculate how much each of the students has to pay/receive to/from the others. Most of it, we got from our teacher. The error we are getting is that we have to 'take care of the input/output order'. So if you type in the names/numbers of the students in a different way, so for example if you type first number 1, then 0, then 2 and 0 and 1 have to pay money to number 2, number 0 has to be in front of 1. Our output is that number 1 is in front of number 0.

insert
Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

[Code].....

View 1 Replies


ADVERTISEMENT

C++ :: Reads User Input And Arrange Letters In Ascending Order?

Apr 21, 2014

I am trying to build a c++ that reads user input and arrange letters in ascending order.

for example, if the user input: Hello my name is Moe! the output will be: !aeeehillmmmnoos (ascending order)

my problem is that when i input hello my name is moe the output will be ehllo (not completing other letters) also when i change class size to 50, it outputs unknown weird letters.

This is my code:

#define CLASS_SIZE 10
#include <stdio.h>
#include <iostream>
void bubbleSortAWriteToB(const char a[], char b[]);
using namespace std;
int main(void){
int i;

[Code]...

View 3 Replies View Related

C :: Arrange Set Of Names In Array In Alphabetical Order

Oct 25, 2013

I am having problem with comparing first letter of every wordso that i can arrange them in array.

Code:
/*22/10/13 15:30
Arrange set of names in an array in alphabetical order
*/
#include<stdio.h>
main( ) {
int x,a,i=0,j;
char *temp, *str[]={

[Code] ....

I am getting unexpected output here :

Code:
himanshu
amit
nitin
saurabh

View 3 Replies View Related

C++ :: Input Sentence And Then Output It In Reverse Order

Jun 3, 2013

I need to do program where i will input sentence and then output it in reverse order. Example: today is Monday ----> Monday is today. So I have this:

#include <iostream>
#include <cstring>
using namespace std;
int main() {
char niz[20],niz2[20];
int lenght,k=0;

[Code] ....

For output I only get one word of sentence,example: Monday is today--->today and nothing else.

View 5 Replies View Related

C# :: Output Numbers In Different Order?

Mar 17, 2015

I am currently writing a program and am having some trouble figuring out how to get the order correct in the output.

Here is my code:

using System;
using System.Collections;
using System.Text;
namespace The_Last_Survivor {
class Program {
static void Main(string[] args) {

[code].....

The output I need to have is:

Actors Count Audition Order

1 1 1

2 1 1 2
2 2 2 1

3 1 1 2 3
3 2 2 1 3
3 3 3 1 2

4 1 1 2 3 4
4 2 2 4 3 1
4 3 3 2 4 1

[code].....

Right now the numbers are just printing in order 1-9 and not changing.

View 7 Replies View Related

C :: Bubble Sort - Output In Descending Order

Feb 1, 2014

I'm stuck again on a homework problem. I enter 9 8 7 6 5 4 3 2 1 in to the program when it asks me to. I print out the array (just before the bubble sort routine) and I get the numbers in descending order just as expected. So going into bubble sort routine, the numbers are correct.

I should get 1 2 3 4 5 6 7 8 9 as output.

But I get 1 2 3 4 4 5 6 7 8

Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int max_size = 20; // max size of array of numbers
int numbers[max_size]; // array for numbers

[Code] .....

View 4 Replies View Related

C++ :: Unable To Output Array In Ascending Order

Sep 13, 2013

I tried to make this code to output an array in Ascending Order but the output is showing weird output like 001fgc123 multiple times instead of the array.

What is wrong with my code?

#include <iostream>
using namespace std;
void ascOrder(int Array[],int length) {
int n=0,i,orderNum=0;
while(n<length) {
for(i=0;i<length;i++)

[Code]...

View 2 Replies View Related

C++ :: Output Sections Of Txt Code In Random Order

Mar 27, 2014

I will keep this simple as I have the code written for my testing software program, I just want to add a feature of randomly generating the answer choice output order, I do not want to randomly output the full questions, but instead the choices (answers to the question), for example =

#include <string>
#include <iostream>
#include <limits>
cout <<" " << endl ; \ space

[Code] ....

As you can see I would like to output the answers, choices randomly as in answer choice 3 will appear at the top instead of 1. and so on, it doesn't matter if the numbers move with the txt as the numbers beside the
questions are txt.

It's a 32bit console application.

View 4 Replies View Related

C++ :: Sorting Data - Output Names And Ages In Ascending Order

Oct 24, 2013

I am having problems sorting data... I don't know to to go about it here is my code:

<code>
#include <iostream>
#include <string>
using namespace std;
int main () {
int i;
struct person

[Code] ....

i want to sort it out so that it can output names and ages in ascending order.

View 2 Replies View Related

C/C++ :: Implement Breadth First Search Graph And Output Order Of Traversal

Mar 26, 2014

I'm new to program breadth first search and for my assignment we have to implement a breadth first search graph and output the order of the traversal. The problem is when I run my program I do not get any output from my traversal. All I get is "Breadth First Search Traversal starts at Vertex 2 and the order is: "

Here is my Queue class

//Declaration of node
struct node{
int info;
node *next;
};
//Defining Queue class
class Queue{

[Code] ....

View 4 Replies View Related

C++ :: Selection Sort For Non Decreasing Order Input?

Feb 17, 2013

Question: What is the efficiency and big O of the selection sort algorithm when the input happens to already be in nondecreasing order?

Answer: Not sure... since the input is in nondecreasing order, such that example 0, 1, 1, 2, 3, 4, 4, 5 then there will be no swap, Just comparisons of emelemts. So it is big O of n

View 2 Replies View Related

C++ :: Arrange Names Alphabetically From A Text File

Feb 25, 2013

I'm trying to arrange names alphabetically from a text file. Inside my textfile, it's like : "John", "Edward", "Peaches", "Anna"... etc.(It has thousand more names, all with quotations, separated by comma and I think it's not typed line by line... but using only one line). How can I read each name separately?

this code, it works if the text file contains names separated by lines and without commas and quotations. I do not know with the case I've stated above.

string numbers[1000];
string line;
string number;
string y;
string x;
int z = 1;
ifstream myfile;
myfile.open("names.txt");

[Code]...

This only shows the data inside text file. I'm new in c++.

View 2 Replies View Related

C++ :: Switch Structures - Program To Arrange Values

Mar 5, 2012

Write a program that accepts three values (int) from the keyboard into three variables a, b and c. After loading the variables, your program will arrange the values into a, b, and c, so that a contains the larger, be the next and c the smallest.

You can use any other variables in addition to a, b c, as you see fit.

You will have to use some variation(s) of the if construct.

There are many ways to program this, but your challenge will be to achieve this without doing all possible comparisons. In fact, three comparisons woudl be enough, if you , for example, determine the largest number first, and keep track of its position in some way , so you can compare the other two.

I think I might use a code similar to the one below.

switch (expression) {
case constant1:
group of statements 1;
break;
case constant2:

[Code] ....

View 14 Replies View Related

C :: How To Sort Data In Linked List And Arrange Them Highest To Lowest

Aug 12, 2013

i am making a program that reads a file from .txt and print them out using linked list. However, i need to sort them from the highest price to lowest price.

Code:

/* my structs */
typedef struct{
Node *head;
Node *tail;
Node *iterator;
int size;
} List;

[Code]...

i know its long but im afraid that i might miss out some things.

View 12 Replies View Related

C :: Read Amount Of Order From Standard Input / Compute And Print Total Price After Discount

Apr 13, 2014

A Bookseller makes special discount for multiple orders of a book as follows:

AMOUNT and DISCOUNT as follows.

5-9 5% 10-14 10% 15-19 15% 20+ 20%

Write a C main function to read the amount of order from the standard input and compute and print the total price of the given order after the discount. Assume that unit price of a book is 10.00$

My problem is that.When i start with this

Code:
#include<stdio.h>
#include <stdlib.h>
int main(void)
{
int number;
float TotalPrice;
printf("enter a number:");

[Code] ....

I get 0 if i enter a number between 0 and 4(0 and 4 included). I don't know where I am doing a mistake. I also want to know if i can handle this buy just if statements. or how can i do it by while and for loops ?

View 1 Replies View Related

C :: Redirecting Input And Output

Sep 14, 2013

I have this code:

Code:

#include <stdio.h> //printf
#include <stdlib.h> //exit
#include <unistd.h> //fork
#include <sys/types.h> //pid_t
#include <sys/wait.h> //waitpid
}

[code]....

I would like to, when running cat, send in some data like "testing" to its stdin, and then catch the output of stdout, and put it into a character array variable.Currently the parent stalls till the child is done.I imagine the parent has to some how detect that the child executed 'cat', and then send in input to stdin?Then somehow detect that 'cat' is done executing, and read the output from stdout? I have looked around and found "dup2", but I don't understand how to send in and get data to the child from the parent, especially since the "file descriptors" is not pointing to any files in the first place..

View 4 Replies View Related

C++ :: Audio Input / Output?

Feb 5, 2015

So I have a project in which I am processing audio signals in real-time. I want to create a class to do this using the ASIO driver. I don't want to use a cross platform library nor do I want to use windows API as it is very slow.

View 2 Replies View Related

C/C++ :: Console Input / Output?

Sep 7, 2014

I'm trying to write something that when a user is at the command line, the user can type and it displays of list of commands the user can use to run the application.

View 14 Replies View Related

C++ :: Zero And Output The Input With A Setprecision Of 2

Mar 31, 2013

I have a program that needs to output the input with a setprecision of 2 but when it outputs 0, it has to be "0", not "0.00"

How will I go about that?

Here is my code:

void PrintAllSales(double sales[][SLSPRDT]) {
cout << fixed << showpoint << setprecision(2) << endl;
cout << "ALL SALES
";
WriteLine('=', 63);

[Code] .....

And here is how it comes out:

1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0.00 | 299.00 |
Salesperson 2 | 0.00 | 2543.98 | 95.99 |
Salesperson 3 | 0.00 | 0.00 | 19.99 |
Salesperson 4 | 0.00 | 3854.75 | 0.00 |

But it should be like this:

1234
ALL SALES
===============================================================
Product # | 1 | 2 | 3 |
Salesperson 1 | 2000.00 | 0 | 299.00 |
Salesperson 2 | 0 | 2543.98 | 95.99 |
Salesperson 3 | 0 | 0 | 19.99 |
Salesperson 4 | 0 | 3854.75 | 0 |

View 7 Replies View Related

C/C++ :: How To Save New Input Using Output

Sep 11, 2012

I have a project, a montly paycheck. So it checks the monthly paycheck of each employees. but my problem there is how to add a new employee when u are a user or in the output of program?

View 2 Replies View Related

C++ :: String Integer Value - Input / Output

Aug 14, 2013

Code:
Prompt the user to input a string,
and then output the sum of all the digits in the string.

Sample Run 1:
Input -> A111B222C
output -> 9

Sample Run 2:
Input -> ABC123XYZ32100000005555555555zzzzzz
output -> 62

View 1 Replies View Related

C++ :: File Input And Output Structure

Jul 17, 2013

How to structure the input of one .dat file and outputting into another one. I have to loop through a file structured "doe, john, 1500", check for errors and then increase the mp by 50. You also have to do this through using a person class too. I think I need to use a while loop to go to eof and use getline to input correctly, but im not sure how to structure it.

Data file:
Horowitz,Jake,1200.24
Flabitz,Bubba,1712.38
Blackwell,Sharon,1872.93
Molerat,Rufus,501.00
Goodall,Jane,1567.43
Sommerset,William,1359.57

[Code] ......

View 4 Replies View Related

C++ :: Get Input From Ports And Send Output

Jul 30, 2014

I'm learning C++. Is there some way to make program function on input from a port like usb port and can I send bits through the port? For example A usb cable connected to a circuit. I press a button and an AND gate on the circuit gets activated by a bit from the usb port and a fan in the room turns on.

View 1 Replies View Related

C++ :: Assigning Input To Value - Random Output

Jul 24, 2014

I'm using getline, and stringstream to assign an input to a value. How to do something similar with a random output.

//Battle with Samer
#include <iostream>
#include <string>
#include <sstream>
#include <ctime>
#include <cstdlib>
using namespace std;

const char* PokemonSamer[6] = {
"Charizard", "Umbreon", "Mew", "Arcanine", "Espurr", "Luxaray"

[Code] ....

When I run <PokemonSamer[rand() % 6]>, I want to be able to save whatever that output may be, and save it to <string Samer>. Is this possible?

View 6 Replies View Related

C++ :: String Input AND Output To File

Sep 15, 2013

I'm trying to write a simple program that will prompt for a string typed in by keyboard and save it to a file. I've tried lots of variations and this is just the latest version.

//Prompt for a string input by keyboard and save it to a file

#include<iostream>
#include<fstream>
#include <string
using namespace std;

[Code] .....

View 2 Replies View Related

C++ :: Input And Output Array Using Function

Apr 25, 2013

I want to create a function that will accept input from the user and return the input, to be used for further calculation. I know how to accept and return with integers as parameters , but how do i do it with arrays?

Suppose there is an array of numbers arr[]. Now, i want a function that accepts the input from the user, and return the array for further manipulation.

For example, if the array is arr[5], then i should call a function and accept the values from the user. Then, i should return the imputed values and print the same. How can i do this.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved