Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to print entered word in an alphabetical order

Posted By: Betsy Cunningham     Category: C Programming     Views: 11627

Program to print entered word in an alphabetical order

Code for Program to print entered word in an alphabetical order in C Programming

#include <stdio.h>
#include <conio.h>
#include <string.h>
    void main()
    {
        char a[40],t;
        int i,j;
        clrscr();
        printf("\n Enter the String :- ");
        scanf("%s",a);
        for(i=0;a[i]!='\0';i++)
        {
            for(j=i+1;a[j]!='\0';j++)
            {
                if(a[i]>a[j])
                {
                    t=a[i];
                    a[i]=a[j];
                    a[j]=t;
                }
            }
        }
        printf("the alphabet wise is :- %s",a);
        getch();
    }

/*
******
OUTPUT
******


Enter the String : world
the alphabet wise is dlorw
*/
  
Share: 


Didn't find what you were looking for? Find more on Program to print entered word in an alphabetical order Or get search suggestion and latest updates.

Betsy Cunningham
Betsy Cunningham author of Program to print entered word in an alphabetical order is from Chicago, United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Sagar Rastogi from Australia Comment on: Jan 15
I want to make name asending order wise in $product = $globalClass->getRow("product","`id`='".$cat_id[$m]['prod_id']."' AND `status`='1'");
as i ahve used order by name asc not working

<?php

$cat_id = $globalClass->getRow("prod_category","`category`='".$get_cat['id']."'");

for($m = 0; $m<count($cat_id); $m++)

{

$product = $globalClass->getRow("product","`id`='".$cat_id[$m]['prod_id']."' AND `status`='1'");
if(!empty($product[0]['id']))
{
for($k=0; $k<count($product); $k++)

{



?>
get Row is a globalClass
function getRow($table,$condition)



{



$this->connection();



if(!empty($condition))



{



$query = mysql_query("SELECT * FROM `".$table."` where ".$condition) or die(mysql_error());



}



else



{



$query = mysql_query("SELECT * FROM `".$table."`") or die(mysql_error());



}



$id=0;



$multiRow = array(0);



if($row = mysql_fetch_assoc($query))



{



$i=0;



do



{



$multiRow[$i] = $row;



$i =$i+1;



}



while($row = mysql_fetch_assoc($query));



}



else



{



$multiRow = array(0);



}



return $multiRow;



}

View All Comments