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

Assignment Help:

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

 

 


Related Discussions:- C program for exchange first & last character

Luminous Jewels, Jewels can only be removed for polishing from either end o...

Jewels can only be removed for polishing from either end of the necklace

What are the two steps that happen while i say delete p?, A: N delete p is ...

A: N delete p is a two-step procedure: it calls the destructor, and then releases the memory. The code developed for delete p is functionally similar to this (supposing p is of typ

Subrotine assembly language, You have to write a subroutine (assembly langu...

You have to write a subroutine (assembly language code using NASM) for the following equation.

C program for bubble sort, C program for bubble sort: void main() {...

C program for bubble sort: void main() { int i,j,k,a[10],n; clrscr(); printf("How many values you want to enter\n"); scanf("%d",&n);  for(i=0;i  {  pri

Creating shopping carts, how to create a shopping cart and sibmit the code ...

how to create a shopping cart and sibmit the code segment on screan

Program of conversion from basic to user-defined variable, Conversion from ...

Conversion from Basic to User-Defined variable Consider the following example. class Distance                  {                   public  :

Control structures in cpp, Control structures The control structures app...

Control structures The control structures appear in both structured programming languages as well as object oriented programming languages.  The three constructs used are: i)

Determine the size of an interger data type without using , Determine the s...

Determine the size of an interger data type without using sizeof() function? A: #include int main() { int *i ; int *j = i + 1; cout }

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd