SlideShare a Scribd company logo
1 of 7
Programming in C
Objectives


                In this session, you will do the practice questions of Chapter
                4 and Chapter 5.




     Ver. 1.0                                                          Slide 1 of 7
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.




     Ver. 1.0                                                             Slide 2 of 7
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.



     Ver. 1.0                                                            Slide 3 of 7
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).




     Ver. 1.0                                                        Slide 4 of 7
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




     Ver. 1.0                                                                   Slide 5 of 7
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.




     Ver. 1.0                                                            Slide 6 of 7
Programming in C
Chapter 5 (Contd.)


                The contents of func.c are as follows:




                                   Microsoft Word
                                      Document




     Ver. 1.0                                            Slide 7 of 7

More Related Content

What's hot

Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
lotlot
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 

What's hot (19)

Notes part5
Notes part5Notes part5
Notes part5
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
 
C programming session5
C programming  session5C programming  session5
C programming session5
 
Chapter 2(1)
Chapter 2(1)Chapter 2(1)
Chapter 2(1)
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Csc 130 class 2 problem analysis and flow charts(2)
Csc 130 class 2   problem analysis and flow charts(2)Csc 130 class 2   problem analysis and flow charts(2)
Csc 130 class 2 problem analysis and flow charts(2)
 
Chapter 3(1)
Chapter 3(1)Chapter 3(1)
Chapter 3(1)
 
Ppt lesson 06
Ppt lesson 06Ppt lesson 06
Ppt lesson 06
 
Algorithm and flowchart2010
Algorithm and flowchart2010Algorithm and flowchart2010
Algorithm and flowchart2010
 
C programming first_session
C programming first_sessionC programming first_session
C programming first_session
 
Software develop....
Software develop.... Software develop....
Software develop....
 
C programming session6
C programming  session6C programming  session6
C programming session6
 
Programming flowcharts for C Language
Programming flowcharts for C LanguageProgramming flowcharts for C Language
Programming flowcharts for C Language
 
Modular programming in qbasic
Modular programming in qbasicModular programming in qbasic
Modular programming in qbasic
 

Viewers also liked

How does your media product represent particular social
How does your media product represent particular socialHow does your media product represent particular social
How does your media product represent particular social
hannahata2012
 
Research and planning March
Research and planning  March Research and planning  March
Research and planning March
hannahata2012
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
AjayBahoriya
 
C programming session 16
C programming session 16C programming session 16
C programming session 16
AjayBahoriya
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
AjayBahoriya
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
AjayBahoriya
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
AjayBahoriya
 

Viewers also liked (7)

How does your media product represent particular social
How does your media product represent particular socialHow does your media product represent particular social
How does your media product represent particular social
 
Research and planning March
Research and planning  March Research and planning  March
Research and planning March
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
C programming session 16
C programming session 16C programming session 16
C programming session 16
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
C programming session 11
C programming session 11C programming session 11
C programming session 11
 
C programming session 07
C programming session 07C programming session 07
C programming session 07
 

Similar to C programming session 10

C programming session 07
C programming session 07C programming session 07
C programming session 07
Dushmanta Nath
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
Vivek Singh
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
Vivek Singh
 
Refinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami OlusegunRefinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami Olusegun
Engr. Adefami Segun, MNSE
 
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docx
ELE2303 Assign 1  Page  1 ELE2303 Embedded Systems Design.docxELE2303 Assign 1  Page  1 ELE2303 Embedded Systems Design.docx
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docx
jack60216
 

Similar to C programming session 10 (20)

C programming session 07
C programming session 07C programming session 07
C programming session 07
 
Book management system
Book management systemBook management system
Book management system
 
C tutorials
C tutorialsC tutorials
C tutorials
 
C programming session 08
C programming session 08C programming session 08
C programming session 08
 
A tutorial on C++ Programming
A tutorial on C++ ProgrammingA tutorial on C++ Programming
A tutorial on C++ Programming
 
What is algorithm
What is algorithmWhat is algorithm
What is algorithm
 
C programming session 01
C programming session 01C programming session 01
C programming session 01
 
Basic construction of c
Basic construction of cBasic construction of c
Basic construction of c
 
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTTC programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
C programming notes BATRACOMPUTER CENTRE IN Ambala CANTT
 
Refinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami OlusegunRefinery Blending Problems by Engr. Adefami Olusegun
Refinery Blending Problems by Engr. Adefami Olusegun
 
P3
P3P3
P3
 
cscript_controller.pdf
cscript_controller.pdfcscript_controller.pdf
cscript_controller.pdf
 
Bcsl 031 solve assignment
Bcsl 031 solve assignmentBcsl 031 solve assignment
Bcsl 031 solve assignment
 
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docx
ELE2303 Assign 1  Page  1 ELE2303 Embedded Systems Design.docxELE2303 Assign 1  Page  1 ELE2303 Embedded Systems Design.docx
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docx
 
OVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAMOVERVIEW OF ‘C’ PROGRAM
OVERVIEW OF ‘C’ PROGRAM
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 
Matopt
MatoptMatopt
Matopt
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Contact management system
Contact management systemContact management system
Contact management system
 

Recently uploaded

Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 

C programming session 10

  • 1. Programming in C Objectives In this session, you will do the practice questions of Chapter 4 and Chapter 5. Ver. 1.0 Slide 1 of 7
  • 2. 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. Ver. 1.0 Slide 2 of 7
  • 3. 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. Ver. 1.0 Slide 3 of 7
  • 4. 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). Ver. 1.0 Slide 4 of 7
  • 5. 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 Ver. 1.0 Slide 5 of 7
  • 6. 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. Ver. 1.0 Slide 6 of 7
  • 7. Programming in C Chapter 5 (Contd.) The contents of func.c are as follows: Microsoft Word Document Ver. 1.0 Slide 7 of 7

Editor's Notes

  1. Begin the session by explaining the objectives of the session.