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:

  1. Write a program using Java program (with OOP)
  2. 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:

  1. Java code:

  1. Comparison Report: Java Solution and C Solution

Criteria

Java Solution

C Solution

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!