Sample input file Dhahran is about four hundred kilometers from Riyadh and

Sample input file dhahran is about four hundred

This preview shows page 9 - 11 out of 11 pages.

Sample input file: Dhahran is about four hundred kilometers from Riyadh and about one thousand two hundred kilometers from Jeddah Sample output file if a is the character read from the user: word frequency of a Dhahran 2 is 0 about 1 9
Image of page 9
four 0 hundred 0 kilometers 0 from 0 Riyadh 1 and 1 about 1 one 0 thousand 1 two 0 hundred 0 kilometers 0 from 0 Jeddah 1 Part of the program is written below. You need to complete it. Use fscanf to read the words from the input file since they are separated by white space characters only. #include <stdio.h> #include <stdlib.h> int getFrequency(char word[], char ch); int main(void){ FILE *inptr, *outptr; inptr = fopen("input.txt", "r"); if(inptr == NULL){ printf("Error in opening input.txt\n"); exit(1); } outptr = fopen("output.txt", "w"); char ch, word[30]; int count; Task 3:A word is a palindrome if it reads the same forwards and backwords. For example, each of the followingwords is a palindrome: rotator, rotor, radar, level, noon, tenet, SMS, dad, madam, 202, pop. Whereas each ofthe following words is not a palindrome: school, apple, student, 103.Write a C program that prompts for and reads a word, in which all the letters are of the same case, it thenpasses this word to isPalindromeboolean function (a function that return true (1) or false (0)). The functiondetermines whether the word is a palindrome or not. Your main function then prints an appropriate message.Assume that a word does not have more than10 characters. Sample program runs: 10
Image of page 10
11
Image of page 11

You've reached the end of your free preview.

Want to read all 11 pages?

  • Summer '14
  • Darwish
  • ASCII

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture