Professional Documents
Culture Documents
BY:-
STUDYING AT :-
usman.ghani599@gmail.com , usman.ghani@live.in
1
CONTENTS
Part A
Sr. No. Chapter Page No. Remarks
2
Part B
C++ Programming
Sr. No. Contents Page no. Remarks
1. Write a program to add two no.s 17
2. Write a program to find the area of 18
square, rectangle and triangle
3. Write a program to interchange the 19
value of two no.s without using third
variable
4. Write a program to check whether 20
the no. is prime or not
5. Write a program to find greatest of 21
three no.s using nested if else
6. Write a program to display week days 23
using switch statement
7. Write a program to print the following 25
pattern
*
**
***
****
*****
8. Write a program to find the factorial 26
of no. using while loop
9. Write a program to add the series of 27
odd no.s
10. Write a program to print Fibonacci 28
series
11. Write a program to compare two 29
matrices
12. Write a program to multiply two 31
matrices
13. Write a program to check whether a 33
3
string is palindrome or not
14. Write a program to reverse a string 35
15. Write a program to print bio data of 35
five students using structure
16. Write a program to swap two no.s by 38
using passing by value and passing by
reference
17. Write a program to find factorial of 39
no. using recursion
18. Write a program to calculate and print 40
smallest no. by using the concept of
classes
19. Write a program to show multiple 43
inheritance
20. Write a program to show use of 44
parameterized constructor and copy
constructor
21. Write a program to compute sum of 47
two no.s using function overloading
22. Write a program to use unary and 48
binary operator overloading
23. Write a program to display concept of 52
pointers
4
Chapter 1
Functioning of computer:- The computer consists of mainly three parts namely Input system,
Central Processing Unit & Output Unit. As shown in figure1
Figure 1
Input Unit:- The input unit is formed by the input devices attached to the computer. Examples
of Input media are: keyboard, mouse, magnetic ink character reader, optical mark reader,
optical character reader, joystick etc.
An input unit takes the input and converts it into binary form so that it can be
understood by the computer.
Central Processing Unit(CPU):- The CPU is the control centre for the compuetr. It guides and
governs the performance. It Consists of Arithmatic Logic Unit (ALU) & Control Unit (CU).
Output Unit:- The output unit is formed by the output units connected to the computer. It
converts the computer understandable language into the human understandable language.
5
How To Powere On a PC:-
6
Figure 2
7
Figure 3
8
Chapter 2
Closing window:-To close the window which in front of you have to move the mouse to the
cross button(Figure 4) then click it, window will closed.
Figure 4
Maximising:-To maximise the icon you have to click the maximise button shown in Figure 4 at
no. 2. The window will fit to screen.
Icon Shifting:-The icons can be shifted from one place to another by dragging and dropping
them to other place.
1. Right click on the desktop at blank space the screen comes as show in Figure 5
Figure 5
9
Chapter 3
Protecting document:- To protect we have to follow the following steps (Figure 6):-
Figure 6
Unprotecting document:-To unprotect the document open the security options and remove
the password as shown in Figure 6.
10
Chapter 4
6. Click O.K.
11
Chapter 5
Control Panel:- It is the functioning part of computer which operates the settings of computer,
in it we can set all the computer peripherals according to our need. To open the control panel
follow simple steps:-
3. Now u can manage the things shown in the control panel window(Figure 7).
Figure 7
12
Chapter 6
MS WORD
Word Processors are the class of software application that is designed for generating various
documents like letter, faxes, resume, memorandum and notices etc. Word Processing software provides
a set of tools and utilities for entering, editing and formatting text. In addition to typical word processing
tasks, modern word processors like MS Word, offer many interesting features like drawing various
objects, creating tables, inserting pictures and many more.
Features of MS word
Starting Word
To start word click once on the Start button, Choose Programs and click once on Microsoft
Office and then once on Microsoft Word.
13
Parts of MS-Word Window
TITLE BAR: It is the horizontal bar at the top of the window. It contains the name of the
current document. Until you save the document, WORD automatically assigns a name. The title
bar contains three buttons at its right end. These are the buttons to minimize, restore and close
the current window.
MENU BAR: It is a horizontal bar, below the title bar that contains several menus. Each of
these menus contains several MS WORD commands and utilities.
File: - the file menu displays the several menu commands .The file menu is used to perform a
variety of file and printing operations. The main menu selections or commands in the file pull
down menu are: - New, Open, save, Save as, Properties, Templates, Page setup, Print Preview,
print, send, Exit and some currently used and saved document files.
Edit: -The edits menu displays several menu commands like: -Cut, Copy, Paste, Clear, select all,
Find, Replace, Goto, Bookmark.
14
Window: - The window menu displays these commands: -New window, arrange all, split, and
some document filename.
Help: - Help menu displays: -Microsoft word help topics, Answer wizards,
STANDARD TOOL BAR: It is a horizontal bar that appears below the menu bar. It contains
shortcut command buttons. These buttons are the shortcuts to access standard menu
commands.
RULERS: Horizontal and vertical rulers appear on the top and left hand side of the page. They
help us to create and move the objects with accuracy.
PAGE AREA: The rectangular white area is the page of the document.
SCROLL BARS: Horizontal and vertical scrollbars are used to scroll the document to the left,
right, up and down.
DRAWING TOOLBAR: A horizontal bar at the bottom is called drawing toolbar. It contains
the several drawing tools.
STATUS BAR: Below the drawing toolbar, status bar is located. This bar depicts the status of
the current document. It displays the current page number, section number, and page
number/total number of pages in the document.
(i) Application window: The area from the title bar till status bar.
(ii) Document window: The area between the ruler bar and the scroll bar
15
Opening an existing document
Go to file menu and click the open command or click on the open button of the standard toolbar
or press Ctrl+O from the keyboard.
Saving a Document
For this purpose either click the save command from the file menu or press Ctrl+S or move the
mouse pointer to the save button on the standard toolbar. A save as dialog box will be shown in which
type the file name in the filename box and click OK button. The word document is saved with .doc
extension.
Go to file menu and click the Close command or press Alt+F+C from the keyboard.
16
Deleting a character
You can delete a character by moving the cursor to the desired location and press the Del key.
The del key deletes the character to the of cursor position. There is another key backspace key, which is
used to delete the character to left of the cursor position.
Inserting a character
You can insert a character by moving the cursor to the desired location with mouse or
keyboard so that the insert mode becomes on.
To cut the text click the cut button from the standard toolbar or select the cut command from
the edit menu or press Ctrl+X key combination. To cut the desired text highlight the text by selecting it
and use any cut way. To copy the text by highlighting it then click the copy button from the standard
toolbar or select the copy command from the edit menu or press the Ctrl+C key combination from the
keyboard. Now you can paste the text by copy command. To paste the text move the cursor to the
desired location where you want to paste and click the paste button from the standard toolbar or select
the paste command from the edit menu or press Ctrl+V combination from the keyboard.
Highlight the text by selecting it and click center button on the formatting toolbar or press
Ctrl+E combination from the keyboard.
17
If you want to set the selected text or paragraph or whole document at the left margin
alignment then first highlight the required text by selecting it, now either move the mouse pointer to
Align left button on the formation toolbar or press Ctrl+L key combination from the keyboard.
First highlight the required text by selecting it. Now either move the mouse printer to Align right
button or the formatting toolbar or press Ctrl+R key combination from the keyboard.
First highlight the required text by selecting it. Now either move the mouse pointer to the justify
button on the formatting toolbar or press Ctrl+J key combination from the keyboard.
Page Breaks
You can insert a manual page break any time you want to force Word to start a new page. To
insert a page break, move the cursor where you want to set the page break. You can select Break
command from the insert menu and click the break command.
18
Chapter 8
Programming in C++
#include<iostream.h>
#include<conio.h>
void main()
int a,b,c;
cin>>a;
cin>>b;
c=a+b;
getch();
Output:-
19
2.Write a program to find the Area of Triangle, Rectangle & Circle:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
float c,d,e,f,g,h,i,j;
cin>>c;
cin>>d;
e=(c*d)/2;
cin>>f;
cin>>g;
h=f*g;
cin>>i;
j=3.14*i*i;
getch();
20
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int a,b;
cin>>a;
cin>>b;
a=a+b;
a=a-b;
b=a+b;
b=a-b;
21
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int n,r,i,flag=0;
cout<<"ENTER A NUMBER";
cin>>n;
i=2;
while(i<=n-1)
r=n%i;
i++;
if(r==0)
22
flag=1;
break;
}}
if(flag==0)
cout<<"NUMBER IS PRIME";
getch( );
Output:-
5.Write a program to find the greatest of three n o.s using nested if else:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int a,b,c;
cin>>a;
cin>>b;
23
cin>>c;
if(a>b)
if(b>c)
else
cout<<" ";
else
if(b>c)
else
getch();
Output:-
24
6.Write a program to display week days using switch:-
#include<iostream.h>
#include<conio.h>
void main()
int a;
cin>>a;
switch(a)
case 1:
cout<<"Sunday";
break;
case 2:
cout<<"Monday";
break;
case 3:
cout<<"Tuesday";
break;
case 4:
cout<<"Wednesday";
break;
case 5:
cout<<"Thursday";
25
break;
case 6:
cout<<"Friday";
break;
case 7:
cout<<"Saturday";
break;
default:
getch();
Output:-
26
7.Write a program to printfollowing pattern:-
**
***
****
*****
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
int i,j;
for(i=1;i<=5;i++)
for(j=1;j<=i;j++)
cout<<"*";
cout<<endl;
getch();
27
}
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int a,i,fact=1;
cout<<"Enter integer:";
cin>>a;
i=a;
while(a)
fact=fact*a;
--a;
28
}
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int n,sum=0,i=1;
cin>>n;
do
{ sum=sum+i;
i=i+2;
29
}
while(i<=n);
cout<<"1+3+5+...""is"<<n<<sum; }
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
clrscr();
first=0;
second=1;
cin>>n;
30
cout<<"Fibonacci series is"<<"n";
cout<<first<<" "<<second;
third=first+second;
cout<<" "<<third;
first=second;
second=third;
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int A[2][2],B[2][2],r,c,flag=0;
for(r=0;r<2;r++)
31
{
for(c=0;c<2;c++)
cin>>A[r][c];
for(r=0;r<2;r++)
for(c=0;c<2;c++)
cin>>B[r][c];
for(r=0;r<2;r++)
for(c=0;c<2;c++)
if(A[r][c]!=B[r][c])
flag=1;
break;
if(flag==1)
break;
if(flag==1)
32
else
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int r,k,c,A[2][2],B[2][2],sum[2][2];
for(r=0;r<2;r++)
33
for(c=0;c<2;c++)
cin>>A[r][c];
for(r=0;r<2;r++)
for(c=0;c<2;c++)
cin>>B[r][c];
for(r=0;r<2;r++)
for(c=0;c<2;c++)
sum[r][c]=0;
for(k=0;k<2;k++)
sum[r][c]=sum[r][c]+A[r][k]*B[k][c];
}}
for(r=0;r<2;r++)
for(c=0;c<2;c++)
cout<<sum[r][c]<<endl;
34
getch();
Output:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
char str[10];
int i,j,n,flag=0;
gets(str);
35
n=strlen(str);
for(i=0,j=n-1;i<=n/2;i++,j--)
if(str[i]!=str[j])
flag=1;
break;
if(flag==1)
else
getch();
Output:-
36
14.Write a program to reverse a string:-
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
char str[10];
gets(str);
strrev(str);
getch();
Output:-
#include<iostream.h>
#include<conio.h>
37
void main()
clrscr();
struct biodata
char name[80];
int rollno;
char branch[80];
int semester;
};
biodata student[5];
cout<<"Enter name";
cin>>student[i].name;
cout<<"Enter roll_no."<<endl;
cin>>student[i].rollno;
cout<<"Enter branch"<<endl;
cin>>student[i].branch;
cout<<"Enter semester"<<endl;
cin>>student[i].semester;
38
for(i=0;i<=4;i++)
cout<<"Name:"<<student[i].name<<endl;
cout<<"Roll no:"<<student[i].rollno<<endl;
cout<<"Branch:"<<student[i].branch<<endl;
cout<<"Semester:"<<student[i].semester<<endl;
getch();
}}
Output:-
39
16.Write a program to swap two no.s using passing by value and passing by reference:-
#include<iostream.h>
#include<conio.h>
void main()
int x,y;
void swap(int,int);
clrscr();
cin>>x;
cin>>y;
swap(x,y);
cout<<"x="<<x<<endl;
cout<<"y="<<y<<endl;
getch();
int temp;
temp=a;
a=b;
b=temp;
cout<<"a="<<a<<endl;
cout<<"b="<<b<<endl;
40
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int fact(int);
int f,n;
cin>>n;
f=fact(n);
cout<<"Factorial is"<<f<<endl;
getch();
int value=1;
if (n==1)
41
return value;
else
value=n*fact(n-1);
return value;
}}
Output:-
18.Write a program to calculate and print smallest of two no.s using concept of classes:-
#include<iostream.h>
#include<conio.h>
class a
private:
int a,b;
public:
void get()
42
{
cin>>a;
cin>>b;
}};
class b
private:
int a,b;
public:
void show()
if(a<b)
cout<<"B is smallest";
else
cout<<"A is smallest";
}};
void main()
a obj;
b obj1;
obj.get();
obj1.show();
43
}
Output:-
#include<iostream.h>
#include<conio.h>
class a
public:
void getdata()
}};
class b
public:
void getdata1()
}};
class c
44
{
public:
void getdata2()
}};
public:
void getdata3()
}};
void main()
clrscr();
a obj;
b obj1;
c obj2;
m obj3;
obj.getdata();
obj1.getdata1();
obj2.getdata2();
obj3.getdata3();
45
getch();
Output:-
#include<iostream.h>
#include<conio.h>
class xyz
public:
int a,b,c;
xyz(int x, int y)
a=x;
b=y;
void sum()
c=a+b;
cout<<c;
}};
46
void main()
clrscr();
int a,b;
cin>>a;
cin>>b;
xyz m(a,b);
m.sum();
getch();
Output:-
Copy constructor:-
#include<iostream.h>
#include<conio.h>
class abc
private:
int a;
float b;
47
public:
abc(int x,float y)
a=x;
b=y;
abc(abc &m1)
a=m1.a;
b=m1.b;
void write()
cout<<a<<b;
}};
void main()
clrscr();
int a;
float b;
cin>>a;
cin>>b;
abc m1(a,b);
48
abc m2=m1;
m2.write();
getch();
Output:-
#include<iostream.h>
#include<conio.h>
return a+b;
return a+b;
void main()
int i,j;
49
float k,l;
int sum(int,int);
float sum(float,float);
cin>>i>>j;
cin>>k>>l;
getch();
Output:-
(a)Unary Operator:-
#include<iostream.h>
#include<conio.h>
class complex
int r;
50
int i;
public:void getdata()
cin>>r;
cin>>i;
void operator++()
++r;
++i;
void showdata()
cout<<r<<"+ i"<<i<<endl;
};
void main()
complex C1;
clrscr();
51
C1.getdata();
C1.showdata();
++C1;
C1.showdata();
getch();
Output:-
(b)Binary operator:-
#include<iostream.h>
#include<conio.h>
class myclass
private:
int s1,s2;
public:
52
myclass(int x,int y)
s1=x;
s2=y;
void show()
cout<<s1<<endl<<s2;
//myclass temp;
s1=s2 +m.s1;
s2=s2+m.s2;
}};
void main()
clrscr();
myclass m1(50,40);
myclass m2(40,50);
//myclass m3;
m1=m1+m2;
m1.show();
53
getch();
Output:-
#include<iostream.h>
#include<conio.h>
void main()
int *p;
int x;
clrscr();
cout<<"Enter a value";
cin>>x;
p=&x;
*p=*p+10;
cout<<"Now x is"<<x<<endl;
54
cout<<"The address of x is"<<&x<<endl;
getch();
Output:-
55