C program for exchange first & last character, C/C++ Programming

void main()

{

          int i=0,k=0,word=0;

          char a[30],temp;

          clrscr();

          printf("ENTER THE STRING: ");

          do

          {

                   a[i++]=getchar();

           }while(a[i-1]!='\n');

          a[i]='\0';

          printf("%s",a);

          for(i=0;a[i]!='\0';i++)

          {

 

                   if(a[i]==' ' || a[i]=='\n')

                   {

                             word++;

                             temp=a[k];

                             a[k]=a[i-1];

                             a[i-1]=temp;

                             k=i+1;

                   }

          }

          printf("%s",a);

          if(word%2==0)

                    printf("\nNO OF WORDS ARE %d",word);

          getch();

}


OUTPUT

-ENTER THE STRING: KAMLESH

AMLESHK

MLESHKA

LESHKAM

ESHKAML

SHKAMLE

HKAMLES

KAMLESH

 

 

Posted Date: 9/10/2012 2:57:22 AM | Location : United States







Related Discussions:- C program for exchange first & last character, Assignment Help, Ask Question on C program for exchange first & last character, Get Answer, Expert's Help, C program for exchange first & last character Discussions

Write discussion on C program for exchange first & last character
Your posts are moderated
Related Questions
what is a variable

Friend Functions One of the major features of OOP is information hiding. A class encapsulates data and methods to operate on that data in a single unit. The data from the class


Implement, in rPeANUt, the a Fibonacci function by using the simple recursive approach. The Fibonacci function can be implemented in c as follow: int fib(int x) {   if (x

What is Namespace and Explicit container Namespace - Namespaces are used to group entities such as objects, classes and functions under a name. Explicit container.

i need a program for finding the last fibonacci number

Write a fully modular C program that reads in a string of a defined size from the keyboard and reports how many times each letter of the alphabet occurs within that string (ignorin

how to create a flowchart? can you help me in my assignment about flowcharting ....

Spider webs have two types of silk, sticky silk and strength silk, spiders do not move on the sticky silken threads only on the strength threads. Assume one type of spider creates

Design a game in c: const DODGERS = 0; const GIANTS = 1;   void main(void) {    int scoreboard [2][9];    // An array two rows by nine columns    int team, i