adplus-dvertising
Perfect 24 U
No Result
View All Result
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry
Perfect 24 U
No Result
View All Result
Home KPK NOTES 2nd Years 2nd year computer science notes

Chapter 3 Object Oriented Programming using C++

ADVERTISEMENT

2nd year Computer science (ICS) Chapter 3 Object Oriented Programming using C++ for Grade-12 Khyber Pakhtunkhwa Board.

Object Oriented Programming using C++ for kpk board

Table of Contents

  • Object Oriented Programming using C++ for kpk board
  • Q.5) Pick that variable from the following list which is improperly declared and named. Also, describe the reason of its invalidity.
  • Q.6) Write a C++ program to get six subject marks of a student and then calculate its total, average, and percentage and display them on screen.
  • Q.7) Write a C++ program to find out maximum value out of three integers using conditional operator.
  • KPK Grade 12 Computer Science Notes
  • Q.8) Write a C++ program to find  out the roots of a quadretic equation.
  • Q.9) Write a C++ program to find out the area of rectangle and display the result on the screen
  • Q.10) Write a C++ program to get the age of a student from the user at run time and display it on the screen.
  • What is object oriented programming in C++?
  • What is object oriented programming with example?

Q.5) Pick that variable from the following list which is improperly declared and named. Also, describe the reason of its invalidity.

  • 1) int sum;
  • 2) int cats=5, dogs=5;
  • 3) int my variable name;
  • 4) int void= 5;
  • 6) int 3some;
  • 7) int meters_of_pipe;
  • 8) int length , width=5;

Answer:
Following are the variables which are improperly declared and named.

  • int my variable name;
    Reason:
    It is having the spaces between the names.
  • int void= 5;
    Reason:
    Reserved or keywords cannot be used as the variable names.
  • int 3some;
    Reason:
    A variable name starting with an integer is not valid.

Q.6) Write a C++ program to get six subject marks of a student and then calculate its total, average, and percentage and display them on screen.

Answer:
#include <stdio.h>
void main() {
    int subj1, subj2, subj3, subj4, subj5, subj6;
    float total, average, percentage;
    cout << “Enter marks of the following Subjects (Max: 200)” << endl;
    cout << “————————————————–” << endl;
    cout << “Subject # 01” << endl;
    cin >> subj1;
    cout << “Subject # 02” << endl;
    cin >> subj2;
    cout << “Subject # 03” << endl;
    cin >> subj3;
    cout << “Subject # 04” << endl;
    cin >> subj4;
    cout << “Subject # 05” << endl;
    cin >> subj5;
    cout << “Subject # 06” << endl;
    cin >> subj6;
    total = subj1 + subj2 + subj3 + subj4 + subj5 + subj6;
    average = total / 6;
    percentage = 100 * (total / 1200);
    cout << “The total marks of the student = ” << total << endl;
    cout << “The Average marks of the student = ” << average << endl;
    cout << “The Percentage of the student = ” << percentage << endl;
}
OUTPUT:
The output of the program is as follows:

Write a C++ program to get six subject marks of a student and then calculate its total, average, and percentage and display them on screen.
Chapter 3 Object Oriented Programming using C++ 6

Q.7) Write a C++ program to find out maximum value out of three integers using conditional operator.

KPK Grade 12 Computer Science Notes

Answer:
void main() {
    int number1, number2, number3;
    cout << “PROGRAM TO PRINT MAXIMUM OF THREE NUMBERS” << endl;
    cout << “—————————————–” << endl;
    cout << “Enter First Number : ” << endl;’
    cin >> number1;
    cout << “Enter Second Number : ” << endl;
    cin >> number2;
    cout << “Enter Third Number : ” << endl;
    cin >> number3;
    if (number1 > number2 && number1 > number3)
    {
        cout << “The maximum number is: ” << number1 << endl;
    }
    if (number2 > number1 && number2 > number3)
    {
        cout << “The maximum number is: ” << number2 << endl;
    }
    if (number3 > number1 && number3 > number2)
    {
        cout << “The maximum number is: ” << number3 << endl;
    }
}
OUTPUT:
The output of the program is as follows:

