In function ‘main’: cntwlc.c:20:2: error: parameter ‘num_lines’ is initialized   int num_lines = 0, num_words = 0, num_chars = 0, num_alpha = 0, num_digits = 0, num_special = 0;   ^ cntwlc.c:20:2: error: parameter ‘num_words’ is initialized cntwlc.c:20:2: error: parameter ‘num_chars’ is initialized cntwlc.c:20:2: error: parameter ‘num_alpha’ is initialized cntwlc.c:20:2: error: parameter ‘num_digits’ is initialized cntwlc.c:20:2: error: parameter ‘num_special’ is initialized cntwlc.c:21:2: error: expected declaration specifiers before ‘printf’   printf("Welcome to cntwlc the CIS158 version of the word count.\n\n");   ^ cntwlc.c:22:2: error: expected declaration specifiers before ‘printf’   printf("This program will produce statistics about the text entered from standard in.\n\n");   ^ cntwlc.c:23:2: error: expected declaration specifiers before ‘printf’   printf("Please enter your text now. When finished enter a control d to end,\n\n");   ^ cntwlc.c:24:2: error: expected declaration specifiers before ‘printf’   printf("--\nText Statistics:\n\n");   ^ cntwlc.c:25:2: error: expected declaration specifiers before ‘While’   While (fgets(line, MAX_LINE, stdin))   ^ cntwlc.c:52:2: error: expected declaration specifiers before ‘printf’   printf("Lines\n%d\n\n", num_lines-1);   ^ cntwlc.c:53:2: error: expected declaration specifiers before ‘printf’   printf("Words\n%d\n\n", num_words);   ^ cntwlc.c:54:2: error: expected declaration specifiers before ‘printf’   printf("Characters\n%d\n", num_chars-1);   ^ cntwlc.c:55:2: error: expected declaration specifiers before ‘printf’   printf("Alphabetic\n%d\n", num_alpha);   ^ cntwlc.c:56:2: error: expected declaration specifiers before ‘printf’   printf("Digits\n%d\n", num_digits);   ^ cntwlc.c:57:2: error: expected declaration specifiers before ‘printf’   printf("Special\n%d\n\n", num_special);   ^ cntwlc.c:58:2: error: expected declaration specifiers before ‘printf’   printf("Thank you for using cntwlc. Bye!\n");   ^ cntwlc.c:59:2: error: expected declaration specifiers before ‘return’   return 0;   ^ cntwlc.c:60:2: error: expected declaration specifiers before ‘}’ token   }   ^ cntwlc.c:17:5: error: old-style parameter declarations in prototyped function definition  int main(void)      ^ cntwlc.c:60:2: error: expected ‘{’ at end of input   }   ^ CODE THAT NEEDS CORRECTION:          #include #include #define MAX_LINE 1000 int main(void)         char line[MAX_LINE];         int num_lines = 0, num_words = 0, num_chars = 0, num_alpha = 0, num_digits = 0, num_special = 0;        printf("Welcome to cntwlc the CIS158 version of the word count.\n\n");         printf("This program will produce statistics about the text entered from standard in.\n\n");         printf("Please enter your text now. When finished enter a control d to end,\n\n");         printf("--\nText Statistics:\n\n");         While (fgets(line, MAX_LINE, stdin))         {         num_lines++;         int in_word = 0;         for (int i = 0; line[i] != '\0'; i++)         {         if (isspace(line[i]))         {         in_word = 0;         } else{         if (!in_word)         {         num_words++;         in_word = 1;     }         if (isalpha(line[i]))         {         num_aplha++;         } else if (isdigit(line[i])){         num_digits++;         } else if (!isspace(line[i])) {         num_special++;         }         }         num_chars++;         }         }         printf("Lines\n%d\n\n", num_lines-1);         printf("Words\n%d\n\n", num_words);         printf("Characters\n%d\n", num_chars-1);         printf("Alphabetic\n%d\n", num_alpha);         printf("Digits\n%d\n", num_digits);         printf("Special\n%d\n\n", num_special);         printf("Thank you for using cntwlc. Bye!\n");         return 0;         } Example of Output [s158a00@cisweb ex0]$ cntwlc

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can someone help me fix and correct this C program .It fails to compile and run .Ive tried everything .It is supposed to come out exactly like the example output.I keep geting these error codes during compilation.

ERRORS GIVEN DURING COMPILATION:

 In function ‘main’:
cntwlc.c:20:2: error: parameter ‘num_lines’ is initialized
  int num_lines = 0, num_words = 0, num_chars = 0, num_alpha = 0, num_digits = 0, num_special = 0;
  ^
