Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Basic C program: Create an array that contains 50 numbers. Then fill that array

ID: 3712436 • Letter: B

Question

Basic C program: Create an array that contains 50 numbers. Then fill that array with random numbers between 0-100. Print the array. Then sort it using any sorting algorithm you like and print the sorted array. Basic C program: Create an array that contains 50 numbers. Then fill that array with random numbers between 0-100. Print the array. Then sort it using any sorting algorithm you like and print the sorted array. Create an array that contains 50 numbers. Then fill that array with random numbers between 0-100. Print the array. Then sort it using any sorting algorithm you like and print the sorted array.

Explanation / Answer

#include<stdio.h>

#include<conio.h>

int main()

{

int arr[1000];

int n=0,i=0,temp=0,j=0;

printf("enter no of elements in array");

scanf("%d",&n);

for(i=0;i<n;i++)

{

scanf("%d",&arr[i]);

}

// now we will print this array

printf("Elements of array are:");

for(i=0;i<n;i++)

{

printf(" %d",&arr[i]);

}

//Now we will sort array Using Bubble sort

  

  for(i=1;i<n;++i)

{ for(j=0;j<(n-i);++j)

            if(arr[j]>arr[j+1])

            {

                temp=arr[j];

                arr[j]=arr[j+1];

                arr[j+1]=temp;

            }

}

    printf(" Array after sorting: ");

    for(i=0;i<n;++i)

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

    return 0;

}

// in this code firstly we will take an array of large size ,then we will ask the user to input the size of array, according to his requirement. Then we will take elements in array using "scanf() ".scanf() is a function to take input from user.

then we will print the array using "printf()" function .Then I used Bubble sort to sort array then printed using "printf()" function and using an "for" loop.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote