Explain Working Logic Code Written C Language Q37165230

void func(char *p) if( *p-=-10) else printf(%c,(p-1)); return; func(p+2): void main (void) char s[)-Karachi; func(s);

Explain the working logic of this code written in Clanguage.

void func(char *p) if( *p-=-10′) else printf(“%c”,”(p-1)); return; func(p+2): void main (void) char s[)-“Karachi”; func(s); Show transcribed image text void func(char *p) if( *p-=-10′) else printf(“%c”,”(p-1)); return; func(p+2): void main (void) char s[)-“Karachi”; func(s);


Answer


#include <stdio.h>

void func(char *p){

if(*p==”) //if the input is empty, just return

return;

else

func(p+2); //if the input pointer in not null, then recursivelycall with pointer moved to next 2 positions

printf(“%c”,*(p-1)); //print the immediate previous character ofthe passed input (referenced

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.