SlideShare uma empresa Scribd logo
1 de 4
CSC103 – Object Oriented
    Programming

               Lecture 3

         21st February, 2011



       Engr. M. Anwar-ul-Haq
     OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad
                                                                        1
Solve
• Q.1. A phone number, such as (051) 579-0360,
  can be thought of as having three parts: the area
  code (051), the exchange (579), and the number
  (0360).
• Write a program that uses a structure to store
  these three parts of phone number separately.
  Call the structure phone. Create two structure
  variables of type phone. Initialize one, and have
  the user input a number for the other one. Then
  display both numbers.
              OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad
                                                                                 2
Solve
• Q. 2: A point on the two-dimensional plane can
  be represented by two numbers: an x-coordinate
  and y coordinate. For example, (4, 5) represents
  a point 4 units to the right of vertical axis, and 5
  units up the horizontal axis. The sum of two
  points can be defined as a new point whose x
  coordinate is the sum of the x coordinates of the
  two points, and whose y coordinate is the sum of
  the y coordinates.
• Write a program that uses a structure called
  point to model a point. Define three points, and
  have user input values to two of them. Then set
  the third point equal to the sum of the other two,
  and display the value of the new point.
               OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad
                                                                                  3
Solve
• Q.3. Create a class Rectangle. The class
  has attributes length and width, each of
  which defaults to 1.
• It has member functions that calculate the
  perimeter and the area of the rectangle. It
  has set and get functions for both length
  and width.
• The set functions should verify that length
  and width are each floating-point numbers
  larger than 0.0 and less than 20.0.
            OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad
                                                                               4

Mais conteúdo relacionado

Mais procurados

Object oriented vs. object based programming
Object oriented vs. object based  programmingObject oriented vs. object based  programming
Object oriented vs. object based programmingMohammad Kamrul Hasan
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops conceptsNilesh Dalvi
 
Object Oriented Programming : A Brief History and its significance
Object Oriented Programming : A Brief History and its significanceObject Oriented Programming : A Brief History and its significance
Object Oriented Programming : A Brief History and its significanceGajesh Bhat
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)indiangarg
 
Cs8392 u1-1-oop intro
Cs8392 u1-1-oop introCs8392 u1-1-oop intro
Cs8392 u1-1-oop introRajasekaran S
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop Kumar
 
OOP programming
OOP programmingOOP programming
OOP programminganhdbh
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabsbrainsmartlabsedu
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingAmit Soni (CTFL)
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingumairrajpoot6
 
Course outline for c programming
Course outline for c  programming Course outline for c  programming
Course outline for c programming Rokonuzzaman Rony
 
OOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented ProgrammingOOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented Programmingdkpawar
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented ProgrammingIqra khalil
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)Jay Patel
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPMudasir Qazi
 

Mais procurados (20)

Object oriented vs. object based programming
Object oriented vs. object based  programmingObject oriented vs. object based  programming
Object oriented vs. object based programming
 
Introduction to oops concepts
Introduction to oops conceptsIntroduction to oops concepts
Introduction to oops concepts
 
Object Oriented Programming : A Brief History and its significance
Object Oriented Programming : A Brief History and its significanceObject Oriented Programming : A Brief History and its significance
Object Oriented Programming : A Brief History and its significance
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)
 
Cs8392 u1-1-oop intro
Cs8392 u1-1-oop introCs8392 u1-1-oop intro
Cs8392 u1-1-oop intro
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
Oop ppt
Oop pptOop ppt
Oop ppt
 
Introduction to oop
Introduction to oop Introduction to oop
Introduction to oop
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Oops
OopsOops
Oops
 
OOP programming
OOP programmingOOP programming
OOP programming
 
Java object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - BrainsmartlabsJava object oriented programming concepts - Brainsmartlabs
Java object oriented programming concepts - Brainsmartlabs
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Course outline for c programming
Course outline for c  programming Course outline for c  programming
Course outline for c programming
 
OOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented ProgrammingOOP Unit 1 - Foundation of Object- Oriented Programming
OOP Unit 1 - Foundation of Object- Oriented Programming
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
1 unit (oops)
1 unit (oops)1 unit (oops)
1 unit (oops)
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
 

Semelhante a oop Lecture 3

Data Structures 2004
Data Structures 2004Data Structures 2004
Data Structures 2004Sanjay Goel
 
2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applicationsVahabshaik Shai
 
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...NILESH VERMA
 
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...ijnlc
 
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...Lifeng (Aaron) Han
 
SPEECH RECOGNITION USING SONOGRAM AND AANN
SPEECH RECOGNITION USING SONOGRAM AND AANNSPEECH RECOGNITION USING SONOGRAM AND AANN
SPEECH RECOGNITION USING SONOGRAM AND AANNAM Publications
 
cs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxcs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxGopalPatidar13
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Tiểu Hổ
 

Semelhante a oop Lecture 3 (9)

Data Structures 2004
Data Structures 2004Data Structures 2004
Data Structures 2004
 
2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications2021 icse reducedsylabiix-computer applications
2021 icse reducedsylabiix-computer applications
 
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...Demystifying NLP Transformers: Understanding the Power and Architecture behin...
Demystifying NLP Transformers: Understanding the Power and Architecture behin...
 
Ijetcas14 399
Ijetcas14 399Ijetcas14 399
Ijetcas14 399
 
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...
Development of Lexicons Generation Tools for Arabic: Case of an Open Source C...
 
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...
LP&IIS2013 PPT. Chinese Named Entity Recognition with Conditional Random Fiel...
 
SPEECH RECOGNITION USING SONOGRAM AND AANN
SPEECH RECOGNITION USING SONOGRAM AND AANNSPEECH RECOGNITION USING SONOGRAM AND AANN
SPEECH RECOGNITION USING SONOGRAM AND AANN
 
cs 601 - lecture 1.pptx
cs 601 - lecture 1.pptxcs 601 - lecture 1.pptx
cs 601 - lecture 1.pptx
 
Hub102 - JS - Lesson3
Hub102 - JS - Lesson3Hub102 - JS - Lesson3
Hub102 - JS - Lesson3
 

Mais de Anwar Ul Haq

Mais de Anwar Ul Haq (7)

oop Lecture19
oop Lecture19oop Lecture19
oop Lecture19
 
oop Lecture 17
oop Lecture 17oop Lecture 17
oop Lecture 17
 
oop Lecture 16
oop Lecture 16oop Lecture 16
oop Lecture 16
 
oop Lecture 9
oop Lecture 9oop Lecture 9
oop Lecture 9
 
oop Lecture 6
oop Lecture 6oop Lecture 6
oop Lecture 6
 
oop Lecture 5
oop Lecture 5oop Lecture 5
oop Lecture 5
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 

Último

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 

Último (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 

oop Lecture 3

  • 1. CSC103 – Object Oriented Programming Lecture 3 21st February, 2011 Engr. M. Anwar-ul-Haq OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad 1
  • 2. Solve • Q.1. A phone number, such as (051) 579-0360, can be thought of as having three parts: the area code (051), the exchange (579), and the number (0360). • Write a program that uses a structure to store these three parts of phone number separately. Call the structure phone. Create two structure variables of type phone. Initialize one, and have the user input a number for the other one. Then display both numbers. OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad 2
  • 3. Solve • Q. 2: A point on the two-dimensional plane can be represented by two numbers: an x-coordinate and y coordinate. For example, (4, 5) represents a point 4 units to the right of vertical axis, and 5 units up the horizontal axis. The sum of two points can be defined as a new point whose x coordinate is the sum of the x coordinates of the two points, and whose y coordinate is the sum of the y coordinates. • Write a program that uses a structure called point to model a point. Define three points, and have user input values to two of them. Then set the third point equal to the sum of the other two, and display the value of the new point. OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad 3
  • 4. Solve • Q.3. Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. • It has member functions that calculate the perimeter and the area of the rectangle. It has set and get functions for both length and width. • The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. OOP, Spring 2011, Engr. Anwar, Foundation University (FUIEMS), Islamabad 4