Problem 4 - x] first = list[4-i] last = temp list[4-x] =...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 /* Anil Kanungo */ /* Lab 8 */ /* Problem 4 */ /* Sort 5 integers */ #include <stdio.h>/* Standard IO header file */ #include <conio.h> int main() { //initialize variables int list[5] int i int x int first int last int temp //clears array "list" to 0 for (i = 0 { list[i] = 0 } //stores input from user for (i = 0 { printf("Enter an integer: ") scanf("%d", &list[i]) } //sorting process for(x = 4 { first = list[4-x] for(i = 0 { last = list[4-i] if(last < first) { temp = list[4-
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x] first = list[4-i] last = temp list[4-x] = first list[4-i] = last first = list[4-x] } } } //prints array &quot;list&quot; printf(&quot;-------------------- \n&quot;) Page 1 i&lt;5 i++) i&lt;5 i++) x&gt;0 //defines &quot;first&quot; i&lt;x //defines &quot;last&quot; x--) i++) //redefine &quot;first&quot; Sheet1 printf(&quot; \n&quot;) printf(&quot; \n&quot;) printf(&quot;Ascending Order: \n&quot;) for (i = 0 { printf(&quot; %d --&gt; %d \n&quot;, i+1, list[i]) } } i&lt;5 i++) Page 2...
View Full Document

Page1 / 3

Problem 4 - x] first = list[4-i] last = temp list[4-x] =...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online