C :: Sorting Array Alphabetically - Print 10 Names In Ascending Or Descending Order

Apr 9, 2014

//Build a program that uses a single-dimension array to store 10 names input by a user.

//After inputting the names, the user should see a menu with two options to sort and print the 10 names in ascending or descending order.

insert
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char names[10];
char temp[10];
int count,i,j;
int sort;

[Code] .....

View 10 Replies


ADVERTISEMENT

C++ :: Sorting Numbers In Both Ascending And Descending Order?

Sep 7, 2014

What kind of code should i use for sorting numbers in both ascending and descending order? I don't know how to use bubble sorting either, is there another easy way to sort this out?

View 3 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++ :: Put Numbers In Ascending / Descending Order

Nov 9, 2014

I have to put these numbers in ascending and descending order . The interesting point of the function is that sortMe does NOT re-arrange elements in the array; instead, it uses a second array, an array of indexes for the elements in the original array and then sortMe sorts the second array based on the values in the original array. A sorted version of the original array can then be produced with these sorted indexes. I'm not sure why the function is working, even though I called it in main.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void sortMe(int array[], int sortedIndexes[], int size, char mode);
char option;
const int SIZE = 5;

[Code] .....

View 7 Replies View Related

C :: Write Program To Sort 2 Ints On Ascending / Descending Order?

Jan 24, 2014

I'm trying to write a program to sort 2 ints on ascending/descending order, using function pointers. here is my code so far:

Code:
#include <stdio.h>
#include <stdlib.h>
int min_el(int a,int b);

[code]....

View 6 Replies View Related

C++ :: Enter Number Or Letter And Sort In Ascending Or Descending Order

Jan 8, 2013

Assignment:

1. Choose what to enter NUMBER or LETTER.
2. Choose type of sorting ASCENDING or DESCENDING.

