Assignment C++

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

ASSIGNMENT – 1

Q.1 What are the applications of C++?

C++ is a versatile language for handling very large programs. It


is suitable for virtually any programming task including
development of editor, compiler, databases, communication
systems and any complex real-life application systems. Also, the
idea of c++ comes from C increment operator ++, thereby
suggesting that C++ is an augmented (incremented) version of
C.

1) Since C++ allows us to create hierarchy-related objects, we


can build special objects – oriented libraries which can be
used later by many programmers.

2) While C++ is able to map the real world problem properly,


the C part of C++ gives the language the ability to get close
to the machine-level details.

3) C++ programs are easily maintainable and expandable.


When a new feature needs to be implemented, it is very
easy to add to the existing structure of an object.

4) It is expected that C++ will replace C as a general purpose


language in the near future.

Q.2 What are the advantages of OOPS?

Object-Oriented Programming has the following advantages

1) OOP provides a clear modular structure for programs which


makes it good for defining abstract data types where
implementation details are hidden and the unit has a clearly
defined interface.

2) OOP makes it easy to maintain and modify existing code as


new objects can be created with small differences to
existing ones.
3) OOP provides a good framework for code libraries where
supplied software components can be easily adapted and
modified by the programmer. This is particularly useful for
developing graphical user interfaces.

4) Allows communication between object to object.

5) Software complexity can easily be managed.

6) The principle of data hiding helps the programmer to build


secure programs that cannot be invaded by code in other
parts of the program.

Q.3 Write a program to check whether the year entered by the


user is an leap year or not?

#include<iostream.h>

#include<conio.h>

Void main ( )

int y;

cout<<”Enter the Year”;

cin>>y;

if (year%4==0)

cout<<”It is a Leap Year”;

else

cout<<”Not a Leap Year”;

Getch ( )

}
Q.4 How to make a source file in C++?

Like C program, C++ program can be created using any text


editor. For example, on the UNIX, we can use vi or ed text editor
for creating and editing the source code. On the DOS system, we
can use edlin or any other editor available or a word processor
system under non-document mode.

Some systems such as Turbo C++ provide an integrated


environment for developing and editing program. Appropriate
manuals should be consulted for complete details.

The file mane should have a proper file extension to indicate that
is a C++ program file. C++ implementation use extensions such
as .c, .C, .cc, .cpp, and.cxx. Turbo C++ and Borland C++ use .c
for C programs and .cpp ( c plus plus ) for C++ program. Zortech
C++ system uses .cxx while UNIX AT&T version uses .C (Capital
C) and .cc. The operating system manuals should be consulted to
determine the proper file name extensions to be used.

Q.5 What is Storage Class?

Storage class defined for a variable determines the accessibility


and longevity of the variable. The accessibility of the variable
relates to the portion of the program that has access to the
variable. The longevity of the variable refers to the length of time
the variable exists within the program.

Types of Storage Class Variables in C++:

1) Automatic

2) External

3) Static

Q.6 Write a program to check whether entered alphabet by


the user is a vowel or not?
#include<iostream.h>

#include<conio.h>

Void main ( );

clrscr ( );

char vow;

cout<<”Enter the alphabet”<<endl;

cin>>vow;

switch (vow)

case ‘a’:

case ‘e’:

case ‘i’:

case ‘o’:

case ‘u’:

cout<<”this is a vowel”;

break;

cout<<”this is not a vowel”;

Getch ( );

You might also like