Write a C++ program to find out maximum value out of three integers using conditional operator.
Chapter 3 Object Oriented Programming using C++ 7

Q.8) Write a C++ program to find  out the roots of a quadretic equation.

Answer:
#include “stdafx.h”
#include <iostream>  
#include <iostream>
#include <cmath>
using namespace std;
int main() {
        float a, b, c, x1, x2, discriminant, realPart, imaginaryPart;’
        cout << “Enter coefficients a, b and c: “;’
        cin >> a >> b >> c;
        discriminant = b*b – 4 * a*c;
        if (discriminant > 0) {
            x1 = (-b + sqrt(discriminant)) / (2 * a);
            x2 = (-b – sqrt(discriminant)) / (2 * a);
            cout << “Roots are real and different.” << endl;
            cout << “x1 = ” << x1 << endl;
            cout << “x2 = ” << x2 << endl;
}
else if (discriminant == 0)
{
    cout << “Roots are real and same.” << endl;
    x1 = (-b + sqrt(discriminant)) / (2 * a);
    cout << “x1 = x2 =” << x1 << endl;
}
else
{
    realPart = -b / (2 * a);

    imaginaryPart = sqrt(-discriminant) / (2 * a);
    cout << “Roots are complex and different.” << endl;
   cout << “x1 = ” << realPart << “+” << imaginaryPart << “i” << endl;
    cout << “x2 = ” << realPart << “-” << imaginaryPart << “i” << endl;
}
return 0;
}
OUTPUT:
The ouptut of the progarm is as follows

Write a C++ program to find  out the roots of a quadretic equation.
Chapter 3 Object Oriented Programming using C++ 8

Q.9) Write a C++ program to find out the area of rectangle and display the result on the screen

Answer:
#include “stdafx.h”
#include <iostream>
#include<conio.h>
using namespace std;
void rectangle(int length, int width)
{
    int area;
    area = length*width;
    cout << “Area of Rectangle is = ” << area << “\n\n”;
}
int main()//main program
{
    int L, W;
    cout << “Enter LENGTH of rectangle : “;
    cin >> L;
    cout << “Enter WIDTH of rectangle : “;
    cin >> W;
    rectangle(L, W);
    return 0;
}
OUTPUT:
The output of the program is as follows:

dd
Chapter 3 Object Oriented Programming using C++ 9

Q.10) Write a C++ program to get the age of a student from the user at run time and display it on the screen.

Answer:
#include <stdio.h>
void main() {
    int birthmonth, birthyear;
    int currentmonth, currentyear;
    int agey, agem;
    cout << “\t\t — PROGRAM TO GET AGE –\n\n”;
    cout << “Enter Your Birth Year(Eg:1989):”;
    cin >> birthyear;
    cout << “\n\nEnter Your Birth Month(Eg:7):”;
    cin >> birthmonth;
    cout << “\nEnter The Current Month(Eg:7):”;
    cin >> currentmonth;
    cout << “\nEnter The Current Year(Eg:2010):”;
    cin >> currentyear;
    agey = currentyear – birthyear;
    agem = 12 – birthmonth;
    cout << “\n\n\t\tYour Age is ” << agey << ” Years And ” << agem << ” Months “;
    _getch();
}
OUTPUT:
The output of the program is as follows:

frgf
Chapter 3 Object Oriented Programming using C++ 10

What is object oriented programming in C++?

OOP stands for Object-Oriented Programming. Procedural programming is about to report procedures or parts that conduct operations on the data, while object-oriented programming is around making objects that have both data and functions. … OOP supplies a clear system for the programs.
Visit Now

What is object oriented programming with example?

Each item is said to be an example of a particular class (for example, an object with its name area set to “Mary” might be an instance of class Worker).

Methods in object-oriented programming are understood as methods; variables are also learned as fields, components, attributes, or properties.

  • 2nd year computer science notes Chapter 1 Operating Systems
  • 2nd year computer science notes Chapter 2 System Development Life Cycle