cntwlc.c:20:2: error: parameter ‘num_words’ is initialized
cntwlc.c:20:2: error: parameter ‘num_chars’ is initialized
cntwlc.c:20:2: error: parameter ‘num_alpha’ is initialized
cntwlc.c:20:2: error: parameter ‘num_digits’ is initialized
cntwlc.c:20:2: error: parameter ‘num_special’ is initialized
cntwlc.c:21:2: error: expected declaration specifiers before ‘printf’
  printf("Welcome to cntwlc the CIS158 version of the word count.\n\n");
  ^
cntwlc.c:22:2: error: expected declaration specifiers before ‘printf’
  printf("This program will produce statistics about the text entered from standard in.\n\n");
  ^
cntwlc.c:23:2: error: expected declaration specifiers before ‘printf’
  printf("Please enter your text now. When finished enter a control d to end,\n\n");
  ^
cntwlc.c:24:2: error: expected declaration specifiers before ‘printf’
  printf("--\nText Statistics:\n\n");
  ^
cntwlc.c:25:2: error: expected declaration specifiers before ‘While’
  While (fgets(line, MAX_LINE, stdin))
  ^
cntwlc.c:52:2: error: expected declaration specifiers before ‘printf’
  printf("Lines\n%d\n\n", num_lines-1);
  ^
cntwlc.c:53:2: error: expected declaration specifiers before ‘printf’
  printf("Words\n%d\n\n", num_words);
  ^
cntwlc.c:54:2: error: expected declaration specifiers before ‘printf’
  printf("Characters\n%d\n", num_chars-1);
  ^
cntwlc.c:55:2: error: expected declaration specifiers before ‘printf’
  printf("Alphabetic\n%d\n", num_alpha);
  ^
cntwlc.c:56:2: error: expected declaration specifiers before ‘printf’
  printf("Digits\n%d\n", num_digits);
  ^
cntwlc.c:57:2: error: expected declaration specifiers before ‘printf’
  printf("Special\n%d\n\n", num_special);
  ^
cntwlc.c:58:2: error: expected declaration specifiers before ‘printf’
  printf("Thank you for using cntwlc. Bye!\n");
  ^
cntwlc.c:59:2: error: expected declaration specifiers before ‘return’
  return 0;
  ^
cntwlc.c:60:2: error: expected declaration specifiers before ‘}’ token
  }
  ^
cntwlc.c:17:5: error: old-style parameter declarations in prototyped function definition
 int main(void)
     ^
cntwlc.c:60:2: error: expected ‘{’ at end of input
  }
  ^

CODE THAT NEEDS CORRECTION:

        

#include <stdio.h>
#include <ctype.h>

#define MAX_LINE 1000

int main(void)

        char line[MAX_LINE];
        int num_lines = 0, num_words = 0, num_chars = 0, num_alpha = 0, num_digits = 0, num_special = 0;        printf("Welcome to cntwlc the CIS158 version of the word count.\n\n");
        printf("This program will produce statistics about the text entered from standard in.\n\n");
        printf("Please enter your text now. When finished enter a control d to end,\n\n");
        printf("--\nText Statistics:\n\n");
        While (fgets(line, MAX_LINE, stdin))
        {
        num_lines++;
        int in_word = 0;
        for (int i = 0; line[i] != '\0'; i++)
        {
        if (isspace(line[i]))
        {
        in_word = 0;
        } else{
        if (!in_word)
        {
        num_words++;
        in_word = 1;
 

  }
        if (isalpha(line[i]))
        {
        num_aplha++;
        } else if (isdigit(line[i])){
        num_digits++;
        } else if (!isspace(line[i])) {
        num_special++;
        }
        }
        num_chars++;
        }
        }
        printf("Lines\n%d\n\n", num_lines-1);
        printf("Words\n%d\n\n", num_words);
        printf("Characters\n%d\n", num_chars-1);
        printf("Alphabetic\n%d\n", num_alpha);
        printf("Digits\n%d\n", num_digits);
        printf("Special\n%d\n\n", num_special);
        printf("Thank you for using cntwlc. Bye!\n");
        return 0;
        }

Example of Output
[s158a00@cisweb ex0]$ cntwlc <testFile
Welcome to cntwlc the CIS158 version of word count.
This program will produce statistics about the text entered from standard
in.
Please enter your text now. When finished enter a control D to end.
--- Text Statistics: ---
Lines 5
Words 37
Characters 188
Alphabetic 139
Digits 3
Special 9
Thank you for using cntwlc. Bye! 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY