CSC215 Homework Homework 06 Due date: Oct 30, 2016.

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
F UNCTION O VERLOADING Chapter 5 Department of CSE, BUET 1.
Review for Final Exam Dilshad M. NYU. In this review Arrays Pointers Structures Java - some basic information.
Informática II Prof. Dr. Gustavo Patiño MJ
1 Day 03 Introduction to C. 2 Memory layout and addresses r s int x = 5, y = 10; float f = 12.5, g = 9.8; char c = ‘r’, d = ‘s’;
Dynamic Memory Allocation in C++. Memory Segments in C++ Memory is divided in certain segments – Code Segment Stores application code – Data Segment Holds.
CSE1303 Part A Data Structures and Algorithms Lecture A6 – Dynamic Memory.
Kymberly Fergusson CSE1303 Part A Data Structures and Algorithms Summer Semester 2003 Lecture A6 – Dynamic Memory.
CIS 101: Computer Programming and Problem Solving Lecture10 Usman Roshan Department of Computer Science NJIT.
Arrays. Arrays  When a value is to be used in a program, a variable is declared to hold that value  What about storing the results of exams for a large.
Plab 2003 Exercise 4. Pointers to pointers. Plab 2003 Exercise 4 2 Pointers to pointers (1)int i=3 (2)int j=4; (3)int k=5; 3 i: 4 j: 5 k: ip1: ip2: (4)int.
Pointers. Addresses in Memory When a variable is declared, enough memory to hold a value of that type is allocated for it at an unused memory location.
Multiple-Subscripted Array
Arrays. Arrays  When a value is to be used in a program, a variable is declared to hold that value  What about storing the results of exams for a large.
COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez
Objectives You should be able to describe: Data Types
Arrays and ArrayLists in Java L. Kedigh. Array Characteristics List of values. A list of values where every member is of the same type. Each member in.
Copyright  Hannu Laine C++-programming Part 1 Hannu Laine.
ECE 103 Engineering Programming Chapter 47 Dynamic Memory Alocation Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103.
Chapter 14 Memory API Chien-Chung Shen CIS, UD
Variables When programming it is often necessary to store a value for use later on in the program. A variable is a label given to a location in memory.
Introduction to Programming
Arrays. Related data items Collection of the same types of data. Static entity – Same size throughout program.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Pointers.
Lecture – Pointers1 C++ Pointers Joseph Spring/Bob Dickerson School of Computer Science Operating Systems and Computer Networks Based on notes by Bob Dickerson.
CHAPTER 6 ARRAYS IN C++ 2 nd Semester King Saud University College of Applied studies and Community Service CSC 1101 By: Fatimah Alakeel Edited.
Computer Engineering 2 nd Semester Dr. Rabie A. Ramadan 3.
Advanced Pointer Topics. Pointers to Pointers u A pointer variable is a variable that takes some memory address as its value. Therefore, you can have.
THE DOUBLE VARIABLE The double variable can hold very large (or small) numbers. The maximum and minimum values are 17 followed by 307 zero’s.
Exception Handling How to handle the runtime errors.
CHAPTER 6 ARRAYS IN C 1 st semester King Saud University College of Applied studies and Community Service Csc 1101 F. Alakeel.
Arithmetic Instructions. Integer and Float Conversions.
Dynamic memory allocation and Intraprogram Communication.
C LANGUAGE UNIT 3. UNIT 3 Arrays Arrays – The concept of array – Defining arrays – Initializing arrays.
C Programming Types & Dynamic memory & bits & others
Code -> Build -> Run
Chapter 6 Arrays in C++ 2nd Semester King Saud University
Day 03 Introduction to C.
BASIC ELEMENTS OF A COMPUTER PROGRAM
2016.
Pointers and dynamic memory
COM S 326X Deep C Programming for the 21st Century Prof. Rozier
CSE 303 Concepts and Tools for Software Development
Day 03 Introduction to C.
Lecture Note Set 1 Thursday 12-May-05
Lecture2.
Lecture 6 C++ Programming
Time Manager Class Activity Material Manager Writer leader Communicator Programmer Start a journey from the capital AbuDhabi to Alasmaa School using your.
Methods and Parameters
CSC 253 Lecture 8.
CSC 253 Lecture 8.
Lecture 8.
Screen output // Definition and use of variables
Dynamic Memory Allocation
Introduction To Programming Information Technology , 1’st Semester
Pointers and dynamic memory
Outline Defining and using Pointers Operations on pointers
CSE451 Fall 2008 Section 1 Roxana Geambasu
CSC215 Homework Homework 05 Due date: Oct 21, 2016.
CSC215 Homework Homework 05 Due date: Oct 21, 2016.
CSC215 Homework Homework 02 Due date: Sep 30, 2016.
CSC215 Homework Homework 03 Due date: Oct 07, 2016.
Chien-Chung Shen CIS/UD
Java Programming Review 1
Seating “chart” Front Back 4 rows 5 rows 5 rows 2 rows 4 rows 2 rows
C Programming Lecture-8 Pointers and Memory Management
Type Conversion It is a procedure of converting one data type values into another data type In C programming language we are having two types of type conversion.
Subtype Substitution Principle
Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a language-specific syntactical token.
Presentation transcript:

CSC215 Homework Homework 06 Due date: Oct 30, 2016

Question 1 : Redefine each of the following variables using dynamically allocated memory, including the initialization step if any. double temperatures[365]; char q[] = "So many books"; int grades[2][3] = {36, 24, 26, 81, 30, 74}; float zeros[] = {0.0, 0.0, 0.0, 0.0}; Char *names[] = {"Ali", "Omar"}

Question 2 : Tell if each of the following code fragments contains an error (compile-time or runtime), specify its type, and correct it. 1) char* p = "Hello world"; printf("%d\n", *p); free(p); 2) int* p = (int*)malloc(10*sizeof(int)); int* q = (int*)realloc(p, 5*sizeof(int)); free(q); 3) int** p = (int*)malloc(2*sizeof(int)); p[0] = (int*)malloc(5*sizeof(int)); p[1] = (int*)malloc(5*sizeof(int));