Free Essay

Et 2560 Unit 5 Assignment 1

In:

Submitted By mlopez0831
Words 752
Pages 4
Matthew Lopez
ET2560 Intro to C
Unit 5 assignment 1
Pg. 238
1. Choose an appropriate kind of loop from Table 5.1 for solving each of the following problems.
a. Calculate the sum of the test scores of a class of 35 students. ( Hint: Initialize sum to zero before entering loop.) Endfile- controlled loop
b. Print weekly paychecks for a list of employees. The following data are to be entered interactively for each employee: ID, hours worked, and hourly pay rate. An ID of zero marks the end of the data. Sentinel- controlled loop
c. Process a data file of Celsius temperatures. Count how many are above 100° C. Input validation loop
Pg. 241 – 242
1. Predict the output of this program fragment: i = 0; while ( i <= 5)
{ printf("% 3d % 3d\ n", i, 10 - i); i = i + 1;
}
It will show the numbers that appear before 5 2. What is displayed by this program fragment for an input of 8? scanf("% d", & n); ev = 0; while ( ev < n)
{ printf("% 3d", ev); ev = ev + 2;
} printf("\ n") Show the numbers from 0 to 8 increasing by 2 each time
Pg. 246 – 247
1. What output values are displayed by the following while loop for a data value of 5? Of 6? Of 7? printf(" Enter an integer> "); scanf("% d", & x); product = x; count = 0; while ( count < 4)
{ printf("% d\ n", product); product *= x; count += 1; } No values are output
3. The following segment needs some revision. Insert braces where they are needed and correct the errors. The corrected code should take five integers and display their sum. count = 0; while ( count <= 5) count += 1; printf(" Next number> "); scanf("% d", & next_ num); next_ num += sum; printf("% d numbers were added; \ n", count); printf(" their sum is % d.\ n", sum);

Pg. 255 – 256
1. Write a loop that displays a table of angle measures along with their sine and cosine values. Assume that the initial and final angle measures ( in degrees) are available in init_ degree and final_ degree ( type int variables), and that the change in angle measure between table entries is given by step_ degree ( also a type int variable). Remember that the math library’s sin and cos functions take arguments that are in radians. #include <stdio.h> int main(){ double cosine, sine; double n; printf("Enter the value of n.\n"); scanf("%d",&n); for(count=1;count<=n;++count) //for loop terminates if count>n { sum+=count; /* this statement is equivalent to sum=sum+count */ } printf("Sum=%d",sum); return 0; }

6. What errors do you see in the following fragment? Correct the code so it displays all multiples of 4 from 0 through 100 .
For n = 0 ; n > 0 && n < 100; n = n + 4; printf("% d\ n", n);

Pg. 260
2. Correct the syntax and logic of the code that follows so that it prints all multiples of 4 from 0 through 100: for sum = 0; sum > 0 && sum < 100; sum = + 4; printf("% d\ n", sum);

Pg. 272
1. What is displayed by the following program segments, assuming m is 3 and n is 5?
a. for ( i = 1; i <= n; ++ i)
{ for ( j = 0; j < i; ++ j) { printf("*");
} printf("\ n");
}
b. for ( i = n; i > 0; -- i)
{ for ( j = m; j > 0; -- j) { printf("*");
} printf("\ n"); }

m is 3“*” n is 5 “*”
2. Show the output displayed by these nested loops: for ( i = 0; i < 3; ++ i) { printf(" Outer % 4d\ n", i); for ( j = 0; j < 2; ++ j) { printf(" Inner% 3d% 3d\ n", i, j);
} for ( k = 2; k > 0; -- k) { printf(" Inner% 3d% 3d\ n", i, k); } }

I is an outer 4 digit number that increases by 1
J is an inner two 3 digit number and only j increases by one
K is 2 but is greater than 0 and decreases by 1
Pg. 275
1. Which of the following code segments is a better way to implement a sentinel-controlled loop? Why?

The right side because the loop only continues as long as num doesn’t equal SENT.
Pg. 304
5. Rewrite the program segment that follows, using a for loop:
For (count = 0; i = 0); while ( i < n) { scanf("% d", & x); if ( x == i) ++ count; ++ i; }

