Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

C Characters & Strings Character Review Character Handling Library Initialization String Conversion Functions String Handling Library Standard Input/Output.
1 Chapter 10 Strings and Pointers. 2 Introduction  String Constant  Example: printf(“Hello”); “Hello” : a string constant oA string constant is a series.
Lecture 09 Strings, IDEs. METU Dept. of Computer Eng. Summer 2002 Ceng230 - Section 01 Introduction To C Programming by Ahmet Sacan Mon July 29, 2002.
Character String Manipulation. Overview Character string functions sscanf() function sprintf() function.
Lecture 9. Lecture 9: Outline Strings [Kochan, chap. 10] –Character Arrays/ Character Strings –Initializing Character Strings. The null string. –Escape.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
 2000 Prentice Hall, Inc. All rights reserved Fundamentals of Strings and Characters String declarations –Declare as a character array or a variable.
ECE Application Programming Instructor: Dr. Michael Geiger Spring 2012 Lecture 31: PE5.
Current Assignments Homework 5 will be available tomorrow and is due on Sunday. Arrays and Pointers Project 2 due tonight by midnight. Exam 2 on Monday.
Array_strcpy void array_strcpy(char dest[], char src[]) { int i = 0; while (src[i] != '\0') { dest[i] = src[i]; i++; } dest[i] = '\0'; }
By Senem Kumova Metin 1 POINTERS + ARRAYS + STRINGS REVIEW.
C programming---String. String Literals A string literal is a sequence of characters enclosed within double quotes: “hello world”
 2000 Prentice Hall, Inc. All rights reserved. Chapter 8 - Characters and Strings Outline 8.1Introduction 8.2Fundamentals of Strings and Characters 8.3Character.