#include<iostream.h>
#include<conio.h>
main() {
int x,y,z;
cout<<"choose Number or letter
1.number
2.Letter";

[Code] ....

View 9 Replies View Related

C++ :: Sorting Array In Ascending Order

Jan 4, 2014

This code prints 10 20 40 50 30.

#include “stdafx.h”
#include
#include
using namespace std;

int main() {
int anarray[5] = {40,10,50,30,20};
for (int iii=0 ; iii <= 4 ; iii++)

[Code] .....

View 1 Replies View Related

C++ :: Bubble Sorting Array In Ascending Order

Nov 18, 2014

I'd like to modify this code so that there is 1000 numbers instead of 100, and that they're sorted in ascending order instead of descending order.

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
double* sort_array(double* sort) {
for (int a=1; a<100; a++) {

[code]....

View 2 Replies View Related

C++ :: Sorting Array Of Numbers Into Ascending Order - Bubble Sort Keeps Crashing

Oct 29, 2014

I am trying to write a program which will sort an array of numbers into ascending order, here is my code

#include<iostream>
#include<cmath>
using namespace std;
int main(){
int array[]={1, 5, 17, 3, 75, 4, 4, 23, 5, 12, 34, 34, 805, 345, 435, 234, 6, 47, 4, 9, 0, 56, 32, 78};

[Code] .....

This compiles fine but when I run the .exe for the first time an error message comes up saying program has stopped working. If I run the program again without recompiling it seems to work as expected.

View 2 Replies View Related

C++ :: Inserting File Of Names And Sorting Alphabetically?

Feb 25, 2013

A teacher has asked all her students to line up single file according to their first name. For example, in one class Amy will be in front of the line and Yolanda will be at the end.

Write a program that will read in a file of names. Names should be read until there are no more names to be read. Use LineUp.txt as a test file for your program.

Once all the names have been read in display which student will be at the front of the line and which one would be at the end of the line. You may assume that no two students have the same name.

These are the name in the LineUp.txt file if needed:
Cooper
Gavin
Joseph
Sierra
Kacie
Dylan
Kaylee
Will

and so on .....

View 1 Replies View Related

C++ :: Vector Int Sorting In Ascending Order

Feb 17, 2015

I want to sort a vector int in ascending order, but when I test, the output isn't correct - the vector is still unsorted. Am I calling it incorrectly?

int sorted (vector <int> a) {
int size = a.size();
sort(a.begin(), a.end());

View 2 Replies View Related

C++ :: Sorting Arrays In Ascending Order

May 28, 2014

// OK this program outputs an array of numbers which are read from two .txt //files which are set1 and set2.

// set1.txt has: 8 37 29 31 40 25 18 38 4 45 34 39 12 21 24 3 5 23 26 44

// set2.txt has: 46 42 25 20 19 29 49 4 32 2 10 12 39 17 33 6 3 15 45 21

// But the problem is that when you run the program, the numbers do not come out // in numerical order.

#include <iostream>
#include <fstream>
#include <string>

[Code]....

View 2 Replies View Related

C :: Sorting Number As A String By Ascending Order

Jul 2, 2014

make my program sort data.in this case number that i declared as char(not string, my bada)if i have

name1
number 2500
email

name 2
number 2400
email

i need to put that this way:
name 2
number 2400
email

name1
number 2500
email

i saw that can be done with qsort but when i try it it doesn't work.

Code:

typedef struct {
char nome[MAX_GERAL], email[MAX_GERAL], morada[MAX_GERAL], postal[MAX_GERAL], numero[MAX_GERAL], geral[MAX_GERAL];
int telefone, FP, SD, AM1, ALGA, CM;
}dados;

code to add info i need to sort "numero"

Code:

void adicionar(dados* contacto){
if (i<total) {
printf("
Introduza o Nome: ", i + 1);
scanf(" %[^

[code]....

View 7 Replies View Related

C++ ::  sorting Ascending Order By According To Product Id / Name / Price

Jul 20, 2014

Here is my code below:

#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<iomanip>
#include<string>
using namespace std;
void main() {
fstream file;
string id,name,type,price;

[code].....

I can't separate and align 4 categories neatly, how to do this solution below(the link of example for sorting Product ID in ascending order): [URL]

By the way,here is the required .txt file(test.txt): [URL]

View 4 Replies View Related

C++ :: Sorting Records By User Field In Ascending Order

Nov 7, 2013

How do i sort records by user specified field in ascending order, without knowing how many columns the file has? its getting the data from a file.

View 6 Replies View Related

C++ :: Sorting Vectors Based On Value Of First Integer In Ascending Order

Feb 13, 2013

I have a vector which contains vectors containing 7 integers each. I'd like to sort these vectors based on the value of the first integer (int IOT), in ascending order. I know this type of question can be found everywhere, but I'm lost as to why this doesn't compile.

#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <windows.h>
using namespace std;
class orders {
public:
int IOT; // Incoming Order Time

[Code] ....

View 7 Replies View Related

C++ :: Sorting User Defined Amount Of Random Numbers In Ascending Order

Jan 30, 2013

I want to implement a function into the code below that sorts the user defined amount of random numbers and then sorts them in ascending order.

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <string>

using namespace std;
class IntegerArray {

[Code] ....

View 5 Replies View Related

C++ :: Sorting String Array Alphabetically

Nov 7, 2014

I wish to sort a string array alphabetically and im not sure if i am doing it right. for example:

string a[5]; //initial array
string b[5]; //sorted array
int index = 0; //index of b array

for (int i = 0; i < 5; i++){
for (int j = 0; j < 5; j++){
int c = 0;

[Code] ....

View 2 Replies View Related

Visual C++ :: How To Put Ascending And Descending Integer In Netbeans

Jan 22, 2013

How to put <stdio.h> ascending integer and descending integer?? in netbeans c++..

View 3 Replies View Related

C++ :: Array In Ascending Order And Average

Mar 19, 2014

I am getting the hang of it pretty well. I created a program that asks the user to input arrays. Now, I need to calculate the average of the inputted arrays, and I need to place them in order from low to high. I have been struggling with doing these two parts for a while now and now decided that the book is not useful, I need some from some actual programmers. I attached my program.

My program printed here!

Code:
#include
<iostream>
using
namespace std;
int
main()

[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

Visual C++ :: Array Of Numbers Sorted In Ascending Order?

Jan 30, 2015

understand the details of what this function actually do?

View 7 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++ :: 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++ :: Bubble Sort - Put In Descending Order

Jan 22, 2014

so my program reads a file type which looks like this...

Michelle 71
Marcie 99
David 42
Rebecca 83
Jonathan 79
Matthew 77
Rose 7
Melanie 75
Kimberly 73
Roger 74
Scott 76
Bradley 77
Drextell 10
Heidi 70
Alan 68
Pearl 13
Jeanne 43
Heber 55

Here is whats in the header of the class

class StudentStat {
private:
int Size;

[Code].....

So as of right now the names are stored in a Names string array and the scores are saved in a Score int array. So my question is where do I begin with my bubble sort? I need it to put the scores in descending order so from greatest score to lowest but I need the Names in the string array to still be connected to the number from the list. Never done a bubble sort before so not sure where to begin.

View 1 Replies View Related

C++ :: How To Store Data By Descending Order Auto

Oct 27, 2014

I wanna store my data by descending order auto without doing a classification after , i have come up with a code but it crashes.

Code:
void list::create(int num) {
struct node * n,*temp;
n=new node;
n->data=num;
if(head==NULL)

[Code]....

I don't wanna use the list library with the push.buck, i need to do it by coding it without fix functions ....

View 3 Replies View Related







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