Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main() {
- char str[30];
- int i = 0;
- int cc = 0;
- int ac = 0;
- int wc = 1;
- int ssc = 0;
- int dc = 0;
- int nl = 1;
- printf("print a paragraph at the end press #:");
- scanf(" %[^#]",str);
- while (str[i] != '\0') {
- if (str[i] >= 65 && str[i] <= 91 || str[i] >= 97 && str[i] <= 123) {
- ac++;
- cc++;
- }
- else if (str[i] >= 40 && str[i] <= 49) {
- dc++;
- cc++;
- }
- else if (str[i] == ' ') {
- wc++;
- cc++;
- }
- else if (str[i] == '\n') {
- nl++;
- cc++;
- wc++;
- }
- else {
- ssc++;
- cc++;
- }
- i++;
- }
- printf(" i = %d\n wc = %d\n ssc = %d\n dc = %d\n ac = %d\n cc = %d\n nl = %d\n",i ,wc ,ssc ,dc ,ac ,cc ,nl);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement