Vous êtes sur la page 1sur 3

Lab Journal – 1 Instructor: Awais Mehmood

Computer Programming Lab


Lab Journal – 1 (Lecture 1, 2, and 3)
Name: __________________________________

Enrollment #: __________________________________

Date: __________________________________

Objective:
1) Practicing Simple Program
2) Practicing how to Write a Program

Tools Required:

a) PC with Windows 7 or Higher


b) Dev C++

Attempt the following tasks.


Task 1 : Attempt the following :
1. include <iostream>
using namespace std;

int main() {
cout << "Newline character:"<<" \n"<<" ending" <<
endl; // Newline character
cout << "Tab character:"<<" \t "<<"ending" << endl; //
Tab character
cout << "Backspace character:"<<" \b"<<" ending" <<
endl; // Backspace character
cout << "Backslash character:"<<" \\ "<<"ending" <<
endl; // Backslash character
cout << "Null character:"<<" \0 "<<"ending" << endl;
//Null character
system("pause");
return 0; }

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
cout << "***************" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "| |" << endl;
cout << "***************" << endl;
getch();
}

Computer Programming Lab


Page 1
Lab Journal – 1 Instructor: Awais Mehmood

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

void main()
{
cout << "Manahil Imran" << endl;
cout << "01-134162-019" << endl;
cout << "1.86" << endl;
_getch();
}

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

int main ()
{
int count = 10;
cout<< “count =“ <<count;
cout<< “count=”<< ++count;
cout<< “count=”<<count++;
cout<<“count=”<<count;
return 0;
}

Lab-Task

1. Input three integer values from keyboard into variables a, b and c and add them. Store
the result in another variable named as Result.
2. Assign the product of variables b and c to a as entered by the user.
3. What prints when each of the following c++ statement is executed? Assume x=2 and
y=3.
cout<<x;
cout<<x+x;
cout<<“x=“;
cout<<“x=“<<x;
cout<<x+y<<“=“<<y+x;
4. Write a program that calculates the square of a number entered by the user and
displays output as below.

Value Square
4 12

Computer Programming Lab


Page 2
Lab Journal – 1 Instructor: Awais Mehmood

5. Print the following outputs using cout.

* * *
*** *** ***
***** ***** *****
******* ******* *******
********* ********* *********

Attempt all tasks and get them checked by your instructor. If you are unable to complete a
task in lab then submit a hardcopy of the task alongwith the journal in the next lab.

Task Completed Checked By:


1.
2.
3.
4.
5.

Computer Programming Lab


Page 3

Vous aimerez peut-être aussi