Question
Read the given program written in C language below. Understand what the program performed. #include int main() { char str[100]; int i, words; /* Input
Read the given program written in C language below. Understand what the program performed.
#include
int main() {
char str[100];
int i, words;
/* Input string from user */
printf("Enter any string: ");
gets(str);
i = 0;
words = 1;
/* Runs a loop till end of string */
while(str[i] != '\0') {
if((str[i]==' ') && (str[i+1]!=' '))
words++;
i++;
}
printf("Total number of words = %d", words);
return 0;
}
Next, complete the following tasks:
- Write a program using Java program (with OOP)
- Compare and contrast between the 2 programming structure. Write a comparison report that shows the differences and similarities.
You may use the following table to organize your report:
| ||
| ||
| ||
Criteria | Java Solution | C Solution |
|
|
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started