Hacettepe University Computer Engineering Department

Slides:



Advertisements
Similar presentations
Technotronics GCECT '091 Decode C This is a C Programming event, where you will be given problems to solve using C only. You will be given a Linux system.
Advertisements

Copyright © 2002 Pearson Education, Inc. Slide 1.
Exercises for CS1512 Week 12 Sets (questions).
Introduction to C Systems Programming Concepts. Introduction to C A simple C Program A simple C Program –Variable Declarations –printf ( ) Compiling and.
ARDUINO CLUB Session 1: C & An Introduction to Linux.
User-defined Functions Selim Aksoy Bilkent University Department of Computer Engineering
CS Fall 2012, Lab 01 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /17/2015 Using Piazza 
CS1010 Programming Methodology
NEW CAIRO EDUCATIONAL ZONE ELSHOROUK FUTURE INTEGRATED LANGUAGE SCHOOL MATHS DEPARTMENT WORK SHEETS FOR 5TH PRIM 1ST TERM.
Introduction to Computer Engineering by Richard E. Haskell 8086 Tutor Monitor Module M14.3 Section 9.3 Appendix B.
The little language that could Remember C is a “small language”
PHYS 2020 Basic C An introduction to writing simple but useful programs in C In these lectures I will take you through the basics of C, but you will need.
1 CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
1 9/26/07CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
1 Gentle Introduction to Programming Tirgul 2: Scala “hands on” in the lab.
Prime and Composite Numbers. Introduction Me: I am in compacted math and I will show you the math concept of prime and composite numbers. Concept: Every.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University October 6-10, 2008 ©By the author. All rights reserved.
Scientific Notation and Significant Digits Created by The North Carolina School of Science and Math.The North Carolina School of Science and Math Copyright.
Basic Math Skills Lesson 2: Reading and Writing Decimals p
I CAN COMPARE AND ORDER RATIONAL NUMBERS BY USING A NUMBER LINE. 1.5 RATIONAL NUMBERS.
Lecture #5 Introduction to C++
Fundamental Programming: Fundamental Programming Introduction to C++
PHYS 2020 Basic C An introduction to writing simple but useful programs in C In these lectures I will take you through the basics of C, but you will need.
Lecture 1 cis208 January 14 rd, Compiling %> gcc helloworld.c returns a.out %> gcc –o helloworld helloworld.c returns helloworld.
Math Library Functions
Introduction to Java Primitive Types Operators Basic input and output.
1 CS161 Introduction to Computer Science Topic #4.
Introduction to Computer Organization & Systems Topics: Types in C: floating point COMP C Part III.
CS 614: Theory and Construction of Compilers Lecture 5 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
WEEK 10 Class Activities Lecturer’s slides.
Introduction to Programming
Lesson 3: Comparing and Rounding Decimals p
The Machine Model Memory
Introduction to Programming
Math Review Traditional Review.
Computer programming {weeks 01 and 02}
CS1010 Discussion Group 11 Week 4 – Overview of C programming.
Numbers in a Computer Unsigned integers Signed magnitude
Addition of Signed Numbers
CS 108 Computing Fundamentals Notes for Thursday, September 14, 2017
CS 121 Engineering Computation Lab Lab 2
CSE 102 Introduction to Computer Engineering
Introduction to Integers and Absolute Value
REALLY BIG & REALLY small Numbers
Administrative things
LING 388: Computers and Language
Complete the Following Table
Scientific Notation.
Review # 2 Math 8.
Lexical Elements, Operators, and the C Cystem
How wide is our universe?
Objective The student will be able to:
How wide is our universe?
Introduction to Programming
Expanded Form = 3, (3 x 1,000) + (5 x 100)
CS110D Programming Language I
CMPE 152: Compiler Design August 28/30 Lab
Scientific Notation Objective: Students will read and write numbers in
Complete the Following Table
Objective - To multiply integers.
Complete the Following Table
Computing Introduction.
Lab 4: Introduction to Scripting
Introduction to Computer Science
SCIENTIFIC NOTATION ... a way to express very small or very large numbers that is often used in "scientific" calculations where the analysis must be very.
From the Previous Table…
Significant Figures and Rounding
DIVISION OF INTEGERS 1-9.
Counter Fundamentals Presented by :
Even or odd?.
Presentation transcript:

Hacettepe University Computer Engineering Department Programming in & BBM103 Introduction to Programming Lab 1 Week 13 Fall 2018

Lab Exercise Write a C program power.c which, given integer base b and power p as command-line arguments, computes the value of b to the power of p (bp) using pow() function from the math library. Example: Compile with: gcc power.c –o power -lm Run with: ./power 2 4 Expected output: 2 to the power of 4 = 16.00000 Write a C program recursive_power.c which does the same computation, but for this exercise you need to write your own recursive function for power computation. Note some different recursive cases: float recursive_power(b, p){ // base case // recursive case: b is zero and p is negative // recursive case: p is negative // recursive case: b is negative and p is odd // recursive case: b is negative and p is even, etc. Compile with: gcc .\recursive_power.c -o recpower Run 1 with: ./recpower -2 -3 Expected output: -2 to the power of -3 = -0.12500 Run 2 with: ./recpower 0 -78 Expected output: 0 to the power of -78 = -inf Run 3 with: ./recpower -56 5 Expected output: -56 to the power of 5 = -550731776.00000 Notice the precision of five digits after the decimal point! You can use math pow() function for this case.