Sunday, August 2, 2009

How will i sort 5 numbers in an array using c language??

Your question is not clear.


How do you want to sort the 5 numbers?


Ascending or descending? or any other way?


How can we arrange all o's element to the end of the list in array in c++ programming code?

other elemtents to the left of the list.

How can we arrange all o's element to the end of the list in array in c++ programming code?
thats a tough one to ask...it would help if you could post the rest of your code here.





Edit: how about something like, if number=0, place it in end of array?

credit cards

Example of multi dimensional array in turbo c?

i dont know how to manipulate array in turbo c

Example of multi dimensional array in turbo c?
An array is a variable that has space to hold 1 or more instances of only ONE data type.


Example:


unsigned int fuzz[256];


This allocates enough memory for 256 unsigned integers, referenced by the variable name fuzz.


You can store up to 256 unsigned integer numbers in that array. Example: 4,5,7,10,etc.


If you want to write a number to the array, you would write something like: fuzz[2]=4;


In this case, the unsigned integer 4 is written to the 3rd location of array fuzz (array numbers start at 0, not 1!).





A multi-dimensional array is like a matrice.


Using my previous example, you can think of a single array as 1 row of numbers. A multi-dimensional array can be thought as having multiple rows of data.





Example:


unsigned int foo[256][256];


This is a two dimensional array.


Think of it as 1 row of numbers, with another row of numbers beneath it.


To write to the first location in the SECOND row, you could do this: foo[1,0]=4.


The first number in the bracket represents the row number (0-1 in this case) and the second number represents the location on that particular row. The number 4 is written to the second row, 1st column on that row.
Reply:yes


Can anyone help me write this in C code?

a) Declare an array of 25 integers.





b) Write a line of C code that will print out the value of the 10th item in the array you declared in a).











c) Write C code that will print out every item in the array, in its order in the array (i.e. by index number), in 5 lines of 5 items each.

Can anyone help me write this in C code?
take help from an expert


http://homework.teamtutorial.com/
Reply:#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int arr[25];


clrscr();


//assign value to 10th item as


arr[10]=25;


printf("%d",arr[10]);


getch();


}
Reply:a) int a[25];

brandon flowers

How do I make a C program?

How do I make a C program that solves a system of three linear equations with three unknowns using determinant of the third order(3*3). Be guided by the following:


1. Use two dimensional arrays in programs.


2. Prompt the user for the input of numerical coefficients and constants of the three equations.


3. The program must contain at least three functions(not including main):


a. A function that computes;


b. A function that displays the matrices; and


c. A function that temporarily stores and replaces values in the matrices ;


4. The program should display the four matrices and the values of the three unknowns should be displayed.


(Show me the output pls...)

How do I make a C program?
I didn't read what you wrote cuz no one reads such long questions :) to make a C program you need to know C programming language and need to have a C compiler :(
Reply:It really sounds like you're asking for people to do your homework for you. At least make the effort to paraphrase the question. Preferably, ask something *specific*. This reminds me of the occasional post to usenet back in the day (before myspace, the "web", etc).





Here is the official response to your question, first doled out well over a decade ago:


http://www.catb.org/~esr/faqs/smart-ques...





(in fact, this is the answer to 90% of the questions posted here in "yahoo answers")


How do I sort an array of strings in C++?

I really can't figure this out! If I could have an example of a sorting algorithm that would work on an array of names, I would really appreciate it.


-No bubble sort


-Only use iostream.h and strings.h if necessary


-Thanks!

How do I sort an array of strings in C++?
Here is an algorithm called selection sort.





#include %26lt;iostream%26gt;


# include %26lt;string%26gt;





void selectionSort(string array[ ], const int arraySize);


int findSmallest(string array[ ], int startIndex, int endIndex);


void swap(string%26amp; first, string%26amp; second);


void print(string array[ ], const int arraySize);





int main( )


{


const int ARRAY_SIZE = 3;


string someArray[ARRAY_SIZE] = {"cat", "mouse", "dog"};


selectionSort(someArray, ARRAY_SIZE);


print(someArray, ARRAY_SIZE);





return 0;


}





void selectionSort(string array[ ], const int arraySize)


{


int smallestIndex = 0;


for(int i = 0; i %26lt; arraySize; i++)


{


smallestIndex = findSmallest(array, i, arraySize - 1);


swap(array[i], array[smallestIndex]);


}


}





int findSmallest(string array[ ], int startIndex, int endIndex)


{


int smallestIndex = startIndex;





for(int i = startIndex + 1; i %26lt;= endIndex; i++)


{


if(array[i] %26lt; array[smallestIndex])


smallestIndex = i;


}


return smallestIndex;


}





void swap(string%26amp; first, string%26amp; second)


{


string temp = first;


first = second;


second = temp;


}





void print(string array[ ], const int arraySize)


{


for(int i = 0; i %26lt; arraySize; i++)


cout %26lt;%26lt; array[i] %26lt;%26lt; endl;


}
Reply:There are plenty of different sorts out there, and they can all be applied to arrays/variables/objects of any kind. You just have to write the comparison function yourself





Lookup these sorts on the net:


Insertion Sort


Shell Sort


Quicksort


radix sort


mergesort





There is alot of example code out on the internet. These are very common programming tasks





Note: Insertion sort is probably the easiest to program(but not the most efficient)


C++ : Row Major OR Column Major 2D array?

Which type is default in C++ for 2d arrays: Row or Column major. How can I initialize a 2d array by both ways?





Please and Thank You

C++ : Row Major OR Column Major 2D array?
In C++, the 2D arrays are stored in row major order





Visit http://www.daniweb.com/forums/thread2218... for example and http://www.cs.uaf.edu/~cs301/notes/Chapt... for explanation
Reply:If you use loops to initialize the array, change the order of the loops to change the order of initialization.





If you initialize the array when you declare it, the rows will be filled before columns:


int c[2][2] = {1,2,3,4};


- will have 1,2 in the first row and 3,4 in the second.