Ticker

6/recent/ticker-posts

CPNM LAB PROGRAM-5

cpnm lab 5 programming made by ece the wonders ***THANK YOU***     
----------------------------------------------
5. Write a program, which generates 100 random real numbers in the range of 10.0 to 20.0, and sort them in descending order. 
-------------------------------------------
PROGRAM  :-


  #include <stdio.h>
  #include <float.h>
  #include <stdlib.h>


  void main()

  {

   int i,j,temp;

   float a[100];

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

  {
     do 
     
     {  a[i]=1+rand()%99;  }
  
     while(a[i]<10.0 || a[i]>20.0); 
     
      }
     
     printf("The generated random numbers is :\n");
     printf("=================================\n");
 
      
      for(i=0;i<100;i++)
 
    {  
       printf("%.2f\t",a[i]);
     }

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

   {  for(j=i+1;j<100;j++)
      
     {  if (a[i]<a[j])

       { temp=a[i];
         a[i]=a[j];
         a[j]=temp;
        }
      }
    }
 
  printf("\nThe generated random numbers in desending order is :\n");
  printf("======================================================\n");
 
  for(i=0;i<100;i++)

  {  
    printf("%.2f\t",a[i]);
  }
  printf("\n------------------------------------------------------");
  printf("\nthis code created by ECE THE WONDERS , HEMU THE SMART");
  }


 OUTPUT :-
   


 -:DON'T TRY TO COPY AND PASTE THE CODE SELECTION OF CODE IS DISABLED:-

Post a Comment

0 Comments