Your algorithm and program should print values for the following:
|
|
- Jared Shields
- 5 years ago
- Views:
Transcription
1 ASSIGNMENT #1 SOLUTION Total: 50 marks Objective of Assignment: To write a simple C program to solve a problem using no decision or repetition instructions and no function calls. Scope: Assignment covers materials up until end of chapter 1 and parts of chapters 2 & 3. Other Things to learn from Assignment : How to use a text editor, compile and run a C program, how to create and print a Unix script file and how to use some Unix commands. Problem: 1. Quick Relief (QR) is a charity organization that has collected non-perishable goods like water, soap, cereal, clothing and others from people so that they could donate the goods to recent hurricane victims. A harmonized sales tax (HST) of 13% should be applied to the given cost of the items to obtain the actual cost. QR agency has filled three car trunks with goods for donation and your job is to write an algorithm and a program to compute (a) the total cost of goods in each of the three trunks with the HST, (b) the total cost of goods in all the three trunks with HST, (c) the total weight of goods in each of the three trunks, and (d) the total weight of goods in all the three trunks. We are told that: i. Trunk 1 contains the following four items: (1) 70 cases of bottled water and each case costs $3:99, (2) 60 cereal boxes costing $6.00 per box, (3) 200 T-shirts costing $12.00 each, and (4) 80 dozens of ivory soap costing $2:49 per dozen. ii. Trunk 2 contains four items: (1) 150 cases of bottled water and each case costs $2:50, (2) 130 cereal boxes costing $4:50 per box, (3) 250 T- shirts costing $15.00 each, and (4) 300 dozens of ivory soap costing $3:50 per dozen. iii. Trunk 3 contains four items: (1) 100 cases of bottled water and each case costs $4:00, (2) 210 cereal boxes costing $4:00 per box, (3) 180 T- shirts costing $10.00 each, and (4) 240 dozens of ivory soap costing $3:10 per dozen. iv. A case of bottled water weighs 150 lbs (pounds), a box of cereal weighs 5 lbs, a T shirt weighs 4 lbs and a dozen of ivory soap weighs 3 lbs. Assume that all products of the same kind have the same weights. For example, all cereal boxes have the same weight and all T-shirts have the same weight. Again, Write an algorithm and a program to compute the cost of goods in each of the three trunks, the cost of the goods in all the three trunks, the weight of the goods in each of the three trunks and the weight of the goods in all the three trunks. Hint: You can set up your program to ask for the input values of the cost of each unit of the 4 items in each trunk (e.g., costs of each unit of the four items in trunk 1 are: ), followed by the input values of the number of each of the 4 items in each trunk (e.g., numbers of each of the items in trunk 1 are: ), etc. Your algorithm and program should print values for the following:
2 Details of Goods sent by QR Charity Agency: Total cost of goods in Trunk 1 with HST is: $ Total cost of goods in Trunk 2 with HST is: $ Total cost of goods in Trunk 3 with HST is: $ Total cost of goods in the three trunks with HST is: $ Total weight of goods in Trunk 1 is: lbs Total weight of goods in Trunk 2 is: lbs Total weight of goods in Trunk 3 is: lbs Total weight of goods in the three trunks is: lbs End of processing!!! Steps for Creating Materials to Hand in for Marking: 1. Type your algorithm solution in a text file called your userid_asn1.txt. 2. Then, type the C program solution into a source file called your userid_asn1.c. 3. Compile your C program with cc userid_asn1.c. 4. Then, run (execute it with a.out). 5. When your program is running with no errors, then, create a script file called userid_script1.txt and hand in your script file for marking. Your script file should show your algorithm, your source program, the compilation of the program, the running of the program with the input and output data shown. To create a script file, at unix prompt, do the following: script userid_script1.txt cat userid_asn1.txt cat userid_asn1.c cc userid_asn1.c a.out [note here when prompted by the cpu, enter the input data from the keyboard as your program has asked to read it and the result will be displayed on the monitor and captured in the script file]. exit Marking Scheme : 1. Correct Algorithm solution (10 marks) 2. Program Solution (10marks) 3. Error free Compilation of Program (10 marks) 4. Correct Running of the Program with Correct Input/Output Data (10 marks) 5. Correct creation and handing in of Script File (10 marks) *** The solution containing the algorithm, the C program, the compilation and the execution of the program showing the input and results of the run as in the script file cezeife_script1.txt is shown below:
3 SOLUTION Script started on Wed Sep 14 13:01: cat cezeife_asn1.txt /* C Program for computing the costs and weights of goods in each of the 3 car trunks as well as the total costs and weights of goods in all 3 car trunks sent to Hurricane victims by QR charity agency. The unit costs and weights as well as number of each of four items contained in the trunks are given as input. The items are cases of bottled water, boxes of cereal, T shirts and dozens of ivory soaps. /* Program written by Dr. Christie Ezeife */ /* Professor for lecture */ /* Labs , 52, 53 and 54. */ MainAlgorithm { Input Data: water_case1, cereal_cost1, T_shirt1, soap1; (real) water_num1, cereal_num1, shirt_num1, soap_num1; (integer) water_case2, cereal_cost2, T_shirt2, soap2; (real) water_num2, cereal_num2, shirt_num2, soap_num2; (integer) water_case3, cereal_cost3, T_shirt3, soap3; (real) water_num3, cereal_num3, shirt_num3, soap_num3; (integer) constant waterwt=150.0, cerealwt=5.0; (real) constant shirtwt=4.0, soapwt=3.0; (real) constant HST = 1.13; (real) Output Data: trunk1_cst, trunk2_cst, trunk3_cst, trunk1_wt, trunk2_wt, trunk3_wt; totalcost, totalwt; (real) /* Sequence of steps */ print("type cost of each unit of the four items in Trunk 1:\n"); read(water_case1, cereal_cost1, T_shirt1, soap1); print("type number of each of the items in Trunk 1\n"); read(water_num1, cereal_num1, shirt_num1, soap_num1); print("type cost of each unit of the four items in Trunk 2:\n"); read(water_case2, cereal_cost2, T_shirt2, soap2); print("type number of each of the items in Trunk 2\n"); read(water_num2, cereal_num2, shirt_num2, soap_num2); print("type cost of each unit of the four items in Trunk 3:\n"); read(water_case3, cereal_cost3, T_shirt3, soap3); print("type number of each of the items in Trunk 3\n"); read(water_num3, cereal_num3, shirt_num3, soap_num3); /* Now compute the cost and weight for Trunk 1 */ trunk1_cst = ((water_case1 * water_num1) + (cereal_cost1 * cereal_num1) + (T_shirt1 * shirt_num1) + (soap1 * soap_num1)) * HST; trunk2_cst = ((water_case2 * water_num2) + (cereal_cost2 * cereal_num2) + (T_shirt2 * shirt_num2) + (soap2 * soap_num2)) * HST; trunk3_cst = ((water_case3 * water_num3) + (cereal_cost3 * cereal_num3) + (T_shirt3 * shirt_num3) + (soap3 * soap_num3)) * HST; trunk1_wt= (waterwt * water_num1) + (cerealwt * cereal_num1) + (shirtwt * shirt_num1) + (soapwt * soap_num1); trunk2_wt= (waterwt * water_num2) + (cerealwt * cereal_num2) + (shirtwt * shirt_num2) + (soapwt * soap_num2);
4 trunk3_wt= (waterwt * water_num3) + (cerealwt * cereal_num3) + (shirtwt * shirt_num3) + (soapwt * soap_num3); /* Now compute the total cost and weight*/ totalcost = trunk1_cst + trunk2_cst + trunk3_cst; totalwt = trunk1_wt + trunk2_wt + trunk3_wt; /* Now print the desired output */ print ("Details of Goods sent by QR Charity Agency: \n\n"); print("\n\n"); print("total cost of goods in Trunk 1 is:", trunk1_cst); print("total cost of goods in Trunk 2 is:", trunk2_cst); print("total cost of goods in Trunk 3 is:", trunk3_cst); print("\n\n"); print("total cost of goods in the three trunks is:", totalcost); print(""); print("total weight of goods in Trunk 1 is: ", trunk1_wt); print("total weight of goods in Trunk 2 is: ", trunk2_wt); print("total weight of goods in Trunk 3 is: ", trunk3_wt); print(""); print("total weight of goods in the three trunks is: lbs", totalwt); print(""); print("end of processing!!!"); } cezeife@sol:~/fall11/assignmt$ cat cezeife_asn1.c #include <stdio.h> /* C Program for computing the costs and weights of goods in each of the 3 car trunks as well as the total costs and weights of goods in all 3 car trunks sent to Hurricane victims by QR charity agency. The unit costs and weights as well as number of each of four items contained in the trunks are given as input. The items are cases of bottled water, boxes of cereal, T shirts and dozens of ivory soaps. /* Program written by Dr. Christie Ezeife */ /* Professor for lecture */ /* Labs , 52, 53 and 54. */ int main(void) { float water_case1, cereal_cost1, T_shirt1, soap1; float water_num1, cereal_num1, shirt_num1, soap_num1; float water_case2, cereal_cost2, T_shirt2, soap2; float water_num2, cereal_num2, shirt_num2, soap_num2; float water_case3, cereal_cost3, T_shirt3, soap3; float water_num3, cereal_num3, shirt_num3, soap_num3; const float waterwt=150.0, cerealwt=5.0; const float shirtwt=4.0, soapwt=3.0; const float HST = 1.13; float trunk1_cst, trunk2_cst, trunk3_cst, trunk1_wt, trunk2_wt, trunk3_wt; float totalcost, totalwt; /* Sequence of steps */ printf("type cost of each unit of the four items in Trunk 1:\n"); scanf("%f %f %f %f", &water_case1, &cereal_cost1, &T_shirt1, &soap1); printf("type number of each of the items in Trunk 1:\n"); scanf("%f %f %f %f", &water_num1, &cereal_num1, &shirt_num1, &soap_num1); printf("type cost of each unit of the four items in Trunk 2:\n");
5 scanf("%f %f %f %f", &water_case2, &cereal_cost2, &T_shirt2, &soap2); printf("type number of each of the items in Trunk 2:\n"); scanf("%f %f %f %f", &water_num2, &cereal_num2, &shirt_num2, &soap_num2); printf("type cost of each unit of the four items in Trunk 3:\n"); scanf("%f %f %f %f", &water_case3, &cereal_cost3, &T_shirt3, &soap3); printf("type number of each of the items in Trunk 3:\n"); scanf("%f %f %f %f", &water_num3, &cereal_num3, &shirt_num3, &soap_num3); /* Now compute the cost and weight for Trunk 1 */ trunk1_cst = ((water_case1 * water_num1) + (cereal_cost1 * cereal_num1) + (T_shirt1 * shirt_num1) + (soap1 * soap_num1)) * HST; trunk2_cst = ((water_case2 * water_num2) + (cereal_cost2 * cereal_num2) + (T_shirt2 * shirt_num2) + (soap2 * soap_num2)) * HST; trunk3_cst = ((water_case3 * water_num3) + (cereal_cost3 * cereal_num3) + (T_shirt3 * shirt_num3) + (soap3 * soap_num3)) * HST; trunk1_wt= (waterwt * water_num1) + (cerealwt * cereal_num1) + (shirtwt * shirt_num1) + (soapwt * soap_num1); trunk2_wt= (waterwt * water_num2) + (cerealwt * cereal_num2) + (shirtwt * shirt_num2) + (soapwt * soap_num2); trunk3_wt= (waterwt * water_num3) + (cerealwt * cereal_num3) + (shirtwt * shirt_num3) + (soapwt * soap_num3); /* Now compute the total cost and weight*/ totalcost = trunk1_cst + trunk2_cst + trunk3_cst; totalwt = trunk1_wt + trunk2_wt + trunk3_wt; /* Now print the desired output */ printf ("Details of Goods sent by QR Charity Agency: \n\n"); printf("\n\n"); printf("total cost of goods in Trunk 1 with HST is: \t \t $%0.2f \n", trunk1_cst); printf("total cost of goods in Trunk 2 with HST is: \t \t $%0.2f \n", trunk2_cst); printf("total cost of goods in Trunk 3 with HST is: \t \t $%0.2f \n", trunk3_cst); printf("\n\n"); printf("total cost of goods in the three trunks with HST is: \t $%0.2f \n", totalcost); printf("\n\n"); printf("total weight of goods in Trunk 1 is: \t \t \t %0.2f lbs \n", trunk1_wt); printf("total weight of goods in Trunk 2 is: \t \t \t %0.2f lbs \n", trunk2_wt); printf("total weight of goods in Trunk 3 is: \t \t \t %0.2f lbs \n", trunk3_wt); printf("\n\n"); printf("total weight of goods in the three trunks is: \t %0.2f lbs \n", totalwt); printf("\n\n"); printf("end of processing!!!\n\n"); return 0; } cezeife@sol:~/fall11/assignmt$ cc cezeife_asn1.c cezeife@sol:~/fall11/assignmt$ a.out Type cost of each unit of the four items in Trunk 1:
6 Type number of each of the items in Trunk 1: Type cost of each unit of the four items in Trunk 2: Type number of each of the items in Trunk 2: Type cost of each unit of the four items in Trunk 3: Type number of each of the items in Trunk 3: Details of Goods sent by QR Charity Agency: Total cost of goods in Trunk 1 with HST is: $ Total cost of goods in Trunk 2 with HST is: $ Total cost of goods in Trunk 3 with HST is: $ Total cost of goods in the three trunks with HST is: $ Total weight of goods in Trunk 1 is: lbs Total weight of goods in Trunk 2 is: lbs Total weight of goods in Trunk 3 is: lbs Total weight of goods in the three trunks is: lbs End of processing!!! cezeife@sol:~/fall11/assignmt $ exit exit script done on Wed Sep 14 13:04:
and function calls (including call-by-reference parameters and global variables), but no decision or repetition instructions.
60-140-1 and 60-140-2 ASSIGNMENT #4 SOLUTION Handed Out:Thurs. Oct 22, 2015 for (60-140-01 and 60-140-02) Due: Thurs Oct 29, 2015 for (60-140-01 and 60-140-02) Total: 50 marks Objective of Assignment :
More informationIntroduction to Algorithms and Programming I Lab. Exercises #1 Solution
60-140 Introduction to Algorithms and Programming I Lab. Exercises #1 Solution Objectives are to: 1. Learn basic Unix commands for preparing a source C program file, compiling a C program and executing
More informationSU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar)
SU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar) 1 Problem A 1.1 Specification Write an ANSI-C program that reads input from the
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationCS Spring 2018 Homework #5
CS 1313 010 Spring 2018 Homework #5 Quiz to be held in lecture 9:30-9:45am Mon Feb 19 2018 1. HOW CAN YOU TELL that a declaration statement declares a named constant? 2. HOW CAN YOU TELL that a declaration
More informationMaterials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.
60-140-1 Lecture for Thursday, Sept. 18, 2014. *** Dear 60-140-1 class, I am posting this lecture I would have given tomorrow, Thursday, Sept. 18, 2014 so you can read and continue with learning the course
More information27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p.
Lecture 10 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 10: Formatted Input and Output 27-Sep-2017 Location: Goldberg CS 127 Time: 14:35 15:25 Instructor:
More informationProgramming and Data Structure Laboratory (CS13002)
Programming and Data Structure Laboratory (CS13002) Dr. Sudeshna Sarkar Dr. Indranil Sengupta Dept. of Computer Science & Engg., IIT Kharagpur 1 Some Rules to be Followed Attendance is mandatory. Regular
More informationCSCI 2132 Software Development. Lecture 8: Introduction to C
CSCI 2132 Software Development Lecture 8: Introduction to C Instructor: Vlado Keselj Faculty of Computer Science Dalhousie University 21-Sep-2018 (8) CSCI 2132 1 Previous Lecture Filename substitution
More informationCptS 360 (System Programming) Unit 1: Introduction to System Programming
CptS 360 (System Programming) Unit 1: Introduction to System Programming Bob Lewis School of Engineering and Applied Sciences Washington State University Spring, 2018 Motivation (for the whole course)
More informationwhile Loops Lecture 13 Sections Robb T. Koether Wed, Sep 26, 2018 Hampden-Sydney College
while Loops Lecture 13 Sections 5.8-5.9 Robb T. Koether Hampden-Sydney College Wed, Sep 26, 2018 Robb T. Koether (Hampden-Sydney College) while Loops Wed, Sep 26, 2018 1 / 25 1 while Loops 2 Input Loops
More informationIntroduction to C Programming
13205 C Programming Lecture 1-26/Sept/2017 c 2017 Abel Gomes All Rights Reserved Introduction to C Programming Scribe: A. Gomes This lecture aims to respond to the following questions: Why do we need to
More informationProgramming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan
Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with
More informationCourse Information and Introduction
August 22, 2017 Course Information 1 Instructors : Email : arash.rafiey@indstate.edu Office : Root Hall A-127 Office Hours : Tuesdays 11:30 pm 12:30 pm. Root Hall, A127. 2 Course Home Page : http://cs.indstate.edu/~arash/cs256.html
More informationC Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.
C Tutorial: Part 1 Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering September 2013 Why C? Small (32 keywords) Stable Existing code base Fast Low-level
More informationDay05 A. Young W. Lim Sat. Young W. Lim Day05 A Sat 1 / 14
Day05 A Young W. Lim 2017-10-07 Sat Young W. Lim Day05 A 2017-10-07 Sat 1 / 14 Outline 1 Based on 2 Structured Programming (2) Conditions and Loops Conditional Statements Loop Statements Type Cast Young
More informationC Programming Lecture V
C Programming Lecture V Instructor Özgür ZEYDAN http://cevre.beun.edu.tr/ Modular Programming A function in C is a small sub-program that performs a particular task, and supports the concept of modular
More informationCS133 C Programming. Instructor: Jialiang Lu Office: Information Center 703
CS133 C Programming Instructor: Jialiang Lu Email: jialiang.lu@sjtu.edu.cn Office: Information Center 703 1 Course Information: Course Page: http://wirelesslab.sjtu.edu.cn/~jlu/teaching/cp2014/ Assignments
More informationCS Fall 2007 Homework #5
CS 1313 010 Fall 2007 Homework #5 Quiz to be held in class 9:30-9:45am Mon Feb 19 2007 1. GIVE TWO EXAMPLES of unary arithmetic operations (NOT operators). 2. For the two examples of unary arithmetic operations,
More informationCS : Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November
CS 1313 010: Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November 7 2018 This fifth programming project will give you experience writing programs
More informationCSE 303 Lecture 8. Intro to C programming
CSE 303 Lecture 8 Intro to C programming read C Reference Manual pp. Ch. 1, 2.2-2.4, 2.6, 3.1, 5.1, 7.1-7.2, 7.5.1-7.5.4, 7.6-7.9, Ch. 8; Programming in C Ch. 1-6 slides created by Marty Stepp http://www.cs.washington.edu/303/
More informationIntroduction to Computing Lecture 07: Repetition and Loop Statements (Part II)
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Assist.Prof.Dr. Nükhet ÖZBEK Ege University Department of Electrical & Electronics Engineering nukhet.ozbek@ege.edu.tr Topics
More informationCSC 270 Survey of Programming Languages
CSC 270 Survey of Programming Languages C Lecture 1 : Getting Started: in C #include int { A First Program main(void) header makes input and output available to us printf("this is my first C
More informationChapter 1 & 2 Introduction to C Language
1 Chapter 1 & 2 Introduction to C Language Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 1 & 2 - Introduction to C Language 2 Outline 1.1 The History
More informationConstants Lesson Outline
Outline 1. Outline 2. What is a Constant? 3. The Difference Between a Variable and a Constant 4. Categories of Constants: Literal & Named 5. Literal Constants 6. Literal Constant Example Program 7. Named
More informationBLM2031 Structured Programming. Zeyneb KURT
BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help
More informationCS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September
CS 1313 010: Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September 19 2018 This second assignment will introduce you to designing, developing, testing
More informationLab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering
2013/2014 Programming Fundamentals for Engineers Lab Lab Session # 1 Introduction to C Language ALQUDS University Department of Computer Engineering Objective: Our objective for today s lab session is
More informationC Fundamentals & Formatted Input/Output. adopted from KNK C Programming : A Modern Approach
C Fundamentals & Formatted Input/Output adopted from KNK C Programming : A Modern Approach Program: Printing a Pun pun.c The file name doesn t matter, but the.c extension is often required. for example:
More informationLecture 2: C Programming Basic
ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX
More informationCS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June
CS 1313 010: Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June 20 2007 This second assignment will introduce you to designing, developing, testing
More informationLAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER
LAB 1 INTRODUCTION TO LINUX ENVIRONMENT AND C COMPILER School of Computer and Communication Engineering Universiti Malaysia Perlis 1 1. GETTING STARTED: 1.1 Steps to Create New Folder: 1.1.1 Click Places
More informationDay06 A. Young W. Lim Wed. Young W. Lim Day06 A Wed 1 / 26
Day06 A Young W. Lim 2017-09-20 Wed Young W. Lim Day06 A 2017-09-20 Wed 1 / 26 Outline 1 Based on 2 C Program Control Overview for, while, do... while break and continue Relational and Logical Operators
More informationCMPUT 201: Practical Programming Methodology. Guohui Lin Department of Computing Science University of Alberta September 2018
CMPUT 201: Practical Programming Methodology Guohui Lin guohui@ualberta.ca Department of Computing Science University of Alberta September 2018 Lecture 1: Course Outline Agenda: Course calendar description
More informationProgramming. Data Structure
Programming & Data Structure For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Programming and Data Structures Programming in C, Arrays, Stacks, Queues, Linked
More informationCS1600 Lab Assignment 1 Spring 2016 Due: Feb. 2, 2016 POINTS: 10
CS1600 Lab Assignment 1 Spring 2016 Due: Feb. 2, 2016 POINTS: 10 PURPOSE: The purpose of this lab is to acquaint you with the C++ programming environment on storm. PROCEDURES: You will use Unix/Linux environment
More informationCOP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA
COP 3275: Chapter 02 Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA Program: Printing a Pun #include int main(void) { printf("to C, or not to C: that is the question.\n");
More informationCpSc 1111 Lab 4 Formatting and Flow Control
CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal
More informationLinux Systems Administration Shell Scripting Basics. Mike Jager Network Startup Resource Center
Linux Systems Administration Shell Scripting Basics Mike Jager Network Startup Resource Center mike.jager@synack.co.nz These materials are licensed under the Creative Commons Attribution-NonCommercial
More informationCpSc 111 Lab 3 Integer Variables, Mathematical Operations, & Redirection
CpSc 111 Lab 3 Integer Variables, Mathematical Operations, & Redirection Overview By the end of the lab, you will be able to: declare variables perform basic arithmetic operations on integer variables
More informationLecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar
Examples of Software Programming and Data Structure Lecture 2 Sudeshna Sarkar Read an integer and determine if it is a prime number. A Palindrome recognizer Read in airline route information as a matrix
More informationInstructor. Mehmet Zeki COSKUN Assistant Professor at the Geodesy & Photogrammetry, Civil Eng. (212)
Instructor Mehmet Zeki COSKUN Assistant Professor at the Geodesy & Photogrammetry, Civil Eng. (212) 285-6573 coskunmeh@itu.edu.tr http://atlas.cc.itu.edu.tr/~coskun Address Consultation of Students: Monday
More informationET156 Introduction to C Programming
ET156 Introduction to C Programming Unit 1 INTRODUCTION TO C PROGRAMMING: THE C COMPILER, VARIABLES, MEMORY, INPUT, AND OUTPUT Instructor : Stan Kong Email : skong@itt tech.edutech.edu Figure 1.3 Components
More informationIntroduction to Programming II Winter, 2015 Assignment 5 (Saturday, April 4, 2015: 23:59:59)
60-4 Introduction to Programming II Winter, 205 Assignment 5 (Saturday, April 4, 205: 2:59:59) This is a lengthy assignment description. Take time to read it carefully and thoroughly. Dynamic Linked Lists
More informationProgramming for Engineers: Getting Started
Programming for Engineers: Getting Started 10 January 2011 History of C: Timeline 1. 1972 Ken Thompson working on UNIX 2. 1972 Dennis Ritchie creates C 3. 1983 ANSI C (C89) 4. 1990 ISO C (C90) 5. 1999
More informationIntroduction to C Programming. What is a C program?
Introduction to C Programming Goals of this section Write a simple C program - Steps Write or develop code Compile Link Execute Add comments to C code 85-132 Introduction to C-Programming 2-1 What is a
More informationBSM540 Basics of C Language
BSM540 Basics of C Language Chapter 4: Character strings & formatted I/O Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture To explain the input/output functions printf()
More informationProblem Set 1: Unix Commands 1
Problem Set 1: Unix Commands 1 WARNING: IF YOU DO NOT FIND THIS PROBLEM SET TRIVIAL, I WOULD NOT RECOMMEND YOU TAKE THIS OFFERING OF 300 AS YOU DO NOT POSSESS THE REQUISITE BACKGROUND TO PASS THE COURSE.
More informationLecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati
Lecture 1 Introduction to Computing A. Sahu and S. V. Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Computer System Problem Solving and Flow Chart Linux Command ls, mkdir,
More informationC Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006
C Compilation Model Comp-206 : Introduction to Software Systems Lecture 9 Alexandre Denault Computer Science McGill University Fall 2006 Midterm Date: Thursday, October 19th, 2006 Time: from 16h00 to 17h30
More informationAN OVERVIEW OF C, PART 3. CSE 130: Introduction to Programming in C Stony Brook University
AN OVERVIEW OF C, PART 3 CSE 130: Introduction to Programming in C Stony Brook University FANCIER OUTPUT FORMATTING Recall that you can insert a text field width value into a printf() format specifier:
More information1.1 Introduction to C Language. Department of CSE
1.1 Introduction to C Language 1 Department of CSE Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to
More informationBIL 104E Introduction to Scientific and Engineering Computing. Lecture 1
BIL 104E Introduction to Scientific and Engineering Computing Lecture 1 Introduction As engineers and scientists why do we need computers? We use computers to solve a variety of problems ranging from evaluation
More informationCpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection
CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection Overview By the end of the lab, you will be able to: declare variables perform basic arithmetic operations on integer variables
More informationEngineering program development 7. Edited by Péter Vass
Engineering program development 7 Edited by Péter Vass Functions Function is a separate computational unit which has its own name (identifier). The objective of a function is solving a well-defined problem.
More information1. The Mac Environment in Sierra Hall 1242
Wednesday, August 26, 2015 Lab Notes Topics for today The Mac Environment C (and Unix) Notes on C Part 1 Program 1 1. The Mac Environment in Sierra Hall 1242 a. Turning on the Mac If the Mac is in sleep
More informationCS 108 Computing Fundamentals. October/November Array Bootcamp
CS 108 Computing Fundamentals October/November 2017 Array Bootcamp For arrays: passing to a function "by value" means passing a single element's "contents" For arrays: no more than one element's contents
More informationCMIS 102 Hands-On Lab
CMIS 10 Hands-On Lab Week 8 Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, and implementation
More informationLab 1 Introduction to UNIX and C
Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. NOTE: Text
More informationC++ Support Classes (Data and Variables)
C++ Support Classes (Data and Variables) School of Mathematics 2018 Today s lecture Topics: Computers and Programs; Syntax and Structure of a Program; Data and Variables; Aims: Understand the idea of programming
More informationPhysics 306 Computing Lab 1: Hello, World!
1. Introduction Physics 306 Computing Lab 1: Hello, World! In today s lab, you will learn how to write simple programs, to compile them, and to run them. You will learn about input and output, variables,
More informationComputer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary
GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis
More informationFriday, September 16, Lab Notes. Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week
Friday, September 16, 2016 Lab Notes Topics for today Redirection of input and output Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week 1. Redirection
More informationHacking C Code - Local Machine
Hacking C Code - Local Machine For CS department machines, use your LDAP password, and log in with ssh to remote.cs.binghamton.edu (unless you're actually sitting at a Unix machine in one of the labs,
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More information1. The Mac Environment in SIE 1222
Friday, September 1, 2017 Lab Notes Topics for today The Mac Environment C (and Unix) Notes on C Part 1 Program 1 1. The Mac Environment in SIE 1222 a. Turning on the Mac If the Mac is in sleep mode you
More informationEastern Mediterranean University Department of Computer Engineering
CMPE 108 Algorithms and Programming Midterm Exam Fall 2015-16 Page 1 Eastern Mediterranean University Department of Computer Engineering CMPE 108 Algorithms and Programming Midterm Exam, 2015-2016 Fall
More informationTutorial 2: Compiling and Running C++ Source Code
Tutorial 2: Compiling and Running C++ Source Code 1. Log in to your UNIX account as you did during the first tutorial. 2. Click on the desktop with the left mouse button and consider the menu that appears
More information15213 Recitation Section C
15213 Recitation Section C Outline Sept. 9, 2002 Introduction Unix and C Playing with Bits Practice Problems Introducing Myself Try to pronounce my name: My office hour: Wed 2-3pm, WeH 8019 Contact: Email:
More information27-Sep CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation. Faculty of Computer Science, Dalhousie University
Lecture 4 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lab 4: Exploring bash and C Compilation 27-Sep-2017 Location: Goldberg CS Building Time: Wednesday, 16:05
More informationCSE / ENGR 142 Programming I
CSE / ENGR 142 Programming I Variables, Values, and Types Chapter 2 Overview Chapter 2: Read Sections 2.1-2.6, 2.8. Long chapter, short snippets on many topics Later chapters fill in detail Specifically:
More informationCarleton University Department of Systems and Computer Engineering SYSC Foundations of Imperative Programming - Winter 2012
Carleton University Department of Systems and Computer Engineering SYSC 2006 - Foundations of Imperative Programming - Winter 2012 Lab 1 - Introduction to Pelles C Objective To become familiar with the
More informationArithmetic Expressions Lesson #1 Outline
Outline 1. Outline 2. A Less Simple C Program #1 3. A Less Simple C Program #2 4. A Less Simple C Program #3 5. A Less Simple C Program #4 6. A Less Simple C Program: Compile & Run 7. Flowchart for my_add.c
More informationLecture 03 Bits, Bytes and Data Types
Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics
More informationby Pearson Education, Inc. All Rights Reserved.
Programmers write instructions in various programming languages, some directly understandable by computers and others requiring intermediate translation steps. Computer languages may be divided into three
More informationFundamentals of Programming. Lecture 3: Introduction to C Programming
Fundamentals of Programming Lecture 3: Introduction to C Programming Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department Outline A Simple C
More informationChapter 11 Introduction to Programming in C
C: A High-Level Language Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University! Gives
More informationNote: If only one statement is to be followed by the if or else condition then there is no need of parenthesis.
Birla Institute of Technology & Science, Pilani Computer Programming (CSF111) Lab-4 ---------------------------------------------------------------------------------------------------------------------------------
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationCC112 Structured Programming
Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer Engineering Department CC112 Structured Programming Lecture 3 1 LECTURE 3 Input / output operations
More informationUNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Winter 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated : Feb 7 th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationTemple University Computer Science Programming Under the Linux Operating System January 2017
Temple University Computer Science Programming Under the Linux Operating System January 2017 Here are the Linux commands you need to know to get started with Lab 1, and all subsequent labs as well. These
More informationEL2310 Scientific Programming
Lecture 6: Introduction to C (pronobis@kth.se) Overview Overview Lecture 6: Introduction to C Roots of C Getting started with C Closer look at Hello World Programming Environment Schedule Last time (and
More informationProgramming for Electrical and Computer Engineers. Loops
Programming for Electrical and Computer Engineers Loops Dr. D. J. Jackson Lecture 6-1 Iteration Statements C s iteration statements are used to set up loops. A loop is a statement whose job is to repeatedly
More informationChapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University C: A High-Level Language! Gives
More informationProgramming Assignment #1: A Simple Shell
Programming Assignment #1: A Simple Shell Due: Check My Courses In this assignment you are required to create a C program that implements a shell interface that accepts user commands and executes each
More informationQuiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated :October 2nd, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationScientific Computing
Scientific Computing Martin Lotz School of Mathematics The University of Manchester Lecture 1, September 22, 2014 Outline Course Overview Programming Basics The C++ Programming Language Outline Course
More informationMA 511: Computer Programming Lecture 2: Partha Sarathi Mandal
MA 511: Computer Programming Lecture 2: http://www.iitg.ernet.in/psm/indexing_ma511/y10/index.html Partha Sarathi Mandal psm@iitg.ernet.ac.in Dept. of Mathematics, IIT Guwahati Semester 1, 2010-11 Largest
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationLecture 3. More About C
Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants
More informationECET 264 C Programming Language with Applications. C Program Control
ECET 264 C Programming Language with Applications Lecture 7 C Program Control Paul I. Lin Professor of Electrical & Computer Engineering Technology http://www.etcs.ipfw.edu/~lin Lecture 7 - Paul I. Lin
More informationLAB 5: REPETITION STRUCTURE(LOOP)
LAB 5: REPETITION STRUCTURE(LOOP) OBJECTIVES 1. To introduce two means of repetition/loop structures; counter-controlled and sentinelcontrolled. 2. To introduce the repetition structures; for, while, do-while
More informationStructured programming. Exercises 3
Exercises 3 Table of Contents 1. Reminder from lectures...................................................... 1 1.1. Relational operators..................................................... 1 1.2. Logical
More informationLab 1 Introduction to UNIX and C
Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is
More informationWeek 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1
Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1 General Information Contributes 3 units: 2 hours lectures 2 hours labs and tutorials Main
More information3. Types of Algorithmic and Program Instructions
3. Types of Algorithmic and Program Instructions Objectives 1. Introduce programming language concepts of variables, constants and their data types 2. Introduce types of algorithmic and program instructions
More informationC++ Programming Lecture 7 Control Structure I (Repetition) Part I
C++ Programming Lecture 7 Control Structure I (Repetition) Part I By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department while Repetition Structure I Repetition structure Programmer
More informationCMSC 246 Systems Programming
CMSC 246 Systems Programming Spring 2018 Bryn Mawr College Instructor: Deepak Kumar CMSC 246 Systems Programming 1 Go to class web page 3 Goals Learn Linux (CLI, not WIMP!) Learn C Learn Linux tools 4
More information2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants
Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a
More information