6. Rewrite this for loop heading, omitting any invalid semicolons. for ( i = n; i < max; ++ i);

Similar Documents

Free Essay

Physics

...SENIOR SECONDARY COURSE PHYSICS 1 (CORE MODULES) Coordinators Dr. Oum Prakash Sharma Sh. R.S. Dass NATIONAL INSTITUTE OF OPEN SCHOOLING A-25, INSTITUTIONAL AREA, SECTOR-62, NOIDA-201301 (UP) COURSE DESIGN COMMITTEE CHAIRMAN Prof. S.C. Garg Former Pro-Vice Chancellor IGNOU, Maidan Garhi, Delhi MEMBERS Prof. A.R. Verma Former Director, National Physical Laboratory, Delhi, 160, Deepali Enclave Pitampura, Delhi-34 Dr. Naresh Kumar Reader (Rtd.) Deptt. of Physics Hindu College, D.U. Dr. Oum Prakash Sharma Asstt. Director (Academic) NIOS, Delhi Prof. L.S. Kothari Prof. of Physics (Retd.) Delhi University 71, Vaishali, Delhi-11008 Dr. Vajayshree Prof. of Physics IGNOU, Maidan Garhi Delhi Sh. R.S. Dass Vice Principal (Rtd.) BRMVB, Sr. Sec. School Lajpat Nagar, New Delhi-110024 Dr. G.S. Singh Prof. of Physics IIT Roorkee Sh. K.S. Upadhyaya Principal Jawahar Navodaya Vidyalaya Rohilla Mohammadabad (U.P.) Dr. V.B. Bhatia Prof. of Physics (Retd.) Delhi University 215, Sector-21, Faridabad COURSE DEVELOPMENT TEAM CHAIRMAN Prof. S.C. Garg Former Pro-Vice Chancellor IGNOU, Delhi MEMBERS Prof. V.B. Bhatia 215, Sector-21, Faridabad Prof. B.B. Tripathi Prof. of Physics (Retd.), IIT Delhi 9-A, Awadhpuri, Sarvodaya Nagar Lucknow-226016 Sh. K.S. Upadhyaya Principal Navodaya Vidyalaya Rohilla Mohammadabad, (U.P.) Dr. V.P. Shrivastava Reader (Physics) D.E.S.M., NCERT, Delhi EDITORS TEAM CHAIRMAN Prof. S.C. Garg Former Pro-Vice Chancellor IGNOU, Delhi MEMBERS Prof. B.B. Tripathi Prof...

Words: 131353 - Pages: 526

Premium Essay

Nothing

...TELECOMMUNICATION SWITCHING AND NETWORKS TElECOMMUNICATION SWITCHING NffiWRKS AND THIS PAGE IS BLANK Copyright © 2006, 2005 New Age International (P) Ltd., Publishers Published by New Age International (P) Ltd., Publishers All rights reserved. No part of this ebook may be reproduced in any form, by photostat, microfilm, xerography, or any other means, or incorporated into any information retrieval system, electronic or mechanical, without the written permission of the publisher. All inquiries should be emailed to rights@newagepublishers.com ISBN (10) : 81-224-2349-3 ISBN (13) : 978-81-224-2349-5 PUBLISHING FOR ONE WORLD NEW AGE INTERNATIONAL (P) LIMITED, PUBLISHERS 4835/24, Ansari Road, Daryaganj, New Delhi - 110002 Visit us at www.newagepublishers.com PREFACE This text, ‘Telecommunication Switching and Networks’ is intended to serve as a onesemester text for undergraduate course of Information Technology, Electronics and Communication Engineering, and Telecommunication Engineering. This book provides in depth knowledge on telecommunication switching and good background for advanced studies in communication networks. The entire subject is dealt with conceptual treatment and the analytical or mathematical approach is made only to some extent. For best understanding, more diagrams (202) and tables (35) are introduced wherever necessary in each chapter. The telecommunication switching is the fast growing field and enormous research and development are undertaken by...

Words: 115682 - Pages: 463

Free Essay

Hacking the Art of Exploitation