. Plab – Tirgul 2 Const, C Strings. Pointers int main() { int i,j; int *x; // x points to an integer i = 1; x = &i; j = *x; ijx 1.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Fundamentals of Strings and Characters Characters.
Tutorial #8 Summer strings #include int main() { char str1[] = {‘h’,’e’,’l’,’l’,’o’}; char str[] = {‘h’,’e’,’l’,’l’,’o’,’\0’}; char p[] = ”hello”;
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);
C Programming Strings. Array of characters – most common type of array in C  Let’s make them easier for use Denote the end of array using a special character.
Strings in C. Strings are Character Arrays Strings in C are simply arrays of characters. – Example:char s [10]; This is a ten (10) element array that.
EPSII 59:006 Spring Introduction Fundamentals of Strings and Characters Character Handling Library String Conversion Functions Standard Input/Output.
1 بنام خدا زبان برنامه نویسی C (21814( Lecture 13 Chapter 13 Strings.
Introduction to C programming
Data Type string #include // C++ String class string str1, str2; // Default constructor cin >> str1 >> str2; cout
Chapter 9 Character Strings 9.1 Character String Constants A character string constant is a sequence of characters enclosed in double quotation mark. Examples.
Strlen() implementation /* strlen : return length of string s */ int strlen(char *s) { int n; for (n = 0 ; s[n] != ‘\0’ ; n++) ; return n; } /* strlen.
STRING Dong-Chul Kim BioMeCIS UTA 10/7/
Final Review Yuan Long CSC3320. Variables byte,char,int,long float,double.
CPT: Strings/ Computer Programming Techniques Semester 1, 1998 Objectives of these slides: –to discuss strings and their relationship.
APS105 Strings. C String storage We have used strings in printf format strings –Ex: printf(“Hello world\n”); “Hello world\n” is a string (of characters)
Lecture 6 C++ Programming Arne Kutzner Hanyang University / Seoul Korea.
Spring 2005, Gülcihan Özdemir Dağ Lecture 8, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 8 Outline 8.1 Declaring.
Representing Strings and String I/O. Introduction A string is a sequence of characters and is treated as a single data item. A string constant, also termed.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
Strings Programming Applications. Strings in C C stores a string in a block of memory. The string is terminated by the \0 character:
C Programming - Structures. Structures containing arrays A structure member that is an array does not ‘behave’ like an ordinary array When copying a structure.
CS 1430: Programming in C++ 1. Data Type string #include // C++ String class string str1, str2; // Default constructor cin >> str1 >> str2; cout
Chapter 8 Characters and Strings. Objectives In this chapter, you will learn: –To be able to use the functions of the character handling library ( ctype).
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Characters and Strings Functions.
Pointers and Arrays An array's name is a constant whose value is the address of the array's first element. For this reason, the value of an array's name.
CMSC 104, Version 8/061L25Strings.ppt Strings Topics String Libraries String Operations Sample Program Reading Sections
Principles of Programming Chapter 8: Character & String  In this chapter, you’ll learn about;  Fundamentals of Strings and Characters  The difference.
CS 1704 Introduction to Data Structures and Software Engineering.
1 Arrays and Pointers The name of an array is a pointer constant to the first element. Because the array’s name is a pointer constant, its value cannot.
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 =
Dr. Sajib Datta Feb 21,  In the last class we discussed: ◦ Bubble sort  How it works  performance.
19-Feb-02 Sudeshna Sarkar, CSE, IIT Kharagpur1 Arrays, Pointers, Strings Lecture 18 19/2/2002.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Characters and Strings Dale Roberts, Lecturer Computer Science,
CSE 251 Dr. Charles B. Owen Programming in C1 Strings and File I/O.
ECE 103 Engineering Programming Chapter 29 C Strings, Part 2 Herbert G. Mayer, PSU CS Status 7/30/2014 Initial content copied verbatim from ECE 103 material.
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
1 Memory, Arrays & Pointers. Memory 2 int main() { char c; int i,j; double x; cijx.
ECE Application Programming
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
INC 161 , CPE 100 Computer Programming
Pointers & Arrays 1-d arrays & pointers 2-d arrays & pointers.
ECE Application Programming
Lecture 8 String 1. Concept of strings String and pointers
Module 2 Arrays and strings – example programs.
Arrays in C.
CSC215 Homework Homework 04 Due date: Oct 14, 2016.
EECE.2160 ECE Application Programming
C Strings Prabhat Kumar Padhy
C++ Pointers and Strings
Strings #include <stdio.h>
Characters and Strings Functions
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
C++ Pointers and Strings
Introduction to Problem Solving and Programming
Presentation transcript:

Xuan Guo Review for the Final Exam Xuan Guo July 29 8:30AM – 10:30AM Classroom South 300 CSC3320 1

Xuan Guo Multiple choice Short answers Complete programs Write the output Write a program Bonus question CSC3320 2

Xuan Guo identifier integer arithmetic operation scanf(), printf(), convention specifies getchar() function declaration assignment of a pointer, & access to the member of the structure 2-dimensional array initilization String, char array, strlen(), strcmp() open(), lseek(), fork(), pid, orphan process static, directive sqrt() CSC3320 3

Xuan Guo double sqrt(double x) Returns the square root of x. size_t strlen(const char *str) Computes the length of the string str up to but not including the terminating null character. char *strcpy(char *dest, const char *src) Copies the string pointed to by src to dest. int strcmp(const char *str1, const char *str2) Compares the string pointed to by str1 to the string pointed to by str2. CSC3320 4

Xuan Guo Example 1 Write a C program to count the occurrences of a fixed word in a string. CSC3320 5

Xuan Guo Example 2 void main(void) { int i=2,j=3; int p=&i, q=&j ; printf(“*p=%d *q=%d”,*p,*q); q=p; printf(“*p=%d *q=%d”,*p,*q); *p=j; printf(“*p=%d *q=%d”,*p,*q); } CSC3320 6

Xuan Guo Example 3 The following recursive function is used to convert a positive integer n to a string a. When converting the integer, the digits are reversed. For example, 483 is converted to string “384”. void convert(char *a, int n) { int i=0; i=n/10; *a=__________; // the last digit of current number if(i!=0) convert(_________,i); // pass the address for next character and value of current number else *(a+1)=’\0’; } void main(void){ char str[10]; convert(str,123); printf(“the converted str is %s\n”, str); } CSC3320 7

Xuan Guo Example 4 CSC3320 8

Xuan Guo Example 5 int sbs( int x, int y, int *p1, int *p2) { int m; *p1=x*x; *p2=y*y; m=*p1+*p2; return m; } void main(void) { int a=3, b=5, c, d; printf(“%d \n”, sbs(a, b, &c, &d)); printf(“%d %d %d %d\n”, a, b, c, d); } CSC3320 9