C Program to Print Entered Alphabets in Descending Order based on ASCII Codes, Study Guides, Projects, Research of Java Programming

A c program that takes user input of five alphabets and prints them in descending order based on their ascii codes. The program uses an array to store the entered characters and two nested for loops to compare and swap the characters if they are in the wrong order.

Typology: Study Guides, Projects, Research

2017/2018

Uploaded on 10/18/2018

hassam-badar
hassam-badar 🇵🇰

6 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TASK:11
OBJECTIVE:
Write a C program that will print the entered alphabets in their descending
order by using their ASCII codes.
SOURCE CODE:
//Name:Syed Hassam Badar
//Section:B
//Form No:EL-042-2018
#include<conio.h>
#include<stdio.h>
void main(void)
{
clrscr();
char arr[5],temp;
int a,b;
for(a=0;a<=4;a++)
{
printf("\nEnter the Letter=");
arr[a]=getche();
}
for(a=0;a<=4;a++)
{
for(b=a+1;b<=4;b++)
{
if(arr[a]<arr[b])
{
temp=arr[a];
arr[a]=arr[b];
arr[b]=temp;
}
}
}
printf("\nThe descending order is");
for(a=0;a<=4;a++)
{
printf("\n%c",arr[a]);
}
getche();
}
OUTPUT:

Partial preview of the text

Download C Program to Print Entered Alphabets in Descending Order based on ASCII Codes and more Study Guides, Projects, Research Java Programming in PDF only on Docsity!

TASK:

OBJECTIVE:

Write a C program that will print the entered alphabets in their descending order by using their ASCII codes.

SOURCE CODE:

//Name:Syed Hassam Badar //Section:B //Form No:EL-042- #include<conio.h> #include<stdio.h> void main(void) { clrscr(); char arr[5],temp; int a,b; for(a=0;a<=4;a++) { printf("\nEnter the Letter="); arr[a]=getche(); } for(a=0;a<=4;a++) { for(b=a+1;b<=4;b++) { if(arr[a]<arr[b]) { temp=arr[a]; arr[a]=arr[b]; arr[b]=temp; } } } printf("\nThe descending order is"); for(a=0;a<=4;a++) { printf("\n%c",arr[a]); } getche(); }

OUTPUT: