**However, there are multiple errors in the given C program. Please correct complier errors and use gdb to debug the program and find out the errors.*** Question: Please write down the line numbers containing the errors and show how to correct them. (Note: you do not need to write down the commands you issued in gdb.) Part 2: You are given a C program "q2.c" as below. This program is used to calculate the average word length for a sentence (a string in a single line): Enter a sentence: It was deja vu all over again. Average word length: 3.4 For simplicity, the program considers a punctuation mark to be part of the word to which it is attached. And it displays the aveage word length to one decimal place. #include 3 int main (){ 5 int letters: int words: char character: 7 9 printf("Enter a Sentence: "); 10 11 12 while ( (character=getchar ()) != \n) { if (character != ' '){ ww 13 14 ifl'apace) { words++; 15 16 17 sрасе-1; } letters++; lelse space = 0; 18 19 20 21 printf("Average word length : $.1f", letters/words); 23 24 return 0; 25 } Ai2 N22 22
**However, there are multiple errors in the given C program. Please correct complier errors and use gdb to debug the program and find out the errors.*** Question: Please write down the line numbers containing the errors and show how to correct them. (Note: you do not need to write down the commands you issued in gdb.) Part 2: You are given a C program "q2.c" as below. This program is used to calculate the average word length for a sentence (a string in a single line): Enter a sentence: It was deja vu all over again. Average word length: 3.4 For simplicity, the program considers a punctuation mark to be part of the word to which it is attached. And it displays the aveage word length to one decimal place. #include 3 int main (){ 5 int letters: int words: char character: 7 9 printf("Enter a Sentence: "); 10 11 12 while ( (character=getchar ()) != \n) { if (character != ' '){ ww 13 14 ifl'apace) { words++; 15 16 17 sрасе-1; } letters++; lelse space = 0; 18 19 20 21 printf("Average word length : $.1f", letters/words); 23 24 return 0; 25 } Ai2 N22 22
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
PLEASE SEE ATTACHMENT. THIS IS FOR SYSTEM-LEVEL

Transcribed Image Text:*However, there are multiple errors in the given C program. Please correct
complier errors and use gdb to debug the program and find out the errors.***
Question: Please write down the line numbers containing the errors and show how
to correct them.
(Note: you do not need to write down the commands you issued in gdb.)
Part 2:
You are given a C program "q2.c" as below. This program is used to calculate the
average word length for a sentence (a string in a single line):
Enter a sentence: It was deja vu all over again.
Average word length: 3.4
For simplicity, the program considers a punctuation mark to be part of the word to
which it is attached. And it displays the aveage word length to one decimal place.
#include <stdio.h>
int main() {
14
.nt lettera:
int words;
char character:
7
printf("Enter a Sentence: ");
10
while ( (character=getchar()) != \n) {
if (character != ' '){
ifllapace) (
words++;
11
www .c
13
14
15
зрасе-1;
16
17
letters++;
18
19
lelse
space = 0;
20
21
}
22
printf("Average word length : $.1f", letters/words);
23
24
return 0;
25
ddd ddD 11 11 222 222
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images

Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education