C examples for Statement:if
Replaces each exclamation mark initially present with two exclamation marks, and reports at the end the number of substitutions it has made.
#include <stdio.h> #define STOP '#'// w w w .java2 s . c o m int main(void){ char ch; printf("Enter input (%c to exit):\n", STOP); while ((ch = getchar()) != STOP){ if (ch == '.') printf("!"); else if (ch == '!') printf("!!"); else printf("%c", ch); } return 0; }