# 1.3 Labworks

 Page 1 / 11

Lab Session 1:

Introduction to C++

Lab Session 2:

Selection Structures

Lab Session 3:

Repetition Structures

Lab Session 4:

Arrays

Lab Session 5:

Structures

Lab Session 6:

Functions

Lab Session 7:

Pointers

Lab Session 8:

Introduction to Classes

Lab Session 9:

Object Manipulation

Lab Session 10:

Inheritance

Programming Project Topic Examples

## 1. objective

The objectives of Lab 1 are (1) to known how to run a simple C++ program; (2) to know the basic data types and operators; (3) to learn how to use variable declarations and assignment statements.

## 2. experiment

2.1) Test the following program:

`#include<iostream.h>`

`int main()`

`{`

`const float PI=3.14159;`

`float radius = 5;`

`float area;`

`area = radius * radius * PI; // Circle area calculation`

`cout<<“The area is “<<area<<“ with a radius of 5.\n”;`

`radius = 20; // Compute area with new radius.`

`area = radius * radius * PI;`

`cout<<“The area is “<<area<<“ with a radius of 20.\n”;`

`return 0;`

`}`

1. Run the above program
2. Use #define to define the constant PI
3. Declare the constant PI in the file “mydef.h”, and then use the #include directive to insert the header file in the above program.

2.2) Debug the following code segment.

`#include<iostream.h>`

`int main()`

`{`

`const int age=35;`

`cout<<age<<“\n”;`

`age = 52;`

`cout<<age<<“\n”;`

`return 0;`

`}`

2.3) What is the result of each following expression:

1. 1 + 2 * 4 / 2
2. (1 + 2) * 4 / 2
3. 1 + 2 * (4 / 2)
4. 9 % 2 + 1
5. (1 + (10 - (2 + 2)))

2.4) Run the following programs and explain their results.

a.

`void main()`

`{`

`short i = -3;`

`unsigned short u;`

`cout<<sizeof(i)<<&i;`

`cout<<sizeof(u)<<&u;`

`cout<<(u = i)<<"\n";`

`}`

b.

`void main()`

`{`

`byte i = 125*4/10;`

`cout<<i<<"\n";`

`}`

2.5) Write a program that inputs two time points and display the difference between them.

2.6) Run the following programs and explain their results:

a.

`#include<iostream.h>`

`int main()`

`{`

`int f, g;`

`g = 5;`

`f = 8;`

`if ((g = 25) || (f = 35))`

`cout<<“g is “<<g<<“ and f got changed to “<<f;`

`return 0;`

`}`

b.

`#include<iostream.h>`

`void main()`

`{`

`if (!0)`

`{ cout<<“C++ By Example \n”; }`

`int a = 0;`

`if ( a !=0&&2/a>0 )`

`cout<<“hello”;`

`}`

2.7) Write a program that inputs the three grades for mathematics, physics and chemistry. And then it displays the average of the three grades in the following format:

## 1. objective

The objective of Lab 2 is to practice C++’s selection structures, such as:

• if
• if … else
• switch

## 2. experiment

2.1) Run the following program:

`// BEEP : ‘\x07’`

`#include<iostream.h>`

`#define BEEP cout<<“\a \n”`

`int main()`

`{`

`int num;`

`cout<<“Please enter a number “;`

`cin>>num;`

`if (num == 1)`

`{ BEEP; }`

`else if (num == 2)`

`{ BEEP; BEEP; }`

`else if (num == 3)`

`{ BEEP; BEEP; BEEP; }`

`else if (num == 4)`

`{ BEEP; BEEP; BEEP; BEEP; }`

`else if (num == 5)`

`{ BEEP; BEEP; BEEP; BEEP; BEEP; }`

`return 0;`

`}`

2.2) Run the following program:

`#include<iostream.h>`

`#define BEEP cout<<“\a \n”`

`int main()`

`{`

`int num;`

`cout<<“Please enter a number “;`

`cin>>num;`

`switch (num)`

`{`

`case (1): { BEEP;`

`break; }`

`case (2): { BEEP; BEEP;`

`break; }`

`case (3): { BEEP; BEEP; BEEP;`

`break; }`

`case (4): { BEEP; BEEP; BEEP; BEEP;`

`break; }`

`case (5): { BEEP; BEEP; BEEP; BEEP; BEEP;`

Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
anyone know any internet site where one can find nanotechnology papers?
research.net
kanaga
sciencedirect big data base
Ernesto
Introduction about quantum dots in nanotechnology
what does nano mean?
nano basically means 10^(-9). nanometer is a unit to measure length.
Bharti
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
absolutely yes
Daniel
how to know photocatalytic properties of tio2 nanoparticles...what to do now
it is a goid question and i want to know the answer as well
Maciej
Abigail
for teaching engĺish at school how nano technology help us
Anassong
Do somebody tell me a best nano engineering book for beginners?
there is no specific books for beginners but there is book called principle of nanotechnology
NANO
what is fullerene does it is used to make bukky balls
are you nano engineer ?
s.
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
Tarell
what is the actual application of fullerenes nowadays?
Damian
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
Tarell
what is the Synthesis, properties,and applications of carbon nano chemistry
Mostly, they use nano carbon for electronics and for materials to be strengthened.
Virgil
is Bucky paper clear?
CYNTHIA
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
NANO
so some one know about replacing silicon atom with phosphorous in semiconductors device?
Yeah, it is a pain to say the least. You basically have to heat the substarte up to around 1000 degrees celcius then pass phosphene gas over top of it, which is explosive and toxic by the way, under very low pressure.
Harper
Do you know which machine is used to that process?
s.
how to fabricate graphene ink ?
for screen printed electrodes ?
SUYASH
What is lattice structure?
of graphene you mean?
Ebrahim
or in general
Ebrahim
in general
s.
Graphene has a hexagonal structure
tahir
On having this app for quite a bit time, Haven't realised there's a chat room in it.
Cied
what is biological synthesis of nanoparticles
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!