Function printYesOrNo - CTS Pattern

 Coding Problem Keys 

 CTS Pattern 

 Function printYesOrNo 

 Problem Statement 

You can click on Run anytime to check the compilation/execution status of the program. You can use printf to debug your code. The submitted code should be logically/ syntactically correct and pass all test cases. Do not write the main() function as it is not required.

Code Approach: For this question, you will need to implement the logic for the program.

The function printYesOrNo (char ch) accepts a character ch as the input. The function is supposed to print "Yes" if the value of ch is 'Y' or 'y'. Else print "No" if the value of ch is 'N' or 'n'. Else the function printYesOrNo() prints "Invalid".

Your task is to fill in the missing lines of code so that the program passes all test cases.

 Max Execution Time Limit: 5000 millisecs 

 Given Code 

void printYesOrNo(char ch)
{
    
}

 Solution 

 Programming Language: C Language 

void printYesOrNo(char ch){
    ch=tolower();
    if(ch=='y'){printf("Yes");}
    else if(ch=='n'){printf("No");}
    else{printf("Invalid");}
}

// Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

String - Special Characters

Left Right Top Bottom Sum

Alphabetical Order Pattern

Iterate Base

Value Equals Previous Two

RAT CHEESE MAZE