What does the following program print? - C String

C examples for String:char array

Description

What does the following program print?

Demo Code


#include <stdio.h> 

int main(void) { 
    char str1[] = "test ";
    char str2[] = " from book2s.com "; 
    char *ps; //from   w  w  w .  ja v a 2  s .c o  m
    int i = 0; 
 
    for (ps = str1; *ps != '\0'; ps++) { 
         if ( *ps == 'a' || *ps == 'e') 
                putchar(*ps); 
         else 
                (*ps)--; 
         putchar(*ps); 
    } 
    
    putchar('\n'); 
    
    while (str2[i] != '\0' ) { 
       printf("%c", i % 3 ? str2[i] : '*'); 
       ++i; 
    } 
    return 0; 
}

Result


Related Tutorials