SendShareTweetPin4ShareShareShareShareSend
Previous Post

2nd year computer science notes Chapter 2 System Development Life Cycle

Next Post

2nd year Computer science Notes Chapter 4 Control Structures

RelatedPosts

KPK G12 Computer Science Notes Chapter 6 (Functions)
2nd year computer science notes

KPK G12 Computer Science Notes Chapter 6 (Functions)

39

The best Notes for exam preparation of 2021-22 kpk class...

Read more
Best 2nd Year Computer Science Notes of All Chapters

Best 2nd Year Computer Science Notes of All Chapters

220
Class 12 Computer Science Notes for KPK Chapter 9 File Handling

Class 12 Computer Science Notes for KPK Chapter 9 File Handling

34
Chapter 8 Objects and Classes

2nd year Computer Science Notes Chapter 8 Objects and Classes

81
Load More
Please login to join discussion
No Result
View All Result

Top Posts & Pages

  • Download file
  • KPK Text Book Board New 2021 PDF Download
  • Sindh textbook board Jamshoro books pdf download 2021
  • Download All Classes Notes in Pdf Class 9, Class 10, Class 11, & Class 12
  • Adamjee Islamiat Compulsory 9th Model Papers
  • Biology 9th Adamjee Model Paper 2021
  • Adamjee Sindhi Salees 10th Model Paper for New Pattern 2022
  • Sindh 9th Class Islamiat Notes PDF Download Urdu | Eng Medium

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 742 other subscribers

  • Trending
  • Comments
  • Latest
Sindh textbook board Jamshoro books pdf download

Sindh textbook board Jamshoro books pdf download 2021

KPK Text Book Board

KPK Text Book Board New 2021 PDF Download

9th Class Math Notes PDF Download Cha 1 to 9

Top 9th Class Math Notes PDF Download Cha 1 to 9

Class 12 English notes Lesson 1 to 20

Class 12 English notes Lesson 1 to 20 for KPK

Best Mothers Day Essay in English USA Gift Movie

Best Mothers Day Essay in English | USA | Gift | Movie

short essay on corruption in pakistan | essay on corruption with quotations | essay on corruption with outline | essay on corruption 500 words | essay on corruption in pakistan pdf | corruption essay pdf

500 Word Essay on Corruption In English

Essay on Co Education

Essay on Co Education – 500 Words

Visit the zoo Essay

Visit the zoo Essay

work and energy ch 6 physics g9 bise rawalpindi ex

Work and Energy Cha 6 Physic G9 Bise Rawalpindi

Gravitation Physics Cha 5 Bise Rawalpindi

Gravitation Physics G9 Cha 5 Bise Rawalpindi

Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4

Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4

Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems

Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems

Recent Posts

  • Work and Energy Cha 6 Physic G9 Bise Rawalpindi
  • Gravitation Physics G9 Cha 5 Bise Rawalpindi
  • Turning Effect of Forces Physics G9 Bise Rawalpindi Cha 4
  • Dynamics bise Rawalpindi 9th Physics Class Mcqs Notes Problems
  • Physics Cha 2 Kinematics Grade 9 Notes Rawalpindi Board
  • Home
  • Privacy Policy
  • Subscription
  • Contact us
  • Feedback
  • Disclaimer
  • Terms & Conditions
  • Cookies Policy
  • ABOUT US
  • Newsletter

© 2021 Perfect24u | All Rights Reserved

