Question: Can you write a code for void swapEvensOnly(char *s3) ( Using C language ) #include #include #include typedef unsigned int ui; //

Can you write a code for 

void swapEvensOnly(char *s3)

( Using C language )

 

#include

#include

#include

 

typedef unsigned int ui;

 

// function prototypes:

void replaceAtDotWithUnderscores(char *s1);

ui howManyNonVowelAlphas(const char *s2);

void swapEvensOnly(char *s3);

 

int main( ) {

   int i;

   ui rv;

 

   char words1[4][31] = { "..l@host.domain", "@@..", "no changes here!", "What@Me@Worry?" };

   char words2[3][81] = { "123-xyz", "This is PRG355@SENECA", "a e i o u???" };

   char images[3][31] = { "123456789", "hello world", "six" };

 

   for(i=0; i<4; i++) {

      replaceAtDotWithUnderscores(words1[i]);

      printf("'%s'\n", words1[i]);

   }

   for(i=0; i<3; i++) {

      rv = howManyNonVowelAlphas(words2[i]);

      printf("%u\n", rv);

   }

   for(i=0; i<3; i++) {

      swapEvensOnly(images[i]);

      printf("%s\n", images[i]);

   }

 

   return 0;

}

 

 

 

void replaceAtDotWithUnderscores(char *s1) {

 

  // your code here ...

}

 

ui howManyNonVowelAlphas(const char *s2) {

 

  // your code here ...

}

 

void swapEvensOnly(char *s3) {

 

  // your code here ...

}

 

=======================================

 

Requires below

 

 

Q3. Write a C function with the following prototype:

void swapEvensOnly(char *s3)

that accepts a string 's3' containing at least 3 characters such that the

string will always have a length that is an odd number and reverses the

order of ONLY the characters in the string with even numbered indexes as follows:

First character is replaced by the last character, third character is replaced by

the third last character, etc.

 

For example,

original string:                               altered string:

 

"123456789"                                    "927456381"

"hello world"                                  "derlw oollh"

"six"                                                   "xis"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!