1 Session-8 CSIT 121 Spring 2006 Chapter 3 continued Text string processing (Functions to search for a sub-string, count the length of names and compare.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

For(int i = 1; i
Chapter 8. Operator Overloading Operator overloading gives the opportunity to redefine C++ Operator overloading refers to redefine C++ operators such.
Boyer Moore Algorithm String Matching Problem Algorithm 3 cases Searching Timing.
 Just the word will find too many instances  Searching for blanks on both sides loses start and end  How to solve? › See last Thursday examples.
An Introduction to Programming with C++ Fifth Edition Chapter 12 String Manipulation.
1 Session-17 CSIT 121 Spring 2006 Loops: Conditional and Count Controlled Loops: Conditional and Count Controlled LCV: Initialize; Test and Update LCV:
1 Session-12 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to March.
1 Session-16 CSIT 121 Spring 2006 Demo for switch-case due now Demo for switch-case due now String comparison String comparison Slide 23; sample case.
1 Session-5 CSIT 121 Spring 2006 Part D due now String Rules Chapter 2 Topics Lab Demo Exercise Assignment.
1 Lab Session-8 CSIT-121 Fall 2003 w Call by Reference w Lab Exercise 1 w Lab Exercise for Demo w Practice Problems.
1 Session-23 CSIT 121 Spring 2006 Revision Ch 7: Reference Parameters Revision Ch 7: Reference Parameters Chapter 8: Value Returning Functions Chapter.
1 Lab Session-9 CSIT221 Fall 2002 Lab Exercise Based on operator overloading (Demo Required)
Princeton University COS 226 Algorithms and Data Structures Spring Knuth-Morris-Pratt Reference: Chapter 19, Algorithms.
1 Lab Session-1 CSIT221 Spring 2003 b Group Programming Challenge b Individual Lab Exercise (Demo Required)
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
1 Session-7 CSIT 121 Spring 2006 Lab Demo of NiMo Lesson 3-2 Exercises 1,2,3,4,5,6 (Arithmetic Operators with Program ‘Convert.cpp’) Q&A about operators.
1 Session-14 CSIT 121 Spring 2006 Demo due today; demo hint was sent to your campus accounts Demo due today; demo hint was sent to your campus .
1 Session-15 CSIT 121 Spring 2006 Selection with Switch~Case Selection with Switch~Case Need an integer or character to test for Need an integer or character.
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
Primitive Data Types byte, short, int, long float, double char boolean Are all primitive data types. Primitive data types always start with a small letter.
Arrays in Java An array is a collection of elements of the same type Declaration (we will use integers in this example) int[] A; int A[]; after this the.
1 Session-11 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-4 due Now Chapter 4 topics –Using get and ignore to control input data (3-19) –Prompting.
1 Session-19 CSIT 121 Spring 2006 Count controlled loops can be implemented with for statement This statement becomes the loop header for (lcv=initial.
1 Lab Session-3 CSIT121 Fall 2003 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
1 Lab Session-3 CSIT 121 Fall 2004 Section-3 should finish Lab-1 Exercise first Division rules Operator precedence rules Lab Exercise.
1 Lab Session-9 CSIT-121 Fall 2003 w Random Number Generation w Designing a Game.
1 Lab Session-3 CSIT 121 Spring’05 Division rules Operator precedence rules Lab Exercise.
1 Lab Session-VIII CSIT-121 Fall 2000 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
1 Lab Session-11 CSIT 121 Fall 2003 Using arrays in functions Programming Exercise.
TA: Nouf Al-Harbi NoufNaief.net :::
1 Lab Session-III CSIT-120 Spring 2001 Revising Previous session Data input and output While loop Exercise Limits and Bounds GOTO SLIDE 13 Lab session.
1 Session-9 CSIT 121 Spring 2006 Lab Demo (first 20 minutes) The correct way to do the previous lab sheet Function calls Calling void functions Calling.
1 Session-13 CSIT 121 Spring 2006 Test-1 is on March 9 th ; Demo-5 due date extended to March 7 Test-1 is on March 9 th ; Demo-5 due date extended to.
1 Lab Session-VIII CSIT-121 Spring 2002 w Formatted Output w Call by Reference w Lab Exercises w File Handling w Lab Exercises.
Characters & Strings Lesson 2 CS1313 Spring Characters & Strings Lesson 2 Outline 1.Characters & Strings Lesson 2 Outline 2.Character String Declaration.
1.
1 Lab Session-8 CSIT-121 Spring 2005 Call by Reference Lab Exercise for Demo Practice Problems.
CS1201: Programming Language 2 Recursion By: Nouf Almunyif.
Fundamentals of Python: First Programs
String Manipulation Chapter 15 This chapter explains the String facilities. You have already seen some of the main methods of the String class.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 24 The String Section.
1 Lesson: Applets with User Input and Output with GUI ICS4M.
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
CHAPTER 5 FUNCTIONS I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
© Oxford University Press All rights reserved. CHAPTER 6 STRINGS.
Week 3 - Friday.  What did we talk about last time?  Operations on boolean values  !, &&, ||  Operations on char values  +, -  Operations on String.
Chapter 3A Strings. Using Predefined Classes & Methods in a Program To use a method you must know: 1.Name of class containing method (Math) 2.Name of.
CS 1430: Programming in C++ 1. Class StudentList class StudentList { private: int numStudents; Student students[MAX_SIZE]; int find(const Student& s)
1 Lab Session-IV CSIT121 Spring 2002 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercises Lab Exercise for Demo.
Computer Programming 2 Lab (1) I.Fatimah Alzahrani.
Lab String Concatenation String s3 = s1.concat(s2); String s3 = s1 + s2; s1 + s2 + s3 + s4 + s5 same as (((s1.concat(s2)).concat(s3)).concat(s4)).concat(s5);
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Today’s topics Java Looping Upcoming Arrays in Java Reading Great Ideas, Chapter 3.
(Monty) Python for loops Mr. Neat. Comparison JavaC++Python source code name.java.cpp.py Object Oriented? required optional functions/ methods ( bob.hide()
© Oxford University Press All rights reserved. Data Structures Using C, 2e Reema Thareja.
Introduction to Programming using Java Day 3 and 4 Java Language Basics Review The “For” loop Subroutines The “String” class.
Introduction to Programming using Java
using System; namespace Demo01 { class Program
David Meredith Aalborg University
Lab Session-9 CSIT-121 Spring 2005
פונקציות לעיתים קרובות לא נוח להגדיר את כל התוכנה בתוך גוף אחד.
String Methods: length substring
Microsoft Visual Basic 2005: Reloaded Second Edition
Welcome back to Software Development!
Knuth-Morris-Pratt Algorithm.
Using string type variables
Introduction to Algorithms and Programming COMP151
Setting Personal Health Goals Your Character in Action
Presentation transcript:

1 Session-8 CSIT 121 Spring 2006 Chapter 3 continued Text string processing (Functions to search for a sub-string, count the length of names and compare two strings) Example demo program Lesson 3-5 Exercises 1,2,3 Lab sheet : Extend Exercise 3 so that your program searches for a pattern “ob” in your full name and reports “pattern found” or “not found” on the screen

2 Demo Program for Strings void main () { string myname, yourname; int mylength, yourlength; int pos; cout<<"Enter first user's full name"; getline(cin,myname); cout<<"Enter second user's full name"; getline(cin,yourname); mylength = int (myname.length()); yourlength = int (yourname.length()); cout<<"My name is "<<mylength<<" characters long"<<endl; cout<<"Your name is "<<yourlength<<" characters long"<<endl; if (myname>yourname) cout<<"My name is longer"<<endl; else cout<<"Your name is longer"<<endl; pos = myname.find('Z'); if (pos != -1) cout<<"Zub occurs at position "<<pos<<endl; cout<<myname.substr(5,6)<<endl; }