You are on page 1of 6

Bridge Course Assignment (C ++)

BRIDGE COURSE
Program number - 09(C++)

SUBMITTED BY:
ROHIT KHATRI (CSE/14/320)

Department of Computer Science Engineering and Information Technology


SHRI BALWANT INSTITUTE OF TECHNOLOGY
Approved by AICTE, Min of HRD, Govt of India & DTE, Govt of Haryana
Affiliated Affiliated to DCR University, Sonepat
Meerut Road (Pallri), Near DPS, Sonepat-131001, Haryana

Bridge Course Assignment (C ++)

Bridge Course (C ++)


General Instructions:
1. Strictly follow the C++ coding guidelines.
a. Use class and functions! Make your code modular. Single function (only
main() having the complete code is not acceptable).
b. Document your code: comment on every function's arguments and return
value. Give a brief description of the important features.
c. Use indentation of 4 spaces. Do not use tab in code
d. Use meaningful variable and function names. Simply writing I, j, tmp is not
acceptable.
e. Source code should be in more than 1 file. This is to be compiled and linked
separately.
2. These projects are individual. Please write in comments at the beginning of each
program your name, roll no, batch, semester, date of submission, faculty in-charge.
3. No documentation is required
4. Following must be submitted in the order given below:
a. Print of this document
b. Print of the code (do not format the code in MS word)
c. Complete compilation steps followed while compiling the programme. Clearly
mention the exact commands as used on the command prompt and explain the
meaning of each command.
d. Give details of all the intermediate files made during the compilation steps.
Explain the complete process of compilation pass 1, pass 2, linking and
loading.
e. Complete execution steps followed while executing the programme. Clearly
mention the exact commands as used on the command prompt and explain the
meaning of each command.
f. Program output
5. At the time of presentation complete project must be explained with detailed code
walkthrough. Evaluation will be done based on the following:
a. Project report in the given template

Bridge Course Assignment (C ++)

b. In depth understanding of the project


c. Presentation
d. Viva-voce
Note: All the Programs should be done on Linux Putty only.
Program 9:
Write a program that accomplishes each of the following:
Create a user-defined class Complex that contains the private integer data members real
and imaginary and declares stream insertion and stream extraction overloaded operator
functions as friends of the class.
Define the stream insertion and stream extraction operator functions. This stream
extraction operator function should determine whether the data entered is valid, and, if
not, it should set the fail bit to indicate improper input. The input should be of the 3+8i.
The values can be negative or positive and it is possible that one of the two values not
provided. If a value is not provided, the appropriate data member should be set to the
stream insertion operator should not be able to display the point if an input error is
occurred. For negative imaginary values, minus sign should be printed rather than a plus
sign.
Write a main function that tests input and output of user-defined class Complex, using the
overloaded stream extraction and stream insertion operators.

Bridge Course Assignment (C ++)

COMPILATION PROCESS
Write your C++ program first. Use a text editor such as vi to create a C++ program called
Complex.cpp , ComplexInput.cpp and Complex.h you need to use syntax as follows:
vi Complex.cpp
vi ComplexInput.cpp
vi Complex.h
To compile C++ program you need to use syntax as follows:
g++ -c Complex.cpp
g++ -c ComplexInput.cpp
Writing Your First C++ Program Under Linux :
To compile C++ program Complex.cpp , ComplexInput.cpp, and create an executable file
called output, enter:
g++ o output Complex.cpp ComplexInput.cpp
To execute program first, enter:
./output
INTERMEDIATE FILES
These are the files which are made during program.
ComplexInput.cpp is the file which contain main() of the program and it includes a
headerfile Complex.h
Complex.cpp is the file which contains the definition of the function declared in the
headerfile Complex.h
Complex.h is the user defined headerfile
output is the executable file which is made after the execution of the command
g++ -o output Complex.o ComplexInput.o
g++ compiler acts as both linker and loader.

Bridge Course Assignment (C ++)

COMMAND USED ON COMMAND PROMPT


If the source code is in several files, say "Complex.cpp" and "ComplexInput.cpp", then they
can be compiled into an executable program named "output" using the following command:
g++ o output Complex.o ComplexInput.o
The same result can be achieved using the following three commands:
g++ -c Complex.cpp
g++ -c ComplexInput.cpp
g++ o output Complex.o ComplexInput.o
The advantage of the second method is that it compiles each of the source files separately. If,
for instance, the above commands were used to create "output", and "ComplexInput.cpp" was
subsequently modified, then the following commands would correctly update "output".
g++ -c ComplexInput.cpp
g++ o output ComplexInput.cpp Complex.cpp
Note that Compile.h does not need to be recompiled, so the time required to rebuild output is
shorter than if the first method for compiling output were used. When there are numerous
source file, and a change is only made to one of them, the time savings can be significant.
This process, though somewhat complicated, is generally handled automatically by a
makefile.
OUTPUT

Bridge Course Assignment (C ++)

You might also like