answersLogoWhite

0

#include

#include

void main()

{

int n ,i,j,temp,a[12]; //in a[] specify some number .

printf("Enter the no of inputs:");

scanf("%d", &n);

printf("Enter %d integer numbers :", n);

for(i=0;i

{

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

}

for (i=0;i

for(j=i+1;j

{

if(a[i]>a[j])

{

temp=a[j];

a[j]=a[i];

a[i]=temp;

}

}

printf("THE %d NUMBERS SORTED IN ASCENDING ORDER ARE :\n", n);

for(i=0;i

{

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

}

getch();

}

Here is another version of the program. While the previous one is obviously simpler, this one is a good program to master the basics of pointer and array problems which might plague them at the beginning.

#include

#include

int a[100],i,j,k,n;

void sort(int *a,int n);

void swap(int *x,int *y);

main()

{

printf("How many numbers? ");

scanf("%d",&n);

printf("Enter the %d numbers separated from each other by a blank space: \n\n",n);

for (i=0;i

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

sort(a,n);

printf("\nThe numbers in descending order is: \n");

for (k=0;k

printf("\n%d",a[k]);

printf("\n\n");

}

void sort(int *a,int n)

{

int p=n-1;

while (p>=0)

{

for(i=0;i<=(p-1);++i)

{

if (a[i]<=a[i+1])

swap(&a[i],&a[i+1]);

else

continue;

}

--p;

}

}

void swap(int *x,int *y)

{

int t;

t=*x;

*x=*y;

*y=t;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Write a program in java to enter 3 digits or more arrange the digits of the entered number in ascending order and display the result?

public static void main(String[] args) { int val = 100; int val1 = 50; System.out.println("Number of digits in " + val + " is: " + new String(val + "").length()); System.out.println("Number of digits in " + val1 + " is: " + new String(val1 + "").length()); }


How write a program to input any number and display digits which are absent in given number?

To write a program that inputs a number and displays the digits absent in it, you can follow these steps: Convert the input number into a set of its digits. Create a set of all possible digits (0-9). Subtract the set of digits from the complete set to find the missing ones. Display the missing digits. Here’s a simple example in Python: number = input(&quot;Enter a number: &quot;) present_digits = set(number) all_digits = set('0123456789') missing_digits = all_digits - present_digits print(&quot;Missing digits:&quot;, ''.join(missing_digits))


Java program to arrange any numbers in ascending order using scanner classes?

To arrange numbers in ascending order using Java, you can utilize the Scanner class to read input from the user and then sort the numbers using an array. Here's a simple example: import java.util.Arrays; import java.util.Scanner; public class AscendingOrder { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(&quot;Enter the number of elements: &quot;); int n = scanner.nextInt(); int[] numbers = new int[n]; System.out.println(&quot;Enter the numbers:&quot;); for (int i = 0; i &lt; n; i++) { numbers[i] = scanner.nextInt(); } Arrays.sort(numbers); System.out.println(&quot;Numbers in ascending order: &quot; + Arrays.toString(numbers)); scanner.close(); } } This program collects a specified number of integers from the user, sorts them using Arrays.sort(), and then displays the sorted list.


How do you write a program in qbasic to input 64751315 to sum?

In QBASIC, you can write a simple program to input the number 64751315 and sum its digits as follows: DIM sum AS INTEGER sum = 0 INPUT &quot;Enter a number: &quot;; number FOR i = 1 TO LEN(number) sum = sum + VAL(MID$(number, i, 1)) NEXT PRINT &quot;The sum of the digits is &quot;; sum This program prompts the user to input a number, iterates through each digit, converts it to an integer, and adds it to the total sum, which is then printed out.


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.

Related Questions

Write a program in java to enter 3 digits or more arrange the digits of the entered number in ascending order and display the result?

public static void main(String[] args) { int val = 100; int val1 = 50; System.out.println("Number of digits in " + val + " is: " + new String(val + "").length()); System.out.println("Number of digits in " + val1 + " is: " + new String(val1 + "").length()); }


How do you make the smallest odd number out of 5671?

To make the smallest odd number from the digits of 5671, you need to arrange the digits in ascending order while ensuring the last digit is odd. The odd digits available are 1 and 7. Placing 1 at the end gives you the smallest combination: 5671 can be rearranged to form 1567, which is the smallest odd number possible with those digits.


What is the median of these numbers 2336712?

To find the median of the numbers in the sequence 2336712, first, we need to arrange the digits in ascending order: 1, 2, 2, 3, 3, 6, 7. Since there are seven digits (an odd number), the median is the middle number, which is the fourth digit in the ordered list. Therefore, the median is 3.


Write the number with the least value using the digits 1 through 9 use each digit once explain your reasoning?

To create the smallest number using the digits 1 through 9, we should arrange the digits in ascending order. This is because placing smaller digits in the higher place values results in a smaller overall number. Here's how you can do it: List the digits in ascending order: 1, 2, 3, 4, 5, 6, 7, 8, 9. Combine them to form the number: 123456789. This number has the least value because it starts with the smallest digit (1) in the highest place value 1, followed by the next smallest digits in order. Using any other arrangement would result in a larger number.


Smallest number you can using 91764?

The smallest number that someone can get using the 91764 digits is 14679. The secret is to arrange the digits from the least number to their greatest number.


How to find the smallest number?

When you are given some numbers just arrange them in ascending order and you will the smallest number which can be made out of those given numbers.


How do you work out the median for a set of eight numbers?

Arrange the numbers in ascending order, and then take the mean of the fourth and fifth number.


What is the smallest possible whole number of the digits 3618?

To find the smallest possible whole number using the digits 3, 6, 1, and 8, we need to arrange them in ascending order. The smallest whole number would be 1368. This is because in whole numbers, the digit in the leftmost place value should be the smallest possible digit available.


How do you arrange the digitsof a particular number to make the smallest and largest possible number?

To give the particular number the largest possible value, arrange the digits in the order of their individual value, beginning with the largest one on the left and smallest on the right. To give the particular number its smallest possible value, arrange the digits in the order of their individual value, beginning with the smallest one on the left and largest on the right.


What is the smallest 10- digit number with no repeated digits?

The smallest 10-digit number with no repeated digits is 1023456789. This number starts with 1, the smallest non-zero digit, followed by the remaining digits in ascending order, ensuring all digits from 0 to 9 are used exactly once without repetition.


Output for ascending order and descending order?

Example 7, 30, 11, 27, 9, 16,Ascending Order = 7, 9, 11, 16, 27, 30 ( You simply arrange the number from lowest to highest number )Descending Order = 30, 27, 16, 11, 9, 7 ( You simply arrange the number from highest to lowest number )


How do you arrange the numbers 7 9 56 and 72?

To arrange the numbers 7, 9, 56, and 72 in ascending order, you would start by comparing the numbers from left to right. The smallest number is 7, followed by 9, then 56, and finally 72. So, the numbers arranged in ascending order would be 7, 9, 56, and 72.