Skip to main content

Featured

C Program to display spellings of number 1-10 on entry

C Program to display spellings of number 1-10 on entry.   #include<stdio.h>   void main() { int num; printf("Enter a number between 1-10:"); scanf("%d",&num); printf("\n"); switch (num) { case 1: printf("ONE"); break; case 2: printf("TWO"); break; case 3: printf("THREE"); break; case 4: printf("FOUR"); break; case 5: printf("FIVE"); break; case 6: printf("SIX"); break; case 7: printf("SEVEN"); break; case 8: printf("EIGHT"); break; case 9: printf("NINE"); break; case 10: printf("TEN"); break; default:         printf("THE ENTERED NUMBER IS NOT BETWEEN 1-10"); } } OUTPUTS

C program to sort array elements in descending order.

C program to sort array elements in descending order.


#include<stdio.h>
int main()
{
int array[100],n,c,d,swap;
printf("How many number of elements to be entered? ");
scanf(" %d",&n);
printf("Enter %d integers:\n",n);
for(c=0;c<n;c++)
scanf("%d",&array[c]);

for(c=0;c<n-1;c++)
{
for(d=0;d<n-c-1;d++)
{
if(array[d]<array[d+1])         /*For decreasing order use*/
{
swap=array[d];
array[d]=array[d+1];
array[d+1]=swap;
}
}
}
printf("\nSorted list in decending order:\n");

for(c=0;c<n;c++)
printf("\t%d\n",array[c]);
return 0;
}


           OUTPUTS



Comments