LAB 3: FORMATTED I/O AND C LIBRARY FUNCTIONS ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr.

Slides:



Advertisements
Similar presentations
Week 4 – Functions Introduction. Functions: Purpose Breaking a large problem into a series of smaller problems is a common problem- solving technique.
Advertisements

We Have Learned main() { … } Variable –Definition –Calculation –Display We can do some real programming! –Think about your solution design –Express design.
Exam/Test - Insert module name and module code will take place in rooms [Insert room number] and [Insert room number]between[insert time] and [insert time].
1 ICS103 Programming in C Lecture 5: Introduction to Functions.
Chemistry 211 Final Examination. Final Exam Tips Exam will contain problems that you won’t have any clue how to solve. That is normal! You can miss about.
1 CSE1301 Computer Programming Lecture 5 C Primitives 2.
1 CSE1301 Computer Programming Lecture 10: Iteration (Part 1)
CS100A, Fall 1997, Lectures 221 CS100A, Fall 1997 Lecture 22, Tuesday 18 November Introduction To C Goal: Acquire a reading knowledge of basic C. Concepts:
1 Arithmetic in C. 2 Type Casting: STOPPED You can change the data type of the variable in an expression by: (data_Type) Variable_Name Ex: int a = 15;
Basic Input/Output and Variables Ethan Cerami New York
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Functions Lecture 4 – Section 2: 9/21/05 Section 4: 9/22/05.
C programming: Variables, Expressions part II. Data Types of Arithmetic Expressions Relational Expressions Logical Expressions Multiple Assignments Compound.
Introduction to Computing Lecture 07: Repetition and Loop Statements (Part II) Introduction to Computing Lecture 07: Repetition and Loop Statements (Part.
LAB 2: C BASICS ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong (Tum)
Reading the data from the input devices and displaying the results on the screen are the two main tasks of any program. To perform these tasks user friendly.
Mrs. Braby’s Classroom PROCEDURES. Classroom Procedures  When does class begin? ____End?____  No food or drinks.  No electronic devices in sight. 
Classroom Rules & Procedures Ms. Rhodes. Expectations  Computers are used for assignments only—NO GAMES.  Use appropriate language.  Keep your hands,
1 CSE1301 Computer Programming Lecture 5: Components of a C Program (Part 1) Linda M c Iver.
A First C Program /* Print a Message */ #include main() { printf("This is a test!\n"); } The program is compiled and run as cc pg32.c  a.out  This is.
1 ICS103 Programming in C Lecture 7: Introduction to Functions.
IT’S TIME FOR LUNCH!. Lunch A Procedures After 2 nd period, go to your 3 rd period class (top lockers—this is your locker break) Place your books on your.
1 C Programming Week 2 Variables, flow control and the Debugger.
Kindergarten, 1st Grade, and 2nd Grade
Functions Exercise 5. Functions a group of declarations and statements that is assigned a name  effectively, a named statement block  usually has a.
CECS 130 EXAM 1. To declare a constant (read only) value: const int x = 20; const float PI = 3.14; Can we do this? const int x;
Khalid Rasheed Shaikh Computer Programming Theory 1.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
Functions. Why use functions? They can break your problem down into smaller sub-tasks (modularity).  easier to solve complex problems They make a program.
LAB 2: REPETITION STRUCTURE #2 ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong.
Data Types and Conversions, Input from the Keyboard If you can't write it down in English, you can't code it. -- Peter Halpern If you lie to the computer,
Computer Programming for Engineers
1 TOPICS TO DISCUSS : FUNCTIONS TYPES OF FUNCTIONS HEADER FILES PRESENTED BY : AVISHEK MAJUMDAR(837837) GUNJAN AGARWAL(856587) SATYAPRIYA DEY(856624)
CISC105 – General Computer Science Class 4 – 06/14/2006.
Agenda  Basic Logic - Continued...  if else statements  switch Statements  Compound Conditions.
ANALYTIC GEOMETRY & ALGEBRA II MRS. CHAPMAN AND MS. STURDIVANT ROOM 304.
Classroom Procedures 1.Enter before tardy bell and take assigned set. 2.Get your science notebook out and get ready for the Starter. 3.Stay in your seats.
+ Note On the Use of Different Data Types Use the data type that conserves memory and still accomplishes the desired purpose. For example, depending on.
 Real numbers representation - Floating Point Notation  First C Program  Variables Declaration  Data Types in C ◦ char, short, int, long, float, double,
Lecture2.
ECE Application Programming
Functions, Part 2 of 2 Topics Functions That Return a Value
Representation of data types
Functions in C Mrs. Chitra M. Gaikwad.
Administrative things
Data Type.
The while Looping Structure
توابع ورودي-خروجي.
Data Type.
WELCOME BACK TO SCHOOL and to
Functions October 23, 2017.
Functions, Part 2 of 3 Topics Functions That Return a Value
The while Looping Structure
Test Next Week Summer 3, 2016 Midterm Exam
Lecture3.
Computer Programming Techniques Semester 1, 1998
EECE.2160 ECE Application Programming
Introduction to Computer Organization & Systems
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Functions Department of Computer Science-BGU יום שישי 26 אפריל 2019.
Data Type.
CSCE 206 Lab Structured Programming in C
The while Looping Structure
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
FCPS Introduction Prof. S. Lupoli “Mr. L”.
CSCE 206 Lab Structured Programming in C
The while Looping Structure
Functions, Part 2 of 3 Topics Functions That Return a Value
Presentation transcript:

LAB 3: FORMATTED I/O AND C LIBRARY FUNCTIONS ITS100: Computer and Programming Lab. Section 1 Instructor: Wirat Chinnan TAs: Ms. Sasirassamee Buavirat Mr. Thanasan Tanhermhong (Tum) Ms. Pattheera Panitsuk (Fon+) Mr. Pongsate Tangseng Mr. Chinorot Wangtragulsang Mr. Kanin Assantachai (Ob) 1

printf() printf() is for output 2

scanf() scanf() is for input. Do not forget & in front of variable names. 3

scanf() 4

Arithmetic Operator 5

Mathematical Functions #include 6 ceil(X) Round X up floor(X) Round X down

Mathematical Functions #include 7 ceil(X) Round X up floor(X) Round X down

Finds the common log of n+3 of an input. 8 #include int main() { float n, ans; printf(“Enter a number: ”); scanf(“%f”,&n); n = n+3; ans = log10(n); printf(“log10(n+3)= %f\n”, ans); return 0; } Enter a number : 1 log10(n+3)=

Mathematical Functions #include 9 ceil(X) Round X up floor(X) Round X down

Finds the power of an input. 10 #include int main() { int n1,n2, ans; printf(“Enter two numbers: ”); scanf(“%d %d”,&n1,&n2); ans = pow(n1,n2); printf(“n1 power n2 = %d\n”, ans); return 0; } Enter two Numbers: 2 3 n1 power n2 = 8

Mathematical Functions #include 11 ceil(X) Round X up floor(X) Round X down

Finds the square root of an input. 12 #include int main() { float n1, ans; printf(“Enter a number: ”); scanf(“%f”,&n1); ans = sqrt(n1); printf(“square root = %f\n”, ans); return 0; } Enter a number : 3 square root =

Mathematical Functions #include 13 ceil(X) Round X up floor(X) Round X down

Finds the round down value of an input. 14 #include int main() { float n1, ans; printf(“Enter a number: ”); scanf(“%f”,&n1); ans = ceil(n1); printf(“Round up = %f\n”, ans); return 0; } Enter a number : Round up =

Mathematical Functions #include 15 ceil(X) Round X up floor(X) Round X down

Finds the round down value of an input. 16 #include int main() { float n1, ans; printf(“Enter a number: ”); scanf(“%f”,&n1); ans = floor(n1); printf(“Round down = %f\n”, ans); return 0; } Enter a number : Round down =

Formatted Output 17

Formatted Output 18 #include int main() { float n1; n1 = ; printf(“n1 = %.2f\n”, n1); return 0; } n1 = 1.73

Formatted Output 19 #include int main() { float n1; n1 = ; printf(“n1 = %.0f\n”, n1); return 0; } n1 = 1

To Do in Class Exercise 1, 3, 4, 5, and Self Practice 7 Call your TA when you finished. You may take a break Be ready for the speed test at

Exercise 1 21

Exercise 3 22

Exercise 4 23

Exercise 5 24

Self Practice 7 25

Speed Test Speed test should be treated just like a real exam. Rules: No talking. Be quiet. No mobile phone. No electronic devices other than your PC No Internet No cheating Cheating will result in a severe penalty TAs will not help you (except when your PC crashes). Time allowed: 45 minutes. 26

Speed Test Instruction Write your name on the question sheet. Create all workspace on your ‘Desktop’ When you finished Raise your hand to signal the assigned TA TA grades your work Quietly leave the room DO NOT bring the question sheet out. Leave it on your table. 27