...and explanations of how they work.” —COMPUTER POWER USER (CPU) MAGAZINE “This is an excellent book. Those who are ready to move on to [the next level] should pick this book up and read it thoroughly.” —ABOUT.COM INTERNET/NETWORK SECURITY ® San Francisco HACKING: THE ART OF EXPLOITATION, 2ND EDITION. Copyright © 2008 by Jon Erickson. All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. Printed on recycled paper in the United States of America 11 10 09 08 07 123456789 ISBN-10: 1-59327-144-1 ISBN-13: 978-1-59327-144-2 Publisher: William Pollock Production Editors: Christina Samuell and Megan Dunchak Cover Design: Octopod Studios Developmental Editor: Tyler Ortman Technical Reviewer: Aaron Adams Copyeditors: Dmitry Kirsanov and Megan Dunchak Compositors: Christina Samuell and Kathleen Mish Proofreader: Jim Brook Indexer: Nancy Guenther For information on book distributors or translations, please contact No Starch Press,...

Words: 139438 - Pages: 558

Premium Essay

Essay

...have been made to ensure the quality and accuracy of this publication. JNB Publications assumes no responsibility for any errors or omissions and no warranties are made with regard to this publication. Neither JNB Publications nor any authorised distributors shall be held responsible for any direct, incidental or consequential damages resulting from the use of this publication. To Order this Publication This publication can be ordered in a wire bound format or as an electronic copy for unlimited copying and editing in an RTO. For distribution details, please visit our website at www.jnbweb.com. or email me at johnb@jnbweb.com . Published in Australia by: JNB Publications PO Box 268 Macarthur Square NSW 2560 Australia www.jnbweb.com HLTHIR403C. Work effectively with culturally diverse clients and...

Words: 39856 - Pages: 160

Premium Essay

Computer Science Illuminated

...N E L L D A L E J O H N L E W I S illuminated computer science J O N E S A N D B A RT L E T T C O M P U T E R S C I E N C E computer science illuminated N E L L D A L E J O H N L E W I S computer science illuminated N E L L D A L E J O H N Villanova University L E W I S University of Texas, Austin Jones and Bartlett Publishers is pleased to provide Computer Science Illuminated’s book-specific website. This site offers a variety of resources designed to address multiple learning styles and enhance the learning experience. Goin’ Live This step-by-step HTML Tutorial will guide you from start to finish as you create your own website. With each lesson, you’ll gain experience and confidence working in the HTML language. Online Glossary We’ve made all the key terms used in the text easily accessible to you in this searchable online glossary. The Learning Store Jones and Bartlett Publishers has a wealth of material available to supplement the learning and teaching experience. Students and instructors will find additional resources here or at http://computerscience. jbpub.com The Language Library Here you will find two complete chapters that supplement the book’s language-neutral approach to programming concepts. A JAVA language chapter and C++ language chapter are included and follow the same pedagogical approach as the textbook. http://csilluminated.jbpub.com eLearning Our eLearning center provides chapter-specific...

Words: 67693 - Pages: 271

Premium Essay

Sql Quiz

...Emory University | Internetworking Technology Handbook | [Type the document subtitle] | | SAVIOUR EMMANUEL UDOBONG | [Pick the date] | [Type the abstract of the document here. The abstract is typically a short summary of the contents of the document. Type the abstract of the document here. The abstract is typically a short summary of the contents of the document.] | Internetworking Basics An internetwork is a collection of individual networks, connected by intermediate networking devices, that functions as a single large network. Internetworking refers to the industry, products, and procedures that meet the challenge of creating and administering internetworks. The following articles provide information about internetworking basics: * Internetworking Basics * Introduction to LAN Protocols * Introduction to WAN Technologies * Bridging and Switching Basics * Routing Basics * Network Management Basics * Open System Interconnection Protocols LAN Technologies A LAN is a high-speed data network that covers a relatively small geographic area. It typically connects workstations, personal computers, printers, servers, and other devices. LANs offer computer users many advantages, including shared access to devices and applications, file exchange between connected users, and communication between users via electronic mail and other applications. The following articles provide information different LAN technologies: * Ethernet...

Words: 217433 - Pages: 870

Free Essay

