CSC215 Homework Homework 02 Due date: Sep 30, 2016.

Slides:



Advertisements
Similar presentations
Selection Feature of C: Decision making statements: It allow us to take decisions as to which code is to be executed next. Since these statements control.
Advertisements

For(int i = 1; i
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Pointer to Structure. Structure variable can be access using pointers int a=10,*p; Here p  is an integer type pointer variable, p can hold the address.
COMP1180 Review Date: 4 March, 2009 Time: 10:30am - 12:20pm Venue: –CS students -- FSC801C and FSC801D –IS and other students -- OEE1017 Remarks: – 1)
CS Data Structures Appendix 1 How to transfer a simple loop- expression to a recursive function (factorial calculation)
Modular Programming From Chapter 6. Output Parameters Pass by reference. In the calling program: int frog, lily; int * frog_ptr=&frog; function_name(frog_ptr,
CSSE221: Software Dev. Honors Day 28 Announcements Announcements Simulation grades coming back Simulation grades coming back All C Projects due Friday.
Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday.
Pointers Example Use int main() { int *x; int y; int z; y = 10; x = &y; y = 11; *x = 12; z = 15; x = &z; *x = 5; z = 8; printf(“%d %d %d\n”, *x, y, z);
1 Chapter 3 Flow of Control. 2 Review of Class on Sep 23.
A simple C program: Printing a line of text #include main() { printf(“hello, world\n”); } Program output: hello, world.
CSC 107 – Programming For Science. Today’s Goal  Learn C functions to input and output data  Using printf to print out variables and strings  Read.
Week 1 - Friday.  What did we talk about last time?  C basics  Data types  Output with printf()
Programming I Introduction Introduction The only way to learn a new programming language is by writing programs in it. The first program to.
Functions Top-down design Breaking a complex problem into smaller parts that we can understand is a common practice. The process of subdividing a problem.
CP104 Introduction to Programming Overview of C Lecture 4__ 1 Assignment Statements An assignment statement is to store a value in a variable variable.
Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC
Week 8: Decisions Bryan Burlingame 21 October 2015.
USER DEFINED FUNCTIONS Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Sudeshna Sarkar, IIT Kharagpur 1 Functions Lecture
1 CSC 1401 S1 Computer Programming I Hamid Harroud School of Science and Engineering, Akhawayn University
CSC Programming for Science Lecture 8: Character Functions.
Char ch; ch ‘L’‘X’‘V’‘I’ As in Roman numerals Want to give each a value, n say switch (ch) { case ‘I’:n = 1; break; case ‘V’:n = 5; break; … default:cout.
The Cast Operator The cast operator converts explicitly from one data type of an expression to another. For example, if x is of type int, the value of.
LOOPING IN C. What would be the output of the following program main( ) { int j ; while ( j
(c) 2006 by Dr. Ziad Kobti - May not be replicated without permission 1 Lecture 0: Review by Dr. Ziad Kobti Introduction to Algorithms and.
CS115 FALL Senem KUMOVA-METİN1 CHAPTER 4 FLOW OF CONTROL-1 Operators, If and switch statements.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Dr. Sajib Datta Jan 21,  Declare a variable ◦ int height; [note that no value is still assigned]  Assign a variable a value ◦ height =
 To find the numerical value of the expression, simply substitute the variables in the expression with the given number. Evaluate: 2x + 7, if x = 4 Substitute.
$100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300 $400 $500 $100 $200 $300.
Arrays. Arrays are objects that help us organize large amounts of information.
Notes Over 1.2 Express the power in words. Then write the meaning. Word Meaning.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
C language--Introduction. History 1970: B by Ken Thompson at AT&T Bell Lab 1972: C by Dennis Ritchie and Ken Tompson at At&T Bell Lab for UNIX 1978: “The.
CSC 215 Pointers and Arrays. Pointers C provides two unary operators, & and *, for manipulating data using pointers The operator &, when applied to a.
Dr. Sajib Datta  char type technically is an integer type  Computer uses numeric codes to represent characters, and store characters as integers.
Dr. Sajib Datta Sep 8,  char type technically is an integer type  Computer uses numeric codes to represent characters, and store characters.
Operators And Expressions
Command Line Arguments
CSE1320 Loop Dr. Sajib Datta
Iteration statement while do-while
OUTPUT STATEMENTS GC 201.
Pointers  Week 10.
Chapter 5 Decision Making and Branching
CSC215 Homework Homework 04 Due date: Oct 14, 2016.
CSC 102 Chabli Boler.
Loops in C.
A function with one argument
CSC215 Homework Homework 06 Due date: Oct 30, 2016.
CSC215 Homework Homework 05 Due date: Oct 21, 2016.
CSC215 Homework Homework 05 Due date: Oct 21, 2016.
CSC215 Homework Homework 03 Due date: Oct 07, 2016.
Chapter 10 Structures and Unions
Homework #5 (Models of Computation, Spring, 2001) Due: Section 1; February 27 Section 2; February 28 ** Please put your homework in the collection.
Chapter 3 Operators and Expressions
Java Programming Review 1
CprE 185: Intro to Problem Solving (using C)
Day 8 Objective: I can review expressions for the test.
Operator and Expression
Lec 6 Loop Statements Introduction to Computer Programming
To Start: 15 Points Evaluate: * 6 – 2 3(6 +2) – 2 3{6 +(3 * 4)}
Thing / Person:____________________ Dates:_________________
Iteration Statement for
CprE 185: Intro to Problem Solving (using C)
Rudra Dutta CSC Spring 2007, Section 001
Evaluating an expression with two variable
Presentation transcript:

CSC215 Homework Homework 02 Due date: Sep 30, 2016

Question 1 Evaluate each of the following expressions in C: int x=1, y=7, z=0; double i=1.5, j=-0.7; char a='m'; x * y - z / i 7.0 1 3 * (2 * x + 1) / x 9 1 x && y | z 1 1 (double) x / i * y 4.666667 1 a / y + (int) i / x 16 1 i > j & j > x || !z 1 1 x+y--+z++ 8 1 --x > z++ ? y-- : i * j -1.05 1 a ? y - x : x - y 6 1 x = 5 ? (y = z) : (z = y) 0 (2 is accepted too) 1 int x=1, y=7, z=0; double i=1.5, j=-0.7; char a='m'; x * y - z / i 3 * (2 * x + 1) / x x && y | z (double) x / i * y a / y + (int) i / x i > j & j > x || !z x+y--+z++ --x > z++ ? y-- : i * j a ? y - x : x - y x = 5 ? (y = z) : (z = y)

Question 2 Find the output of each of the following statements : char CC[]="+966"; char city[]="11"; char a='P'; printf("%6d, %4d\n", 86, 1040); printf("%12.5e\n", 30.253); printf("%d\t%c\n", (int)30.253, (char)83.162); printf("%s-%s-%d\n", CC, city, 4334567); printf("%d:%d:%d %cM (%d/%d/%d)", 9,3,7,a,12,7,16); 86, 1040 2 3.02530e+01 2 30 S 2 +966-11-4334567 2 9:3:7 PM (12/7/16)2