No Result
View All Result
  • Home
  • KPK NOTES
    • KPK TextBook Board
      • Grade 1
      • Grade 2
      • Grade 3
      • Grade 4
      • Grade 5
      • Grade 6
      • Grade 7
      • Grade 8
      • Grade 9
      • Grade 10 KPTBB BOOK
      • Grade 12 books for KPK
      • Grade 11 BOOK KPK Board
    • Class 7
      • Urdu
    • Class 9
      • Mathematics
      • English Class 9 Notes for KPK
      • 9th Urdu Notes
      • Biology 9th
      • Islamiat 9
      • Computer Science 9th
      • Pak Studies 9
      • Physics 9th
      • Chemistry 9th
    • Class 10
      • English 10th Notes
      • Biology 10 Class
      • CHEMISTRY 10 NOTES
      • class 10 Maths
      • Pak Study 10th
      • Physics 10
      • Urdu 10
    • Class 11 KPK Notes
      • 11 class biology notes KPK
      • 1st Year Mathematics Notes
      • chemistry class 11 notes
      • English FA Fsc Part 1 KPK
      • Islamiat Class 11 for kpk
      • Physics class 11 notes
    • 2nd Years
      • 2nd Year Chemistry Notes
      • Mathematics-XII
      • 2nd year computer science notes
      • 2nd Year Economics Notes
      • 2nd year English notes
      • 2nd year Pakistan Study Notes
      • 2nd Year Physics Notes
      • Bio Fsc Part 2
    • BISE Swat
      • Result
      • Model Papers
      • Chemistry Class 10 Notes
      • Class 11 Computer Science
      • Economics Notes Class 11
      • Statistics Class 11
      • Class 12 Statistics Notes
    • Syllabus
    • Mardan Board
      • 9th Notes
  • AIOU
    • B.ED books
    • B.S AIOU Books
    • Bachelor AIOU Books
    • CT AIOU Books
    • FA
  • BISE Lahore
    • Class X
      • English Class 10th Notes
    • Class IX
      • English Class 9th Notes
    • Class XI
      • English Class 11th Notes
    • Class XII
      • English Class 12th Notes
  • Sindh Board
    • Sindh Textbook Jamshoro
    • Class IX
      • Pak Studies Sindh 9
      • Computer Science 9 Sindh
      • Mathematic Sindh Class 9
      • Chemistry Notes
      • Biology 9
      • Physics
      • Sindh Board English 9th Notes
      • Islamiat Class 9 Sindh
    • Class X
      • Sindh Class 10 Physics
      • Sindh Class 10th English Notes
      • Islamiat Class 10 Sindh
    • Class XI
      • Islamiat
      • English notes class 11 Sindh board
    • Class XII
      • English Notes Sindh board 12th
  • CBSE
    • CBSE Class 9
    • CBSE Class 10
    • CBSE Class 11
    • CBSE Class 12
  • Rawalpindi Board
    • Class 9th
      • English 9th Notes
      • Biology G9
    • Class 10th
      • English 10th Notes
    • Class 11th
      • English 11th Notes
  • FBISE
    • 9 Class
      • Computer Science
      • Biology Notes
      • 9th FBISE Maths
      • Fbise 9 Notes Eng
    • 10 Class
      • English FBISE Notes
    • 11 Class
      • FBISE English 11th
    • 12 Class
      • Class 12 English Notes Fbise
    • FBISE Past Papers
      • 10 Class
      • 9th Past Papers
  • Articles
    • Essay
    • A-Z Universities in Pakistan
    • Admissions
    • All Country Independence Day
    • Countries Info
    • FILMORA
    • Education Qoutes
    • Happy Teacher Day
    • Insurance
    • Islamic
    • Muslim Boys names
    • Nelson’s Mandela
    • PHILONTHROPIC PRACTICES
    • Speeches
    • Story
  • DIT
  • DAE
  • MCQs
  • Technology
    • Marketing Think with Google
    • Science
  • Punjab board
    • Class 11 Notes PTBB
      • Computer Science PTBB Class 11
      • English 11 Notes Punjab
      • Chemsitry PTBB 11th
      • Math Notes PTBB 11th
      • Physics PTBB 11th
      • Urdu PTBB 11th
      • Biology 11th PTBB
    • Class 9
    • Punjab Class 10th
    • Punjab Board Class 10 Chemistry

© 2021 Perfect24u | All Rights Reserved

 

Loading Comments...
 

You must be logged in to post a comment.