0% found this document useful (0 votes)
3 views7 pages

FOCSE

The document outlines various categories of programming languages, including System, Architectural, and Application languages, each serving different purposes in software development. It also explains the concepts of Object-Oriented Programming (OOP) and highlights the differences between C and C++. Additionally, it provides examples of C++ programs and short notes on functions, arrays, pointers, structures, constructors, and destructors.

Uploaded by

Kalu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

FOCSE

The document outlines various categories of programming languages, including System, Architectural, and Application languages, each serving different purposes in software development. It also explains the concepts of Object-Oriented Programming (OOP) and highlights the differences between C and C++. Additionally, it provides examples of C++ programs and short notes on functions, arrays, pointers, structures, constructors, and destructors.

Uploaded by

Kalu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Q. 3) What are the categories of programming languages?

System Languages

… best used to build operating systems, hardware drivers etc. Fast and gives you low level
(close to the core) access to the computer. These languages are used when speed is critical.

These languages include:

 C
 C++
 Assembler
Architectural Languages

… best used to build frameworks that support (make easy) application building. Not as fast (at
run-time) as system level languages, but they provide a higher level of abstraction that makes
writing software quicker and more productive.

These languages include:

 Java
 C#
Application Languages

… best used to build the actual business applications like web shopping carts/stores,
connecting to databases and creating the screens for users to interact with the database.

These languages include:

 PHP
 Ruby
 Perl
 Python
These language all allow for extremely fast development.

Programmers are freed from the low-level details that you have to contend with when working
with architectural and system level languages.

The fact that they’re all scripting languages (that don’t need to be compiled,) adds to the ease of
use and speed of development.

Q.4) What are the concepts of OOP?


Object oriented programming is a way of solving complex problems by breaking them into
smaller problems using objects. Before Object Oriented Programming (commonly referred as
OOP), programs were written in procedural language, they were nothing but a long list of
instructions. On the other hand, the OOP is all about creating objects that can interact with each
other, this makes it easier to develop programs in OOP as we can understand the relationship
between them.
The following are the features of OOP;
1.Data Abstraction
2.Data encapsulation
3. Inheritance
4. Polymorphism

Q.5) Write the difference between C and C++.

C language was developed in C++ language was


1972 by Dennis Ritchie. developed in 1980 by
Bjarne Strostroup.

C is a Procedural Oriented C++ is an Object


Programming language. Oriented Programming
language.

C has Top Down programming C++ has Bottom Up


approach. programming
approach.

The extension of a c program The extension of a c+


is is .c + program is .cpp

In c programming language, a In c++ programming


big problem divides into small language, a big
pieces known as functions; this problem divides into
approach of programming is Classes and Objects.
known as Modular
programming.

Structure in C does not have Structure in C++


function declaration features provide the feature of
i.e. we cannot declare a declare a function as
function as member function of member function of
structure in C. structure
Q.6) Write a Program in C++ to :
(i) Add to numbers.
#include <iostream>
using namespace std;
int main(){
//Declaring two integer variables
int num1, num2;
/* cout displays the string provided in the
* double quotes as it is on the screen
*/
cout<<"Enter first integer number: ";
/* cin is used to capture the user input
* and assign it to the variable.
*/
cin>>num1;

cout<<"Enter second integer number: ";


cin>>num2;
cout<<"Sum of entered numbers is: "<<(num1+num2);
return 0;
}
Output:

Enter first integer number: 10


Enter second integer number: 20
Sum of entered numbers is: 30

(ii) Swap two numbers


#include <iostream>
using namespace std;

int main()
{
int num1, num2, temp;
cout<<"Enter 1st Number: ";
cin>>num1;
cout<<"Enter 2nd Number: ";
cin>>num2;

//displaying numbers before swapping


cout<<"Before Swapping: First Number: "<<num1<<" Second Number:
"<<num2;

//swapping
temp=num1;
num1=num2;
num2=temp;

//displaying numbers after swapping


cout<<"\nAfter Swapping: First Number: "<<num1<<" Second Number:
"<<num2;
return 0;
}

(iii) Print pyramid


#include <iostream>
using namespace std;

int main()
{
int i,j,k,space=10; // to print the pyramid in center, you can also
increase the # of spaces

for (int i=0;i<=5;i++)


{
for (int k=0;k<space;k++)
{

cout<<" ";
}
for (int j=0;j<2*i-1;j++)
{

cout<<"*";}
space--;
cout<<endl;
}

(iv) To show use of class and object


class Test
{
private:
int data1;
float data2;
public:
void function1()
{ data1 = 2; }

float function2()
{
data2 = 3.5;
return data2;
}
};

int main()
{
Test o1, o2;
}

(v) To show inheritance

#include <iostream>

using namespace std;

/*Base Class*/

class A

public:

void Afun(void);

};

// function definiion

void A::Afun(void)

cout << "I'm the body of Afun()..." << endl;

/*Derived Class*/
class B:public A

public:

void Bfun(void);

};

// function definition

void B::Bfun(void)

cout << "I'm the body of Bfun()..." << endl;

int main()

//create object of derived class - class B

B objB;

// Now, we can access the function of class A (Base class)

objB.Afun();

objB.Bfun();

return 0;

Q.7) Write short notes on


(i) Functions
A function is a group of statements that together perform a task. ... A function declaration tells
the compiler about a function's name, return type, and parameters. A function definition
provides the actual body of the function. The C++ standard library provides numerous built-
in functions that your program can call.

(iii) Arrays
An array is a collection of similar items stored in contiguous memory locations. In programming,
sometimes a simple variable is not enough to hold all the data.
(iii) Pointers
A pointer is a variable that holds a memory address where a value lives. A pointer is declared
using the * operator before an identifier. As C++ is a statically typed language, the type is required to
declare a pointer.

(iv) Structures
Structure is a collection of variables of different data types under a single name. It is similar to a
class in that, both holds a collecion of data of different data types.

(v) Constructor and destructor


Constructors are special class functions which performs initialization of every object. The
Compiler calls the Constructor whenever an object is created. Constructors initialize values to
object members after storage is allocated to the object.
Whereas, Destructor on the other hand is used to destroy the class object.

You might also like