Please Answer with C code including C function. Will rate! Thanks
Write a C function that takes as parameter a character and uses
the switch statement to return
the same character if it is 'a', 'b' or 'c', otherwise the
character 'z'. Write a C program that reads
a character, calls the function, and displays the return value.
ANSWER:
#include <stdio.h>
//function declaration
char callFunction(char ch);
int main()
{
//Declaring variables
char ch,ret;
//Getting the input entered by the user
printf("Enter a Character :");
scanf(" %c",&ch);
//calling the function
ret=callFunction(ch);
//Displaying the returned value
printf("Returned Character :%c\n",ret);
return 0;
}
/* This function takes the character as input and
* returned a character based on the input character
*/
char callFunction(char ch)
{
char ret;
switch(ch)
{
case 'a':
case 'b':
case 'c':{
ret=ch;
break;
}
default:{
ret='z';
break;
}
}
return ret;
}
Please Answer with C code including C function. Will rate! Thanks Write a C function that...