C programming session 10

183 views

Published on

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
183
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Begin the session by explaining the objectives of the session.
  • C programming session 10

    1. 1. Slide 1 of 7Ver. 1.0 Programming in C In this session, you will do the practice questions of Chapter 4 and Chapter 5. Objectives
    2. 2. Slide 2 of 7Ver. 1.0 Programming in C Chapter 4 1. Modify the program that determines the length of a string so that it allows input of the string from the user and displays its length. (Maximum size of the input string is 80). 2. Modify the string comparison program so that it allows input of strings and reports on whether they are the same or not.
    3. 3. Slide 3 of 7Ver. 1.0 Programming in C Chapter 4 (Contd.) 3. A program can be easily understood if it is indented properly. This has one drawback, in terms of the size of the program on the disk. One simple way of cutting down the size significantly is described here. Assume the following piece of code: 123456789012345678901234567890 (indicates column) printf("This is the last straw"); The 15 blanks at the start of the line can be replaced by the number 15 so that the line of code is now: 123456789012345678901234567890 (indicates column) 15printf("This is the last straw"); Note that a saving of 13 bytes (15 - 2) has been accomplished at one shot.
    4. 4. Slide 4 of 7Ver. 1.0 Programming in C Chapter 4 (Contd.) Write a program, which takes in a line of code from the user (maximum length of 80 characters) and prints out the condensed string (with the number of spaces occupying the first two characters in the condensed string).
    5. 5. Slide 5 of 7Ver. 1.0 Programming in C Chapter 5 1. Alcatel Automatics is a company known for its marketing success. This success has been largely due to its superb data analysis programs. The product manager wants some modifications to the existing programs. When running the program, he should be able to specify any of the following with the run command itself: %s: for displaying the product sales by each salesman as a percentage of the total salesman sales. %p: for displaying the product sales by each salesman as a percentage of the total product sales. %i: for displaying the product sales as an index of total sales of all products
    6. 6. Slide 6 of 7Ver. 1.0 Programming in C Chapter 5 (Contd.) He should also be shown some help message to assist him in case he forgets what to specify with the command and should then be able to give the command again. Since the calculations will be coded in separate functions, which are stored together in one file called func.c, separate from the main() function. The function available in this file are: intdat(): Displays the data as an index of total sales. proddata(): Displays the data as a percentage of total product sales. calcprodtot(): Calculates the salesman-wise totals.
    7. 7. Slide 7 of 7Ver. 1.0 Programming in C Chapter 5 (Contd.) The contents of func.c are as follows: Microsoft Word Document

    ×