Xxxxxx

...HOW TO Prepare Your Curriculum Vitae Revised Edition Acy L. Jackson and C. Kathleen Geckeis Copyright © 2003 by The McGraw-Hill Companies, Inc. All rights reserved. Manufactured in the United States of America. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher. 0-07-142626-4 The material in this eBook also appears in the print version of this title: 0-07-139044-8 All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps. McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. For more information, please contact George Hoare, Special Sales, at george_hoare@mcgraw-hill.com or (212) 904-4069. TERMS OF USE This is a copyrighted work and The McGraw-Hill Companies, Inc. (“McGraw-Hill”) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve...

Words: 31831 - Pages: 128

Premium Essay

From Pmbok

...Project Management Project and Programme Management Resources for Students Gower have teamed up with a major provider of project management training, ESI International, to bring you a range of project and programme resources to support your learning. Visit www.projectmanagement9.com and: • • • • Download white papers on topics as diverse as the project communication, project leadership, risk management and project troubleshooting. View professional project webinars from some of the leading presenters on project management covering topics such as: risk management, troubled project recovery, portfolio management, business requirements, earned value management, performance-based service contracting. Learn about the qualifications and development available from the PMI, Project Management Institute, the world’s largest non-profit professional association in project management. Link to further resources, professional bodies, news sites and more. These resources are designed to help you develop your learning on project management and start you on the road to professional qualifications or further development, once you have finished your degree or your current qualification. Visit www.projectmanagement9.com Project Management Ninth Edition DENNIS LOCK © Dennis Lock 2007 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise...

Words: 232485 - Pages: 930

Premium Essay

Google

...Deardorff's Glossary of International Economics - A - Above the line |In balance of payments[->0] accounting, this refers to those transactions that are included in calculating the balance of payments surplus[->1] or deficit. Transactions below the line, typically official reserve transactions[->2] and sometimes short term capital flows[->3], are not included. | Absolute advantage |The ability to produce a good at lower cost, in terms of real resources, than another country. In a Ricardian model[->4], cost is in terms of only labor. Absolute advantage is neither necessary nor sufficient for a country to export a good. See comparative advantage[->5]. | Absolute advantage trade policy |The idea, advocated by opponents of globalization[->6], that a country should import only goods in which other countries have an absolute advantage[->7], particularly goods that the importing country cannot (or cannot "reasonably") produce itself. | Absolute Purchasing Power Parity |See purchasing power parity[->8]. | Absorption |Total demand for final goods and services by all residents (consumers, producers, and government) of a country (as opposed to total demand for that country's output). The term was introduced as part of the Absorption Approach[->9]. | Absorption approach |A way of understanding the determinants of the balance of trade, noting that it is equal to income minus absorption. Due to Alexander (1952)[->10] | Abundant |Available in large supply. Usually meaningful...

Words: 122814 - Pages: 492

Premium Essay

Business Management

...SAGE India website gets a makeover! Global Products Enhanced Succinct Intuitive THE Improved Interactive Smart Layout User-friendly Easy Eye-catching LEADING WORld’s LEADING Independent Professional Stay tuned in to upcoming Events and Conferences Search Navigation Feature-rich Get to know our Authors and Editors Why Publish with SAGE ? World’s LEADING Publisher and home and editors Societies authors Professional Academic LEADING Publisher Natural World’s Societies THE and LEADING Publisher Natural authors Societies Independent home editors THE Professional Natural Societies Independent authors Societies and Societies editors THE LEADING home editors Natural editors Professional Independent Academic and authors Academic Independent Publisher Academic Societies and authors Academic THE World’s THE editors Academic THE Natural LEADING THE Natural LEADING home Natural authors Natural editors authors home World’s authors THE editors authors LEADING Publisher World’s LEADING authors World’s Natural Academic editors World’s home Natural and Independent authors World’s Publisher authors World’s home Natural home LEADING Academic Academic LEADING editors Natural and Publisher editors World’s authors home Academic Professional authors Independent home LEADING Academic World’s and authors home and Academic Professionalauthors World’s editors THE LEADING Publisher authors Independent home editors Natural...

Words: 63606 - Pages: 255