#include<stdio.h>
int main() {
int data[10], i, j, temp;
printf("Enter 10 random number to sort in ascending order:\n");
for(i = 0; i < 10; i++)
scanf("%d", &data[i]);
/* Sorting process start */
****** INSERT YOUR CODE TO COMPLETE THE PROGRAM ******
printf("After sort\n");
for(i = 0; i < 10; i++)
printf("%d\n",data[i]);
return 0;
}
Looking for alternative solutions for the program code.
// C program to sort an array in ascending order
#include<stdio.h>
int main() {
int data[10], i, j, temp, min;
printf("Enter 10 random number to sort in ascending order:\n");
for(i = 0; i < 10; i++)
scanf("%d", &data[i]);
/* Sorting process start */
// loop to sort the data in ascending order using selection sort
for(i=0;i<9;i++)
{
min = i;
// loop to get the ith minimum element from the array (i+1:10)
for(j=i+1;j<10;j++)
{
if(data[j] < data[min])
min = j;
}
// if ith minimum element is not present in place, swap it to get it in place
if(min != i)
{
temp = data[i];
data[i] = data[min];
data[min] = temp;
}
}
printf("\nAfter sort\n");
for(i = 0; i < 10; i++)
printf("%d\n",data[i]);
return 0;
}
//end of program
Output:
#include<stdio.h> int main() { int data[10], i, j, temp; printf("Enter 10 random number to...
#include<stdio.h> #include<stdio.h> int main(){ int i; //initialize array char array[10] = {“Smith”, “Owen”, “Kowalczyk”, “Glass”, “Bierling”, “Hanenburg”, “Rhoderick”, “Pearce”, “Raymond”, “Kamphuis”}; for(int i=0; i<8;i++){ for(int j=0; j<9; j++){ if(strcmp(array[j],array[j+1])>0){ char temp[20]; strcpy(temp,array[j]); strcpy(array[j],array[j+1]); strcpy(array[j+1],temp); } } } printf(“---------File Names---------\n”); for(inti=0; i<9; i++){ printf(“\t%s\n”,array[i]); } printf(-------5 Largest Files according to sorting----\n”); for(int i=0;i>=5;i--) { printf(“\t%s\n”,array[i]); } return0; } Consider the "sort" program (using with void* parameters in the bubblesort function) from the week 10 "sort void" lecture. Modify it as follows...
#include "stdio.h" int main() { float array[5][3],rowsum=0.0,colsum=0.0; int i,j; for(i=0;i<5;i++){ printf("Enter the %d elements of array:\n",i); for(j=0;j<3;j++){ scanf("%f",&array[i][j]); } } printf("Given table data:\n"); for(i=0;i<5;i++){ for(j=0;j<3;j++){ printf(" %0.1f",array[i][j]); } printf("\n"); } for(i=0;i<5;i++){ for(j=0;j<3;j++){ rowsum=rowsum+array[i][j]; } printf("sum of the %d row is %0.1f\n",i,rowsum); rowsum=0; } for(j=0;j<3;j++){ colsum+=array[j][i]; printf("Sum of %d coloumn is %0.1f\n",j,colsum); colsum=0; } return(0); } can someone help me to get the correct row sum and column sum in c program
C program-- the output is not right please help me to correct it. #include <stdio.h> int main() { int arr[100]; int i,j,n,p,value,temp; printf("Enter the number of elements in the array: \n "); scanf("%d",&n); printf("Enter %d elements in the array: \n",n); for(i=0;i<n;i++) { printf("\nelement %d: ",i); scanf("\n%d",&arr[i]); } printf("\nEnter the value to be inserted: \n "); scanf("\n%d",&value); printf("The exist array is: \n"); for(i=0;i<n;i++) { printf("%d",arr[i]); } p=i; for(i=0;i<n;i++) if(value<arr[i] ) { p = i; break; } arr[p]=value; printf("\n"); for (i =...
i need flowchart for the following c code #include <stdio.h> int main() { int n, i, sum = 0; printf("Enter an integer: "); scanf("%d",&n); i = 1; while ( i <=n ) { sum += i; ++i; } printf("Sum = %d",sum); return 0; }
#include<stdio.h> eint main() { int i = 0, j = 0; while (i < 10|| j < 7) { i++; j++; } printf("%d, %d\n", i, j); getchar(); return 0; } 01,01 10,10 7.7 10,7
sort.c #include <stdlib.h> #include <stdio.h> #include "libsort.h" int main() { int* array; int size, c; float median; printf("Enter the array size:\n"); scanf("%d", &size); array = (int*) malloc(size * sizeof(int)); printf("Enter %d integers:\n", size); for (c = 0; c < size; c++) scanf("%d", &array[c]); sort(array, size); printf("Array sorted in ascending order:\n"); for (c = 0; c < size; c++) printf("%d ", array[c]); printf("\n"); median = find_median(array,...
Convert the below C code to basic MIPS. Please leave comments for explanation #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b; scanf("%d",&a); scanf("%d",&b); a=a<<2; b=b<<2; printf("%d&%d\n",a,b); return 0; }
Convert the below C code to basic MIPS. Leave comments for explanation please #include <stdio.h> int main(void) { printf("Insert two numbers\n"); int a,b,c; scanf("%d",&a); scanf("%d",&b); c=a|b; printf("%d|%d=%d\n",a,b,c); return 0; }
#include<stdio.h> int main() { int i; printf("Type an integer value: "); scanf("%d",&i); evaluate(i); return(0); } void evaluate(int x) { if(x > 10) printf("Value entered by you is greater than 10"); else if(x < 10) printf("Value entered by you is less than 10"); else printf("Value entered by you is equal 10"); } _______________________________________ report for this in hr ?
include<stdio.h> #include<pthread.h> int i=4 ,j=10; void*childfunc(void *p) { printf("child here.i=%d,j=%d\n",i,j); i*=3; j*=3; printf("child here.i=%d,j=%d\n",i,j); } void main() { pthread_t child1; pthread_create(&child, Null,childfunc, Null) pthread_join(child,Null); printf("parent here.i=%d,j=%d\n",i,j); i*=2; j*=2; printf("end of program .i=%d,j=%d\n",i,j); } what is output?