You are on page 1of 10

S

Computer Programming Lab


CSL-113

Lab Journal 1

Student Name : UROOJ TARIQ


Enrolment No.: 01-134211-097
Class and Section : BSCS A1

Department of Computer Science

er:
Task # 1.1:

• Write the following program in your particular IDE and compile it.
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{

_getch();
return 0;
}

If there are compiler errors correct them and compile again. What is the output of the
program?

There is no compiler error

In case you didn't have any typing errors on your first attempt, we'll introduce some now.
Change the word cout in the source program to couts and try to compile the program. How
does your compiler inform you of this error?
Correct the error introduced in the above step, and then remove the semicolon from the end
of the first line. Try to compile this altered version. How does your compiler respond?

Omit the statement return 0; from the program and record the error.
Result/Output:

Analysis/Conclusion:

We learn the basic structure of c++ and learn to debug the error

Task # 1.2:

Write this code in your compiler, see its output and write it below.
#include <iostream>
#include <conio.h>
using namespace std;
int main ()
{
cout << “#\n$$\n@@@\n****\n#####\n”;
_getch();
return 0;
}

Result/Output:

Analysis/Conclusion:

We use \n. the function of \n. is move the cursor to next line

Task # 1.3:
Write this code in your compiler, see its output and write it below.

#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout<<"subject " <<"\tmarks"<<"\nenglish\t"
<<90<<"\nmaths\t"<<77<<"\nphysics\t"<<69;

_getch();
return 0;
}

Result/Output:

Analysis/Conclusion:

We learn the use of \t. the purpose of \t. is to create 8 spaces


Task # 1.4:

Manipulators are operators that are used with insertion operator (<<) to control format of data.
A very useful manipulator is ‘endl’ which stands for ‘end of line’.
It inserts a new line and is used as follows:

cout << “This is a test message “ << endl;


cout << “This is a” << endl << “test message “ << endl;

Write the program using endl manipulator to display the following text:
C++
programming is not
that though

Code:
#include <
#include <conio.h>
using namespace std;
int main()iostream>
{
cout << "C++" << endl;
cout << "programming is not" << endl << "that tough" << endl;

_getch();
return 0;
n
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
cout << "this is the text messege" << endl;
cout << "this is a" << endl << "text messege" << endl;

_getch();
retur0;
}

Result/Output:
Analysis/Conclusion:

In this we learn how to use "endl" and insert a new line

Task # 1.5:
Write a program that prints any two shapes as follows : 
Code:

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
cout << "*********\n" << "*\t" << "*\n";
cout << "*\t" << "*\n" <<"*\t" <<"*\n" <<"*\t" <<"*\n";
cout << "*\t" <<"*\n" <<"*\t" <<"*\n" <<"*\t" <<"*\n" << "*********";

_getch();
return 0;
}

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
cout << " *\n" << " ***\n" << " *****\n";
cout << " *\n" << " *\n" << " *\n";
cout << " *\n" << " *\n" << " *\n";
_getch();
return 0;
}
Result/Output:
Analysis/Conclusion:

In this we write a program to get different shapes like;square and arrow

Write a program that asks the user to enter two numbers, obtains the two numbers from
the user and prints the sum, product, difference, average and quotient of the two
numbers. The screen dialogue should appear as follows : 
Enter two different positive integers (First one should be greater than the second):  
23 12 
Sum is 35 
Product is 276 
Difference is 11 
Average is 7 
Quotient is 11 

You might also like