Arrays & pointers C How to Program, 8/e.

Slides:



Advertisements
Similar presentations
What is output line of the following C++ code? Please trace int i = 1, QP; DATA: 4, B, 3, A double credit, totCredit=0.0; double num = 0.0; string LG;
Advertisements

Hand Trace and Output for: int digit = 0; int number = 1423; do { digit = number % 10; System.out.println(digit); number = number / 10; } while (number.
General Computer Science for Engineers CISC 106 Final Exam Review Dr. John Cavazos Computer and Information Sciences 05/18/2009.
Exercise 10 Review: pointers, strings and recursion.
Functions: Part 2 of /11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park 1.
Array of pointers We can have an array whose members are pointers, in this example pointers-to-int. int* data[3]; int i; int x = 5; int y = 89; int z =
1 Memory, Arrays & Pointers. Memory 2 int main() { char c; int i,j; double x; cijx.
Arrays Name, Index, Address. Arrays – Declaration and Initialization int x; y[0] y[1] y[2]
SpringerLink Training Kit
Summer Student Program First results
פרויקט מסכם לתואר בוגר במדעים (B.Sc.) במתמטיקה שימושית
Limits on Anomalous WWγ and WWZ Couplings from DØ
2 INFN Sezione di Napoli, I-80126, Italy
Flow to Wells – 1 Steady flow to a well in a confined aquifer
“Devil is in the nuances” (Duran, 2017)
Type-based Verification of Electronic Voting Systems
Mathematical Formulas
Basic Data Types & Memory & Representation
Pointers verses Variables
INC 161 , CPE 100 Computer Programming
ARRAYS 2D ARRAY APPLICATIONS DYNAMIC ARRAYS
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
Functions and Pointers
Formatted Input/Output
POINTERS.
Functions, Part 2 of 2 Topics Functions That Return a Value
Command Line Arguments
Command Line Arguments
2016.
Announcements Homework #5 due Monday 1:30pm
C Language By Sra Sontisirikit
Chapter 2 Overview of C.
Pointers.
Computer Science 210 Computer Organization
Formatted Input/Output
Programming Languages and Paradigms
2008/11/10: Lecture 16 CMSC 104, Section 0101 John Y. Park
Functions and Pointers
CSC 253 Lecture 8.
Computer Science 210 Computer Organization
Compiled and ready to run Memory Stack /*
Pointers.
CSC 253 Lecture 8.
INC 161 , CPE 100 Computer Programming
בקרת קלט #include int main () { int num; printf("Enter number(0-100)\n"); if (scanf("%d",&num) != 1) printf(“Input Error\n”); return 1; } printf("Very.
כתיבת מאקרו הפקודה assert מצביעים לפונקציות
Functions, Part 2 of 3 Topics Functions That Return a Value
Pointers (continued) Chapter 11
Simulating Reference Parameters in C
C Strings Prabhat Kumar Padhy
CS111 Computer Programming
Pointers Pointers are variables that contain memory addresses as their values. A variable name refers to a specific value. A pointer contains an address.
Extra Practice for Recursion
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Fundamental Programming
CS250 Introduction to Computer Science II
EECE.2160 ECE Application Programming
CS150 Introduction to Computer Science 1
Chapter 9: Pointers and String
Strings in C Array of characters is called a string.
Summary CSE 2031 Fall May 2019.
Character Arrays char string1[] = “first”;
EECE.2160 ECE Application Programming
Exercise 5 1. We learned bubble sort during class. This problem requires you to modify the code for bubble sorting method to implement the selection sorting.
EECE.2160 ECE Application Programming
IPC144 Introduction to Programming Using C Week 5 – Lesson 1
CSCE 206 Lab Structured Programming in C
Functions, Part 2 of 3 Topics Functions That Return a Value
Functions, Part 2 of 3 Topics Functions That Return a Value
Presentation transcript:

Arrays & pointers C How to Program, 8/e

How arrays work

How arrays work

Strings in C

Strlen and sizeof

Introducing pointers

Passing function arguments

What's the output of this code?

What happens when you run this?

Pointers VS Arrays

#include <stdio.h> int largest(int* ,int); int largest(int* arr,int num) { int largest=*arr; int i; for (i=1;i<num;i++) // if (a[i] > largest) if (*(arr+i) > largest) //largest=arr[i]; largest=*(arr+i); } return largest; int main() int a[10]; for (i=0; i< 10; i++) printf("Enter a number: "); scanf("%d",&a[i]); // printf("The largest: %d\n",largest(&a[0],10)); printf("The largest: %d\n",largest(a,10)); return 0;