Lisa b

Lisa b

  • NA
  • 31
  • 16.2k

Write C programs of theses questions.

Jun 4 2013 9:36 PM
Write a C program that reads in two words and prints them out in alphabetical order.  Assume that the function strcmp is not available and so do not use strcmp in your program.
 
When your program runs, the screen must look something like this:
 
Enter the first word: MONKEY Enter the second word: kangaroo
 
The words in alphabetical order are: kangaroo, MONKEY
 
*** Warning: notice that kangaroo is in small letters and MONKEY is in capital letters.



3.  Write a C program that reads in some positive integer numbers.  You do not
 
know how many numbers there are, so enter -1 to stop reading numbers. Display the numbers in ascending order.  Then read another number and display all the numbers again with the new number in the correct position. When your program runs, the screen must look something like this:
Enter some numbers (-1 to stop):
82
4
16
55
-1
The numbers in ascending order are:
4  16  55  82
 
Enter another number: 39

The numbers in ascending order are:
4  16  39  55  82

 
4.  There is a file called workers.txt which contains data about the employees in a business.  Each line in the file contains surname, first name and age.
As an example, one line in the file looks like this:
 
Baggins, Bilbo, 60
 
Write a C program that reads all the data from the file and displays a list of years when each person will retire.  When you read the data from the file, it must be loaded into an appropriate structure.
 
When your program runs, the screen must look something like this:
 
List of retirement years: Peters, Winston retires in 2039
Baggins, Bilbo retires in 2015
Dickens, Charles retires in 2023
 
Notes:
 
1.  People retire when they are 65
 
2.  Assume that the current year is 2010
 
3.  You do not know how many lines there are in the file
 
4.  The names and years in the final display are not sorted in any way




Answers (3)