You are on page 1of 89

c  

p   


+    

Microsoft Office 2000 is a software suite that consists of different applications that
complete different activities. MS Office 2000 is by far the most widely recognized
software suite in the world.

p   à - Microsoft Word 2000 provides powerful tools for creating and
sharing professional word processing documents.

p 
 à - With Microsoft Excel 2000, you can create detailed spreadsheets for
viewing and collaboration. Create customized formulas for your data and analyze it with
the easy to construct charts.

p   à - Microsoft PowerPoint 2000 provides a complete set of tools for
creating powerful presentations. Organize and format your material easily, illustrate your
points with your own images or clip art, and even broadcast your presentations over the
web.

p  à - Microsoft Access 2000 gives you powerful new tools for managing
your databases. Share your database with co-workers over a network, search and retrieve
information quickly, and take advantage of automated, pre-packaged wizards and
solutions to quickly create databases.

p   à - Microsoft Publisher 2000 helps you easily create, customize, and
publish materials such as newsletters, brochures, flyers, catalogs, and Web sites. Publish
easily on your desktop printer




Word Processor is a Software package that enables you to create, edit, print and save
documents for future retrieval and reference. Creating a document involves typing by
using a keyboard and saving it. Editing a document involves correcting the spelling
mistakes, if any, deleting or moving words sentences or paragraphs.

The followings are examples of some popular word processor available

m WordStar
m Word perfect
m Microsoft word

p 

MS-WORD is a part of the MS OFFICE. It not only supports word processing features
but also DTP features. Some of the important features of Ms-Word are listed belowà

m "sing Word, a document could be created and edited later, as and when required,
by adding more text, modifying the existing text, deleting/moving some part of it.
m Changing the size of the margins can reformat complete document or part of text.
m Font size and type of fonts can also be changed. Page numbers and Header and
Footer can be included.
m Spelling can be checked and correction can be made automatically in the entire
document. Word count and other statistics can be generated.
m Text can be formatted in columnar style as we see in the newspaper. Text boxes
can be made.
m Tables can be made and included in the text.
m Word also allows the user to mix the graphical pictures with the text. Graphical
pictures can either be created in word itself or can be imported from outside like
from Clip Art Gallery.
m Word also provides the mail-merge facility.
m Word also has the facility of macros. Macros can be either attached to some
function/special keys or to a tool bar or to a menu.
m It also provides online help of any option.



p

Start MS-WORD by the following wayà

1. Take the mouse pointer to START button on the task bar. Click the left mouse
button. The monitor will show like as followsà
Ô Move the pointer to ã !". You will notice another menu coming up to the
right.

3. In that menu identify where p    is placed. Move the cursor
horizontally to come out of ã !".
4. Move into the rectangular area meant for p  #Click the left mouse
button there. The computer will start MS-WORD. You will find the screen as
follows.



 ! !  " $

"sing the mouse click on the % menu. Select   and select  !& " . A new
Blank document appears on the screen.

!'  ! " 



To save a document at any time, select !' option from the % menu or press (
keys together. Give appropriate pathname to save the document.

ã !    " 

From the % menu, select ã  option. In the Look In box, Click the drive that contains
the document, in the list of files, click the document name.

   ! " 

To close a document, from the File menu, select   option.



g#  ! ! "   ! !  ã   ã!&! ) & 
p ) ! ! ã!! !ã! ã "    
ã ! $

#   "! g !  "! *#+, 
#     !  ! "!&   # !   - #
# .    ã       " ! !  "
! 
'#  ã  &!   " ! /
'#  "!  "   !  
' #
! ã!! !ã0! 1  ! ã! ! /
' #  !  ! !  
' #  "  !   
#  "!   !   
#    !   2 " "2/" 

  $


Start MS-WORD program. Open a new document and enter any two paragraphs of text.

i. Margin Setting

m On the % menu, select !  ã, and then select the p!  tab.
m In the left box enter the value as 1"
m In the right box enter the value as 0.75"

ii. Center the heading and make it bold. Increase the font size

Select (block) the heading line; click the    button in %"! tool bar.
Select 3 button from the %"! tool bar (or from the Format menu, select
% option and then select Font Style as 3 ). To increase the font size, from
the %"! menu select % option and then select sizes from  - pop down
menu and press OK.

iii. "nderline the specified words in the document and change them to italics

Select the specified word and click the .   button. If you click the same
button again, the underline is removed. To make the word italics from the
%"! menu, select %) then change the % / to !  (or select +
button from the %"! tool bar).
iv. Conduct spell check and correct them suitably

Place the curser in the beginning of the file. From the   menu, select
Spelling! !""!. It checks the spelling and displays ! à box to
replace the word that word could not be found in the open dictionaries. Accept
the word in Change Toà box type the correct word or select word in the
   box or select   box.

v. "se numbering and bullets as used in the document

Select the items to which you want to add bullets or numbers. On the %"!
toolbar, to add, click the Bullets button or to add numbering, click the
Numbering button. Otherwise from the %"! menu, select the 3  ! 
"   option and select appropriate.

vi. Exchange paragraphs 2 and 3 using cut and paste facility.

Select paragraph 2 and from


 menu select Cut. Go to end of paragraph 3
and press ENTER key. In
 menu, select ! .

vii. Put suitable Header and Footer



From the 4  menu, choose  !  !  % . In the Header & Footer
toolbar, select the   3    !  5 %  button to move to the
header or footer area. The Header and footer areas are enclosed by a non-
printing dashed line. Type the text with in the dashed line that surrounds the
header and footer area. To return to the document, choose C  button on the
Header and Footer Toolbar.

viii. Count the number of words and lines


Select   option from the   Menu.

ix. "se of drawing tools

m From the 4  menu, choose  !, from that click on ! 
option and observe that a drawing menu appears at the bottom of the
document.
m To draw a  ! click on the icon and drag the mouse on the
document space to get the required size of rectangle.
m To draw a   or '! click on the icon and drag the mouse on
the document space to get the required size of Circle/Oval.
m To draw a (  click on the icon and drag the mouse on the
document space to get line of required length.
m To draw an  click on the icon and drag the mouse on the
document space to get an arrow of required length.
m When we move the mouse cursor on the icons of the drawing menu, we
get information about the respective icons, using it
m We can insert Text box, Clip Art or Word Art by clicking on the  
3 )  ã!)  ! icons respectively.
m We can change the color of the font, line or background color by
clicking on % )(    and %   respectively, and then
choosing the desired color.
m We can change the Style of line, dash & arrow by clicking on (  
/ )!/ and / respectively and choosing the desired
style from the given choice.
m We can insert Different types of Lines, Basic shapes, Block arrows,
Flow chart Symbols, Stars and Banners, Call outs by clicking on
!ã , and selecting the required option.
m We can give 3D and shadow effects for the shapes by clicking 1 and
!  icons respectively.

x. Including logo/emblem/symbol

m From   menu choose /" option from it select the required
symbol and click on insert button.
m From   menu choose Picture then select the  ã ! or " 
option and insert the desired logo or emblem present in them.





















0#  ! !"!     ! !  ã   ã!&! ) & 
p )ã ! !ã!  ã " &)
!'       "! #

Details of the book No.of
Sl.No Title of the Author Edition Publication Copies
book



  $

m Create a new document. Type the required matter for the letter.
m To insert a table, from the ! menu, select   option, click on ! )we
get a window for table. Enter the value of "    " field as 6, and
desired value in " field.
m Enter the table headings in the first row and make it    and 3 #
m Fill the table with some data (for example) as given below.
m To sort on any one column, select the column. Then from ! Menu, select the
 Option. The default order is ascending order and if required change the order
to descending. And then press OK.

 #     
   !  #
# 3& ã 
1. Computer Basse and Allen 2000 Addison 25
Algorithms, Wan Gelder Wesley
Introduction to
Design and
Analysis
2. Data Structures, Sartaj Sahni 1998 McGraw-Hill 10
Algorithms, and
Applications in
C++,











  ! ""! !  ã

  

DOS (an acronym for Disk Operation System) is a tool which allows you to control the
operation of the IBM PC.

To work on DOS first click on !button then select ã !" then choose
!   and then click on ""! "ã.

67!   /""! 

We can move from directory to directory using the CD command (change directory)

Exampleà

m C> cd furniture

Moves you to the directory called 'F"RNIT"RE'

m C> cd \furniture\cd..

Takes you back to the previous directory

8""! 

The COPY command can be used both to copy files from disk to disk or to create a
second copy of a file on a single disk.

Exampleà

m C> copy càword1.doc aà

Copies the file 'word1.doc' from the C drive to the A drive and gives it the
same name.
6  /7""! 

The DIRECTORY command lists the names and sizes of all files located on a particular
disk.

Exampleà

m C> dir
m Shows directory of drive C
m C> dir /w
m Shows directory in wide format, as opposed to a vertical listing.

ã 

The use of wild cards '*' and '?' is illustrated below.

Exampleà

m C> dir cà*.ex

Lists all files on the C drive with an extension of 'EXE'.

m C> dir dàccp*

Lists all files on the B drive with a filename starting from the word 'ccp'.

m The asterisk is a wild-card character which allows the user to enter only a
limited part of a file specification to find a file. It is useful when you wish to
locate a group of files with the same filename or the same extension.
m On other occasions you may have forgotten part of a file specification. You
can use '*' in place of the parts of the specification you have forgotten.
m Similarly, '?' permits wild-card searches keyed to single characters.

Exampleà

m C> dir aàlabe?.com

Lists all five-letter files with the first four letters 'LABE' and an extension of
'COM'.


%p""! 

To format new disks. The format command checks a diskette for flaws and creates a
Y  where all the names of the diskette's files will be stored.

Exampleà

m C> format aà

Formats the diskette in the A drive.

p96p7p!&   /""! 

This command creates a new directory.

Exampleà

m C> mkdir mine

Creates a directory called 'MINE'


p
6
7""! 

The RENAME command permits users to change the name of a file without making a
copy of it.

Exampleà

m C> ren aàgoofy.txt pluto.txt

Changes the name of 'GOOFY.TXT' on the A drive to 'PL"TO.TXT'.

p67 "'   /""! 

This command removes a directory and all its contents.

Exampleà
m C> rd mine

Removes directory called 'MINE'.

8%(


To copy a file (named „  ) to a new file named  , enterà

m C> copy oldfile newfile

The file   will have exactly the same contents as the file „  .

(

(

If you don't remember a command name, typeà

help

and DOS will provide a complete list of command names. If you don't remember the
syntax for the command, type a   followed by the command nameà

help command_name

Exampleà

help date

3%(


Batch files are not programs, they are list of command line instructions that are V Y
together in one file.
3.  ! !   !! 
(#3 ã'   
 ã! /    ""! : ! ) " #

 !"$

Help date
Help time

  $
1) Open Command prompt type Dà\> edit <filename>.bat

2) Type the program in Edit Window.

3) save file name by selecting ALT+F -> Save

4) Exit from the EDIT by pressing ALT+F -> Exit



5) In command prompt type the file name Dà\> <filename>.bat to Execute

ã$

Dà\>HELPDOS

Displays or sets the date.

DATE [/T | date]

Type DATE without parameters to display the current date setting and a prompt for a
new one. Press ENTER to keep the same date.

If Command Extensions are enabled the DATE command supports the /T switch which
tells the command to just output the current date, without prompting for a new date.
Displays or sets the system time.

TIME [/T | time]

Type TIME with no parameters to display the current time setting and a prompt for a new
one. Press ENTER to keep the same time.

If Command Extensions are enabled the TIME command supports the /T switch which
tells the command to just output the current time, without prompting for a new time.
6  !  !    !  !   p8p4
#3   0 ã!!"  )
  ! !   /6 ' /ã!!"  g7! "'   6 ' 
/ã!!"  07"    /  / !   /#


 !"$

rem mymove.bat (Comment line)


md %1
echo %1 directory created«.
move %2 %1
dir %1
pause

Dà\>mymove msrit testing.bat


msrit directory created...
Volume in drive D is WIN-2000
Volume Serial Number is 4426-26FC

Directory of Dà\msrit

09/26/2006 12à47p <DIR> .


09/26/2006 12à47p <DIR> ..
09/26/2006 12à44p 248 testing.bat
1 File(s) 248 bytes
2 Dir(s) 11,614,203,904 bytes free
Press any key to continue . . .












,#   !ã !"  ! ã!  ! ' ;! ! 
<! )-    #6.     ! " 7


  "$

Step 1à Begin
Step 2à [Read the values for the coefficients a, b and c]
Read a,b,c
Step 3à IF a is equal to 0 or b is equal to 0 or c is equal to 0
THEN Write ³Invalid inputs´, go to Step 15
Step 4à [Compute] disc B b2 ± 4 * a * c
Step 5à IF disc is less than 0 go to Step 6
ELSE go to Step 10
Step 6à Write ³Complex roots´
GV
Step 7à [Compute the real part,] real B

Step 8à [Compute the imaginary part,] imag B sqrt(abs(d))


Step 9à Write ³root1 = real µ+ i¶ imag and root2 = real µ- i¶ imag´. Go to Step 15
Step 10à IF disc is equal to 0 go to Step 11
ELSE go to Step 13
GV
Step 11à compute the equal roots root1 B root2 B root1
2*
Step 12à Write root1, root2, go to step 15
Step 13à Compute root1 B- b+sqrt(d)/2*a root2 B- b ± sqrt(d)/2*a
Step 14à Write root1, root2
Step 15à End
% !$

Start

Read coefficients of the


quadratic equation a, b, c


Is (a == 0)



disc B b * b - 4 * a * c Write
³Invalid Inputs´

m a
Is disc<0  

Write
real µ+i¶ imag
and real-i imag Is disc>0

GV
root1 B
| disc | 2*
root1 B- b+
2* root2 B root1
| disc |
root1 B- b -
2*
Write
root1 and root2

Write

 root1 and root2



 a
Stop

 !"$

/* To find the roots of a given quadratic equation */

#include <stdio.h>
#include <math.h>

void main( )
{
float a, b, c;
float disc, root1, root2;
float real, imag;

printf("\n Enter the Coefficients of the Equation à ax2+bx+c=O ? à ");


scanf("%f%f%f",&a, &b, &c);

if( a = = 0 || b= =0 || c= =0) /* Check for non-zero coefficients */

printf("\n\n Errorà Coefficients value must be Non-Zero...");


else

{
disc = b * b - 4 * a * c;
if(disc < 0 ) { /* Caseà imaginary roots */
printf("\n\n Roots are Imaginary...");
real = -b / (2 * a);
imag = sqrt(fabs(disc)) / (2 * a);
printf("\n\n Complex Root1 = %7.4f +i %7.4f",real, imag);
printf("\n Complex Root2 = %7.4f -i %7.4f",real, imag);
}
else if( disc = = 0 ) { /* Caseà real and identical roots */
printf("\n\n Roots are Real & Identical...");
root1 = -b / (2 * a);
root2 = root1;
printf("\n\n Root1 = %7.4f",root1);
printf("\n Root2 = %7.4f",root2);
}
else { /* Caseà real and distinct roots */
printf("\n\n Roots are Real & Distinct...");
root1 = (-b + sqrt(disc)) / (2 * a);
root2 = (-b - sqrt(disc)) / (2 * a);
printf("\n\n Root1 = %7.4f",root1);
printf("\n Root2 = %7.4f",root2);
}
}
} /* End of main( ) */

ã$
1) Enter the Coefficients of the Equation à ax2+bx+c=0 ? à
000
Errorà Coefficients value must be Non-Zero...

2) Enter the Coefficients of the Equation à ax2+bx+c=0 ? à


121
Roots are Real & Identical...
Root1 = -1.0000
Root2 = -1.0000

3) Enter the Coefficients of the Equation à ax2+bx+c=0 ? à


156
Roots are Real & Distinct...
Root1 = -2.0000
Root2 = -3.0000

4) Enter the Coefficients of the Equation à ax2+bx+c=0 ? à


123
Roots are Imaginary...
Root1 = -1.0000 + i 1.4142
Root2 = -1.0000 ± i 1.4142
6#   !ã !" " ! ! "ã !  !!ã "
! "  ã !  & !  )! )"  ã ! )! 
'   /  #
" !    ã ) !/
! "ã "!  ' /- #6.   ! " 7

% !$
 Start

Read two integer


numbers a, & b

Read the operation code


to opcode

µ+¶ for Addition

opcode µG¶ for Subtraction

µ*¶ for


;#@>?
#
;#=>? #
;#=G?
;#@A?
#
;#@A?
;#@2?
#
;#@2?
result B a + b result B a G b result B a * b Write ³Invalid
Operation code´
%!  
b b .EQ. 0
 a

 Write result  

 result B a / b
a


 Stop b
 Write
 ³Division by
 ZERO error´



a



/* To simulate a simple calculator that performs arithmetic operations */

#include <stdio.h>

void main( )
{
int a, b;
char opcode;
clrscr( );
printf("\n Enter any two Integers ? à ");
scanf("%d%d",&a, &b);

printf("\n Enter the Operation Code ? à ");


printf("\n + -> Addition ");
printf("\n - -> Subtraction");
printf("\n * -> Multiplication");
printf("\n / -> Division");
fflush(stdin);
printf("\n Operation Code à");
opcode = getche( );

switch(opcode) {

case '+' à printf("\n\n Result = %d", a + b);


break;
case '-' à printf("\n\n Result = %d", a - b);
break;
case '*' à printf("\n\n Result = %d", a * b);
break;
case '/' à if( b = = 0)
printf("\n\n Errorà divide by zero...");
else
printf("\n\n Result = %d", a / b);
break;
default à printf("\n\n Not a valid Operation Code...");

} /* End of main( ) */

ã$

Enter any two Integers ? à 8
2

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à+

Result = 10

Enter any two Integers ? à 3


4

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à-

Result = -1

Enter any two Integers ? à 6


5

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à*

Result = 30

Enter any two Integers ? à 49


7

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à/

Result = 7

Enter any two Integers ? à 9


0

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à/

Errorà divide by zero...

Enter any two Integers ? à 6


7

Enter the Operation Code ? à


+ -> Addition
- -> Subtraction
* -> Multiplication
/ -> Division
Operation Code à%

Not a valid Operation Code...










+#   !ã !"  ! ! ã  @?% ! 
" #6.   ã  7#

  "

Step 1à Begin
Step 2à [Read the value of n]
Input n.
Step 3à [Initialize] fib1B 0 and fib2B 1
Step 4à IF n = = 0 THEN Write ³Errorà Input non-zero positive number´.
ELSE IF n = = 1 THEN Write the value of fib1.
Step 5à ELSE
[Generate Fibonacci Numbers]
Write the value of fib1, fib2.
Repeat Step 6 for i =3 to i = n
fibBfib1+fib2.
Write the value of fib.
fib1Bfib2.
Fib2Bfib.
Step 6à End.
% !$ Start


Read the number n

fib1 B 0
fib2 B 1

Is n.= 0


Print ³Input 

Non-Zero 
Is n=1 Print fib1
Positive Number
Only´



Print fib1, fib2
a


i=3
b i <= n 
a
i+1

 Stop

fib B fib1 + fib2

Write fib

fib1 B fib2
b fib2 B fib
 !"$

/* To generate and print first N fibonacci numbers */

#include <stdio.h>

void main( )
{
long int n, i, fib1 = 0, fib2 = 1, fib;

printf("\n Enter the value for N ? à ");


scanf("%ld",&n);

if(n = = 0)
printf("\n Errorà Input non-zero Positive Number...");
else if(n = = 1) {
printf("\n The Generated Fibonacci Number isà \n");
printf("\n %ld",fib1);
}
else {
printf("\n The Generated Fibonacci Numbers areà \n");
printf("\n %ld\t%ld",fib1, fib2);

for (i = 3; i <= n; i++) {


fib = fib1 + fib2;
printf("\t%ld",fib);
fib1 = fib2;
fib2 = fib;
}
}

} /* End of main( ) */

ã$
1) Enter the value for N ? à 0
Errorà Input non-zero Positive Number...
2) Enter the value for N ? à 1
The Generated Fibonacci Number isà 0
3) Enter the value for N ? à 10
The Generated Fibonacci Numbers areà
0 1 1 2 3 5 8 13 21 34
’#   !ã !"   ! (p  ! 
ã   !     '   #. 
 ?
!  "#6.   ã  7

  "$

Step 1à Begin
Step 2à [Input value of numbers]
Read a,b
Step 3à [Duplicate values of a and b]
ma nb
Step 4à[use Euclid¶s algorithm]
Repeat step 4 while(n !=0)
remm mod n
mn
nrem
End while
Step 5à [Compute L.C.M and print result]
Lcm (a*b)/m
Print¶G.C.D¶=m,¶L.C.M¶=lcm
Step 6à End

Start


Read any two Integer
numbers m & n

pBm
qBn

Is n!=0

rem=m%n
m=n
n=rem

GCD B m
LCM B (p * q) / GCD

Write GCD, LCM

Stop
 !"$

/* To find GCD and LCM of 2 integer numbers */

#include <stdio.h>

void main( )
{
int m, n, rem, GCD, LCM, p, q;

clrscr( );

printf("\n Enter any Two Integer Numbers ? à ");


scanf("%d%d",&m, &n);
p = m;
q = n;

while((q != 0) {
rem=p%q;
p=q;
q = rem;
}

GCD = p;
LCM = (m * n) / GCD;
printf("\n\n The GCD and LCM for Integers %d and %d are à %d &
%d",m, n, GCD, LCM);

} /* End of main( ) */

ã$

Enter any Two Integer Numbers ? à 24 6

The GCD and LCM for Integers 24 and 6 are à 6 & 24


{#   !ã !" '  ! '    " ! 
 &    !ã!  " #ã  ' " 
  ! " ! #6.   ã  7

  "

Step 1à Begin
Step 2à [Read the value of n]
Read n.
Step 3à [Initialize the value ] revB0,sumB0.
Step 4à IF n >= 0 tempBn
do
digitBn mod 10
revBrev*10+digit.
n=n/10.
While(n!=0)
Step 5à IF(rev= =temp)
THEN Write ³The Number is Palindrome´.
ELSE
Write ³The Number is not a Palindrome´.
Step 6à End.

% !$
 Start

Read the number n

Write ³Input
Positive 
Is n = 0
Number Only´


a rev B 0
sum B 0
temp B n

digit B n %10
rev B rev * 10 + digit
n B n / 10

Is n =0 



Write rev

Write ³Number
Is rev .= temp 
³, temp, ³is not a
Palindrome´


Write ³Number
³, temp, ³is a
Palindrome´

a Start

 !"$

/* To reverse a given integer number and check whether it is a palindrome or not */
#include <stdio.h>
void main( )
{
int n, temp, digit, rev = 0, sum = 0;
clrscr( );
printf("\n Enter the Number ? à ");
scanf("%d",&n);

if( n >999&&n<10000)
{ temp = n;

do {
digit = n % 10;
rev = rev * 10 + digit;
sum += digit;
n /= 10;

} while (n != 0);

printf("\n The Reversed Number of %d Isà %d",temp, rev);

if (rev = = temp)

printf("\n\n The Number %d is Palindrome...",temp);


else
printf("\n\n The Number %d is not a Palindrome...",temp);
}
else

printf("\n\n Input 4 digit Number Only...");

} /* End of main( ) */

ã$
1) Enter the Number ? à 1234321
The Reversed Number of 1234321 Isà 1234321
The Number 123421 is Palindrome...",
2) Enter the Number ? à1234
The Reversed Number of 123 Isà 4321
The Number 1234 is not a Palindrome...",

10.   !ã !"    ! ' "  ã " #
ã  ' "   ! " ! #6.   ã  7

  "$

Step 1àBegin
Step 2à[Input the number]
Read n
Step 3à [Initialize flag]
Flag  1
Step 4à [check for division of n]
Repeat step 4 for i2 to n/2
If n%i=0
Flag0
Goto step5
End if
Step 5à [output the result]
If flag=1
Print´prime number´
Else
Print´not a prime number´
Step 6à end

% !
 Start


Read number n


n .GT. 0

Write ³Input

non-zero flag B 1
Positive
Number Only´
i=2
i <= n/2

 i+1
b



rem B n%i



Is rem .=. 0 


flag B 0

Write n ³is not a


flag .EQ. 1 
prime number´


Write n ³is a prime number´ b

 !"$
b

Stop
/* To find whether a given number is a prime or not and output suitable message
*/

#include <stdio.h>

void main( )
{

int n, i, flag;

clrscr( );

printf("\n\n Enter Any Number To Check for a Prime Number ? à ");


scanf("%d",&n);

if(n == 0)
printf(³enter non zero value´);
else if(n==1)
printf(³\n neither prime nor composite´);
else
{

flag=1;
for (i = 2; i <= n / 2; i++)
if (n % i = = 0) {

flag = 0;
break;
}
if (flag)
printf("\n\n %d Is a Prime Number.. ",n);
else
printf("\n\n %d Is Not a Prime Number.. ",n);
}

} /* End of main( ) */

ã$
1) Enter Any Number To Check for a Prime Number ? à 4
4 Is Not a Prime Number..
2) Enter Any Number To Check for a Prime Number ? à 17
17 Is a Prime Number.
:3
gg#   !ã !" ã ! "  !     !  
"  !!/# ! !/ !! ' & /  " 
!  ã !    "! ! " ! .

  "

Step 1à Begin
Step 2à [Read the value for number of elements in n]
Read n.
Step 3à Repeat Step 3 for iB0 to n
Read a[i]
Step 4à Read the value of keyno.
Step 5à [Initialize the value ]
lowB0.
highBn-1.
flagB0.
Step 6à Repeat Step 6 While(low<=high)
midB(low+high)/2.
IF (keyno < a[mid])
high = mid - 1;
ELSE IF(keyno > a[mid])
low = mid + 1;
ELSE
flag1B1
Go to Step 7
Step 7à IF (flag = = 1)
THEN Write ³ Success Element is found´
ELSE
Write ³Failure Element not found´
Step 8à End.








% !
 Start

Read number of
elements to n

Write ³Enter numbers in ascending order´

 i=0
 i<n


i+1


Read the number ai

Read key to be
searched to keyno

flag B 0
low B 0
high B n-1

b Is low .<= high 


a

lo D 

mid B 2

c
c

Is keyno .<. amid 



b high Bmid - 1

keyno .GT. amid 



b high Bmid + 1

flag B 1


flag .EQ. 1


Write ³Failure, Write ³Success,
key element´, element´, keyno,
keyno, ³is not ³is found in the
found´ position´, mid

Stop
 !"$

/* To find a keyno in a list of N numbers ordered in ascending using binary
search */

#include <stdio.h>

void main( )
{
int n, a[25], keyno, i, j;
int low,mid,high,flag;

clrscr( );

printf("\n Enter the Number of Elements ? à ");


scanf("%d",&n);
printf("\n Enter the Elements (in Ascending Order) ? à ");
for (i = 0; i < n; i++)
scanf("%d",&a[i]);

printf("\n Enter the KeyNo to be Searched ? à ");


scanf("%d",&keyno);

low = 0;
high = n-1;
flag = 0;

while (low <= high) {

mid = (low + high) / 2;


if (keyno < a[mid])
high = mid - 1;
else if(keyno > a[mid])
low = mid + 1;
else
{
flag=1;
break;
}
}

if(flag)
printf("\n\n S"CCESS! Element %d Found in Position
%d",keyno,mid+1);
else
printf("\n\n FAIL"RE! Element %d Not Found",keyno);

} /* End of main( ) */

ã$

1) Enter the Number of Elements ? à 5


Enter the Elements (in Ascending Order) ? à 2 6 8 10 12
Enter the KeyNo to be Searched ? à 10
S"CCESS! Element 10 Found in Position 4.

2) Enter the Number of Elements ? à 5


Enter the Elements (in Ascending Order) ? à 1 2 3 4 5
Enter the KeyNo to be Searched ? à 6
FAIL"RE! Element 6 Not Found
g0#   !ã !" ã  "  !  
"  !!/# " !       
  < #   ' !!/!   !!/ 
 !  !  #


  "$

Step 1àBegin
Step 2à[Read the size of array]
Read n
Step 3à [Input n numbers]
Repeat step 3 for i0 to n
Read a[i]
Step 4à [set the loop for passes]
Repeat step 5 for i 1 to n
Step 5à [swap the elements]
Repeat step 5 for j 0 to n-1
If a[j] > a[j+1] then
[Swap a[j] and a[j+1]]
Temp=a[j]
A[j]=a[j+1]
A[j+1]=temp;
Step 6à [Output the sorted array]
Repeat step 6 for i0 to n
Print a[i]
Step 7à end
% !
 Start

Read number of elements to n

i=0
i<n 

i+1


a
Read the number i

Write ³input array is


given below´

i=0
i<n 

i+1

Write ai 

i=0
a 
i<n-1
i+1

j=0

b j<n±i 

j+1



Is aj > aj+1


temp B aj
aj B aj+1
aj+1 B temp
a

Write ³sorted array´

i=0
i<n 

i+1

Write ai 

Stop

 !"$

/* To sort N numbers in ascending order using bubble sort */

#include <stdio.h>

void main( )
{
int n, a[25], i, j, t;

clrscr( );
printf("\n Enter the Number of Elements ? à ");
scanf("%d",&n);
printf("\n Enter the Elements ? à ");
for (i = 0; i < n; i++)
scanf("%d",&a[i]);

printf("\n\n Given Array Is à\n\n");


for (i = 0; i < n; i++)
printf("\t%d",a[i]);

for(i = 0; i < n-1; i++)


for(j = 0; j < n ± i-1; j++)
if(a[j] > a[j+1])
{

t = a[j];
a[j] = a[j+1];
a[j+1] = t;
}

printf("\n\n Sorted Array Is à \n\n");


for( i = 0; i < n; i++)
printf("\t%d",a[i]);

} /* End of main( ) */

ã$


Enter the Number of Elements ? à
5

Enter the Elements ? à


99
23
45
11
35

Given Array Is à

99 23 45 11 35

Sorted Array Is à

11 23 35 45 99








g1#   !ã !" '! !   ' ã /" ! 6 7B!C C>
!1 1>!0 0>!g >!* ' '!   !       
 ?"  #6.     "  !!/    7

  "

Step 1à Begin
Step 2à [Read the order n and value of x].
Step 3à [Read the coefficients]
Repeat Step 3 for iB0 to n
Read a[i]
Step 4à [Initialize value of P(x)]
pxBa[n]
iBn
Step 5à [Compute Polynomial]
Repeat step 5 while i0
pxBx*px + a[i-1]
i=i-1
Step 6à [Output the polynomial]
Print px
Step 7à End.
















% ! 

 Start

Read value of n and x

i=0
i <= n 

i+1


 
Read the coefficient ai

px B a[n]
iBn

Is i!=0

px B x * px + a[i-1]
iBi-1

Write ³Value of given


polynomial is ³, px

Stop
 !"$

/* To evaluate the polynomialà P(x) = anxn + an-1xn-1 + ... +a1x1 + a0 */

#include <stdio.h>

void main( )
{

float a[20], x, px;

int n,i;

clrscr( );

printf("\n Enter the order of Polynomialà");


scanf("%d",&n);

printf("\nEnter the Value of x ? à ");


scanf("%f",&x);

printf("\nEnter the Coefficients starting from constant term\n ");


for ( i = 0; i <= n; i++)
{
Printf(³a[%d] = ³,i);
scanf("%f",&a[i]);
}

px = a[n];
i=n;
While (i!=0)
{
px = x * px + a[i-1];
i--;
}

printf("\nValue of given polynomial is %f ", px);

} /* End of main( ) */

ã$
Enter the order of Polynomialà 5
Enter the Value of x ? à 1.5
Enter the Coefficients starting from constant term
a0=1 a1=2 a2=3 a3=4 a4=5 a5=5
Value of given polynomial is = 95.125000
gC#   !ã !" ! "!  6p 7! 36 ;7! "ã  
ã ! 3!  &  "ã!  /"  ã ! #ã  ã
"!  !    !"!   !  !  ! "!#6.  
"  !!/  !!/ - p)));DE17
  "$
Step1 à Begin
Step2 à [Input order of matrix A]
Read m,n
Step3 à [Input order of matrix B]
Read p,q
Step4 à [Check for multiplication]
if(n!=p) then,
Print µNot multiplicable¶
goto Step 9
Step5 à[Input elements of matrix A]
Count for rows
Repeat Step 5 through 6 for iB0 to m
Step6 à [Count for columns]
Repeat Step 6 for jB0 to n
Read a[i][j]
Step7 à[Input elements of matrix B]
Count for rows
Repeat Step 7 through 8 for iB0 to p
Step8 à [Count for columns]
Repeat Step 8 for jB0 to q
Read b[i][j]
Step7 à [Compute Product]
Repeat Step 7 through 9 for iB0 to m
Step8 à Repeat Step 8 through 9 for jB0 to q
prod[i][j]=0
Step9 à Repeat Step 9 for kB0 to n
c[i][j]+ = a[i][k] * b[k][j]
Step10 à[Output elements of matrix A]
Repeat Step 10 through 11 for iB0 to m
Step11 àRepeat Step 11 for jB0 to n
Print a[i][j]
Step12 à[Output elements of matrix B]
Repeat Step 12 through 13 for iB0 to p
Step13 àRepeat Step 13 for jB0 to q
Print b[i][j]
Step14 à[Output elements of resultant matrix C]
Repeat Step 14 through 15 for iB0 to m
Step15 àRepeat Step 15 for jB0 to q
Print c[i][j]
Step16à End
Start
% !$

Read the order of


matrix A to m and n

Read the order of


matrix B to p and q

n .EQ. p Write ³Matrix not



multiplicable´


Read elements a
into matrix A


i=0

i<m
i+1

j=0 
j <n 

j+1

Read aij 

Read elements
into matrix A

x
x

i=0

i<p
i+1

j=0 
j <q 

j+1

Read bij 

i=0
y 
i<m
i+1


j=0
j <q 

j+1


cij B 0

k=0

k<n
k+1


cij B cij + aik * bkj
 y



 Elements of
matrix A are




i=0

i<m
i+1

j=0 
j <n 

j+1

Print aij 



 Elements of
 matrix B are


i=0

i<p z
i+1

j=0 
j <q 

j+1

Print bij 




 z



 Resultant
 Matrix C is


i=0

i<m
i+1

j=0 
j <n 

j+1

Print cij 

Stop


 !"$

/* program for matrix multiplication*/
#include <stdio.h>
#include <math.h>
int a[10][10],b[10][10],c[10][10];
void main( )
{
int m,n,i,j,p,q,k;
clrscr( );
printf("Enter the order of matrix A à ");
scanf("%d%d",&m,&n);
printf("Enter the order of matrix B à ");
scanf("%d%d",&p,&q);
if(n!=p)
{
printf("Multiplication is not possible\n");
getch( );
exit( );
}
printf("Enter the elements ( %d ) for matrix A",m*n);
for(i=0;i<m;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
printf("Enter the elements (%d) for matrix B",p*q);
for(i=0;i<p;i++)
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
printf("Given matrix A is\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d\t",a[i][j]);
printf("\n");
}
printf("Given matrix B is\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d\t",b[i][j]);
printf("\n");
}

for(i=0;i<m;i++)
for(j=0;j<q;j++)
{
c[i][j]=0;
for(k=0;k<p;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
printf("The product of the matrix is \n");
for(i=0;i<m;i++)
{
for(j=0;j<q;j++)
printf("%d\t",c[i][j]);
printf("\n");
}
getch( );
}


ã$

1) Enter the Dimension of Matrix 1 ? à 2 3

Enter the Dimension of Matrix 2 ? à 3 4

Matrices Multiplicable...

Enter The Elements Of Matrix 1 ? à


123
456

Enter The Elements Of Matrix 2 ? à


1111
1111
1111

The Resultant Matrix Is à


6 6 6 6
15 15 15 15

2) Enter the Dimension of Matrix 1 ? à 1 2

Enter the Dimension of Matrix 2 ? à 3 4

Matrices Not Multiplicable...



g,#        
6 7 ã  "  !   "  !!/#
6 7 !  ! !#
.     )  !ã !"! ã   
" 5 ' & /  " !  !  ! !#
 ã !    "! ! " ! #

  "$

Step 1à Begin
Step 2à [Read the value for number of elements in n].
read(n)
Step 4à [Read the value of keyno.]
Step 5à [Search for the given key in the array]
posBlinsrch(n,num,key)
Step 7à IF (pos = = )
THEN Write ³Failure Element not found´
ELSE
Write ³ Success Element is found´
Step 8à End.

 %  ! 
Step 1à Begin
Step 2à Repeat Step 2 for iB0 to n
Read num[i]
Step 3à Return

 %  
Step 1à Begin
Step 2à Value B 0
Step 3à Repeat Step 2 for jB0 to j<n
IF(num[j] = = key)
THEN value=j+1; /* return position of key number for successful search*/
Step 4à Return value
Step 5à Return








% !$
 Start

Read number of
elements to n

Enter numbers one


by one

read(n)

Read the number to be


searched into keyno

linsrch(n,num)

Stop
read(int n)

 i=0
 i<n


i+1

 num
Read the number i

 Return


 linsrch(int n,int num)


Value B0

 j=0
 j< n


j+1

 T
num[j].EQ.Key
ValueB
j+1
 F






 Return Value



 !"$
/* c program to conduct linear search for given key no. in an array of N nos*/
/* "sing one-dimensional arrays and function*/
#include <stdio.h>
#include<conio.h>
#include <math.h>
int num[10];
void read(int n);
int linsrch(int n,int num[10],int key);
void main( )
{
int snum;
int i,j,n,pos;

clrscr( );
printf("How many real nos. to search ?à ");
scanf("%d",&n);
printf("\n\n Enter %d nos. one by oneà \n", n);
read(n);
printf("\n type in the key (real) number to be searched for a matchà");
scanf("%d", &snum);
pos=linsrch(n,num,snum);
if (pos= =0)
{
printf("\n search failure ...!\t");
printf("Given key number %4.2d not found in the array...! \n", snum);
}
else
{
printf("\n Given key number %4.2d found at location %d in the array",snum,pos);
printf("\n Therefore successful search...!\n");
}
getch( );
}

void read(int n)
{
int i;
for(i=0;i<n;i++)
scanf("%d",&num[i]);
}

int linsrch(int n,int num[10],int key)


{
int j,value=0;
for (j=0; j<n;++j)
{
if(num[j] = = key)
{
value=j+1; /* return position of key number for successful search*/
break;
}
}
return(value);
}

ã$

1) How many real nos. to search ?à 5

Enter 5 nos. one by oneà 2.4 3.5 4.1 5.3 9.0



type in the key (real) number to be searched for a match 5.3

Given key number 5.3 found at location 4 in the array
Therefore successful search...!

2) How many real nos. to search ?à 5

Enter 5 nos. one by oneà 2.4 3.5 4.1 5.3 9.0



type in the key (real) number to be searched for a match 10.2

search failure ...!
Given key number %4.2d not found in the array...!















g6#        
6 7 ã  "  !   "  !!/#
6 7   "  !       
  < #
6 7ã     "  !!/ " #
.     )  !ã !" ã  " 
!   "  !!/) " !    )! 
ã   ' !!/5  !!/  !  !  #

% !$


 start

Read number of
elements to n

Enter numbers one


by one

read(n)

Sort()

display(n)

Stop





read(int n)

i=0
i<n 

i+1

a
Read the number i

return

display(int n)

i=0
 i<n
 

i+1



 Display the 
array ai



 return








Sort()

i=0

i < n-1
i+1


j=0
T j < n -1-i 

T j+1

F F

If F
(a[j+1]>a[j])

T
tmp a[j];
a[j] a[j+1];
a[j+1] tmp

Return












 !"$

/* To sort N numbers in ascending order using bubble sort using functions*/

#include <stdio.h>
#include<conio.h>

int n, a[25], i, j, tmp;

void read(int n)
{
for (i = 0; i < n; i++)
scanf("%d",&a[i]);
}

void display(int n)
{
for (i = 0; i < n; i++)
printf("\t%d",a[i]);
}
void sort(int n,int a[])
{
for (i=0; i<n-1; i++)
{
for (j=0; j<n-1-i; j++)
if (a[j+1] < a[j])
{ /* compare the two neighbors */
tmp = a[j]; /* swap a[j] and a[j+1] */
a[j] = a[j+1];
a[j+1] = tmp;
}
}

void main( )
{

clrscr( );
printf("\n Enter the Number of Elements ? à ");
scanf("%d",&n);
printf("\n Enter the Elements ? à ");
read(n);
printf("\n\n Given Array Is à\n\n");
display(n);
sort(n,a);
printf("\n\n Sorted Array Is à \n\n");
display(n);
getch( );

} /* End of main( ) */

ã$

Enter the Number of Elements ? à 4

Enter the Elements ? à 89


45
11
64

Given Array Is à

89 45 11 64

Sorted Array Is à

11 45 64 89


















g+#        
6 7 ã  "  !   "  !!/#
6 7   "         
    < #
6 7ã     "  !!/ " #
.     )  !ã !" ã  " 
!   "  !!/) "      )! 
ã   ' !!/5  !!/  !  !  #

  "

Step 1àbegin
Step 2à [Input array size]
Read n
Step 3à [input elements of array]
Repeat step 3 for i0 to n
Read a[i]
Step 4à [perform selection sort]
Repeat step 4 for i 0 to n-1
iminmin(a,n,i)
Swap(a,i,ismall)
Step 5à [output sorted array]
Repeat step 5 for i0 to n
Print a[i]
Step 6à end

% " 67

Step 1àbegin
Step 2à[Initialize position]
Ismall0
Step 3à [find location of minimum element]
Repeat step3 for ji+1 to n
If a[ismall]<a[j]
Ismall j
Step 4à [return the position]
Return ismall

% !ã67

Step 1à begin
Step 2à [exchange the elements]
ta[i]
a[i] a[imin]
a[imin] a[j]
Step 3à return
% !


Start


Read number of
elements to n

i=0
i<n 

i+1

a
Read the number
 i

i=0
i<n 

i+1


imin B MIN(a, n, i)

Swap(a,imin,i)
i=0
i<n
i+1

Write ai


Stop

Min(int a[],int n,int I)

ismall B i

j=i+1
j <= n 

j+1




aj .GT. small


ismall B j

RET"RN - ismall

swap(int a[],int
imin,int I)

t = a[i];
a[i]=a[imin];
a[imin] = t;

Return




 !"$

#include <stdio.h>
#include <conio.h>

void read(int a[25],int n)


{ int i;
for (i = 0; i < n; i++)
scanf("%d",&a[i]);
}

void display(int a[25],int n)


{ int i;
for (i = 0; i < n; i++)
printf("\t%d",a[i]);
}

/* "ser defined function to find the index of the minimum element in the N elements */
int min(int a[25], int n, int i)
{
int j, ismall;
ismall = i;

for (j = i + 1; j < n; j++)


if (a[ismall] < a[j]) {
ismall = j;
}
return ismall;
}

/* "ser defined function to exchange contents of two positions */

int swap(int a[25], int imin, int i)


{
int t;

t = a[i];
a[i]=a[imin];
a[imin] = t;
return;
}

void main( )
{
int a[25], n, i, imin;

clrscr( );

printf("\nEnter the Number of Elements ? à ");


scanf("%d",&n);
printf("\nEnter the Elements ? à ");
read(a,n);

for (i = 0;i < n-1; i++)


{
imin = min(a, n, i);
swap( a,imin,i);

}
printf("\nThe Final Sorted Array Is à ");
display(a,n);
getch( );

} /* End of main( ) */


ã$

Enter the Number of Elements ? à 5

Enter the Elements ? à 99 12 7 29 456 56


The Final Sorted Array Is à 456 99 56 29 12 7
g’#        
6 7 ã ! "  !   "  !!/#
6 7"ã  " !#
6 7"ã  '! ! 
6 '7"ã  ! !  ' ! #
.     )  !ã !" ã ! " 
!   "  !!/)! "ã  " !)'! ! 5
! !  ' ! #ã "ã     ! 
 !  #

% !

void read(float value[10], int no)

Enter The Elements

i=0
i < no 

i+1


Read value[i]


Return

















 Void maen(float value[10],int
 mean)


 sum B 0

 i=0
 i<n


i+1


Read the number ai

i=0
i<n 

i+1


sum B sum + ai

sum
amean B n

Return




 void variance(float
 value[10],int no,float


sum B 0

i=0
i<n 

i+1
a


sum B sum + (ai G amean) 2



 Return





 Void sid(float var)



 Print sqrt(var)




Return















 Start



 Enter no




 read(a,n);





The mean is à



 mean(a,n)





 The varience is à



 variance(a,n,amean);




 The S.D isà



 sid(var)



 Stop

 !"$
/* To find mean, variance and standard deviation for N real numbers */
#include<stdio.h>
#include<math.h>
void read(float value[25], int no);
void mean(float value[25],int no);
void variance(float value[25],int no,float amean);
void sid(float var);
float a[10],amean, var,sum;
int n,i;
void main( )
{

clrscr( );
printf("\nEnter the no of Elements ? à \n");
scanf("%d",&n);
read(a,n);
printf("\n\nThe Mean is à ");
mean(a,n);
printf("\n\nThe Variance is à ");
variance(a,n,amean);
printf("\n\nThe Standard Deviation is à");
sid(var);
getch( );
} /* End of main( ) */
void read(float value[10], int no)
{

printf("\n\nEnter The Elements ? à \n\n");


for (i = 0;i < no; i++)
scanf("%f",&value[i]);

void mean(float value[10],int no)


{
sum=0;
for ( i = 0;i < no; i++)
sum += value[i];
amean = sum / no;
printf("%f",amean);
}
void variance(float value[10],int no,float amean)
{
sum = 0;
for(i = 0;i < no; i++)
sum += pow((value[i] - amean), 2);
var = sum / no;
printf("%f", var);

void sid(float var)


{
printf("%f",sqrt(var));
}

ã$

Enter the no of Elements ? à


3

Enter The Elements ? à

1
4
6

The Mean is à 3.666667

The Variance is à 4.222222

The Standard Deviation is à2.054805













g{#        
6 7 !   " ! ' "!  - p 
6 7ã   " ! ' "!  - p 
6 7"ã  ã "!  
.     )  !ã !" ! "!  6p 7! 
36 ;7! "ã  ã ! 3! 
 &  "ã!  /"  ã ! #ã  ã"!  
!    !"!   !  !  ! "!#
6.   "  !!/  !!/ - p)));DE17


  "

Step1 à Begin
Step2 à Input order of matrix A
Read m,n
Step3 à Input order of matrix B
Read p,q
Step4 à Check for multiplication
if(n!=p) then,
Print µNot multiplicable¶
goto Step 9
Step5 àInput elements of matrix A
read(a,m,n)
Step6 àInput elements of matrix B
read(b,p,q)
Step7 à Compute Product
multiply(a,b,c,m,n,q)
Step8 à Output the result
display(c,m,q)
Step9 à End



%  ! 

Step1 à Begin
Step2 à Count for rows
Repeat Step 2 through 3 for iB0 to r
Step3 à Count for columns
Repeat Step 3 for jB0 to s
Read mat[i][j]
Step4 à Return



%  ã !/

Step1 à Begin
Step2 à Count for rows
Repeat Step 2 through 3 for iB0 to r
Step3 à Count for columns
Repeat Step 3 for jB0 to s
Print prod[i][j]
Step4 à Return




% "  ã /

Step1 à Begin
Step2 à Repeat Step 2 through 4 for iB0 to m
Step3 à Repeat Step 3 through 4 for jB0 to q
prod[i][j]=0
Step4 à Repeat Step 4 for kB0 to p
prod[i][j]+ = mat1[i][k] * mat2[k][j]
Step5 à Return.

























% !
Start

Read the dimension of


the matrix1 to m and n

Read the dimension of


the matrix2 to p and q

n .EQ. p Write ³Matrix not



multiplicable´


Write ³Matrix a
multiplicable´

READ(mat1, m, n)

READ(mat2, p, q)

M"LTIPLY(mat1, mat2, prod, m, p, q)

DISPLAY(prod, m,q)

Stop
READ(int mat1[][],int
m,int n)

i=0
Return 
i<r
i+1

j=0 
j<s 

j+1

Read matij 

M"LTIPLY(int mat1[][], int mat2[][], int


prod[][], int m, int p, int q)

i=0
Return 
i<m
i+1


j=0
j <q 

j+1


prodij B 0

k=0

k<p
k+1


prodij B prodij + mat1ik * mat2kj
DISPLAY(int prod[][],
int m,int q)

i=0
Return 
i<r
i+1

j=0 
j<s 

j+1


Write prodij

 !"$

/* Develop functionsà i) To read a matrix ii) To output a matrix iii) To compute
the product of two matrices */

#include <stdio.h>
#include <conio.h>

void read(float mat[10][10], int r, int s)


{
int i, j;

for (i = 0;i < r; i++)


for (j = 0; j < s; j++)
scanf("%f",&mat[i][j]);

void multiply(float mat1[10][10], float mat2[10][10], float prod[10][10], int m, int


p, int q)
{
int i, k, j;

for (i = 0;i < m; i++)


for (j = 0;j < q; j++) {
prod[i][j] = 0.0;
for (k = 0;k < p; k++)
prod[i][j] = prod[i][j] + mat1[i][k] * mat2[k][j];
}
}

void display(float mat[10][10], int r, int s)


{
int i, j;

for (i = 0; i < r; i++) {


for (j = 0;j < s; j++)
printf("%.2f ",mat[i][j]);
printf("\n");
}

void main( )
{
float mat1[10][10], mat2[10][10], prod[10][10];
int m, n, p, q;
int i, j, k;

clrscr( );

printf("\nEnter the Dimension of Matrix 1 ? à ");


scanf("%d%d",&m, &n);
printf("\nEnter the Dimension of Matrix 2 ? à ");
scanf("%d%d",&p, &q);

if(n = = p)
{
printf("\nMatrices Multiplicable...");

printf("\n\nEnter The Elements Of Matrix 1 ? à \n\n");


read(mat1, m, n);

printf("\nEnter The Elements Of Matrix 2 ? à \n\n");


read(mat2, p, q);

multiply(mat1, mat2, prod, m, p, q);

printf("\n\nThe Resultant Matrix Is à \n\n");


display(prod, m, q);
}
else
printf("\n\nMatrices Not Multiplicable...");
} /* End of main( ) */

ã$

1) Enter the Dimension of Matrix 1 ? à 2 3

Enter the Dimension of Matrix 2 ? à 3 4

Matrices Multiplicable...

Enter The Elements Of Matrix 1 ? à


123
456

Enter The Elements Of Matrix 2 ? à


1111
1111
1111

The Resultant Matrix Is à


6 6 6 6
15 15 15 15

2) Enter the Dimension of Matrix 1 ? à 1 2

Enter the Dimension of Matrix 2 ? à 3 4

Matrices Not Multiplicable...


















0*#   !ã !" ! !"! 6p 7!    
          $
6 7"  "  ã   
6 7"  "  ã    "
6 7"!   "  "! 
ã "ã     !  !  #


  "$

Step 1à Begin
Step 2à input the order of matrix
Read m,n
Step 3à Input the elements of matrix
Repeat step 3 through 4 for i0 to m
Step 4à Repeat step 4 for j 0 to n
Read a[i][j]
Step 5à Read the desired row
read r
Step 6à Find sum of elements of specified row
Print rowsum(r-1)
Function call
Step 7à Read the desired column
read c
Step 8à Find sum of elements of specified column
Print columnsum(c-1)
Function call
Step 9à Initialise sum to zero
Sum<- 0
Step 10àFind the sum of all elements of matrix
Repeat step 8 for I <-0 to m
Sumsum +rowsum(i)
Step 11àoutput the total sum
Print sum
Step 12à end

% "67

Step 1à begin
Step 2à initialize row sum
rs0
Step 3à sum all alements of the row
Repeat step 3 for j 0 to n
rsrs+a[i][j]
Step 4à Return sum
Return rs


%  "67

Step 1àbegin
Step 2àinitialize column sum
cs0
Step 3à sum all alements of the row
Repeat step 3 for i 0 to m
cscs+a[i][j]
Step 4à Return column sum
Return cs

































% !



Start

Read the order of


matrix A into m and
n

Read elements into


matrix aij

i=0

i<m
i+1

j=0 
j<n 

j+1

Read matij 

Read the desired


row number into r


elements to n


print ROWS"M (r-1)

c


c


Read the desired


column number into c


elements to n


Print COL"MNS"M (c-1)

sum B S"MALL (mat, m, n)

write sum

Stop

Int ROWS"M (int row)

sr B 0

j=0
Return sr 
j<n
j+1


sr B sr + matrow,j
Int COL"MNS"M (int col)

sc B 0

i=0
Return sc 
i<m
i+1


sc B sc + mati,col

Int S"MALL (int mat[][], int


m, int n)

sum B 0

i=0
Return sum i<m
i+1

j=0 
j<n 

j+1


sum B sum + matij








 !"$

/* Read a matrix and find the following using functionsà i) Sum of all the elements of
each row ii) Sum of the elements of each column iii) Sum of all the elements of the
matrix */

#include <stdio.h>
#include <math.h>
#include<conio.h>
int m,n,i,j,rsum,r,c;
int a[10][10];
int rowsum(int row);
int colsum(int col);
int sumall( );

void main( )
{
clrscr( );
printf("Enter the order of matrix A à ");
scanf("%d%d",&m,&n);
printf("Enter the elements ( %d ) for matrix A",m*n);
for (i=0; i<m;i++)
for(j=0;j<n;j++)
scanf ("%d",&a[i][j]);

printf("The elements of matrix A are\n");


for (i=0; i<m;i++)
{
for(j=0;j<n;j++)
printf("\t%d",a[i][j]);
printf("\n");
}

printf("Enter the row number \n");


scanf("%d",&r);
printf("\nSum of the specified row is as followsà\n");
printf("\t%d\t",rowsum(r-1));

printf("\nEnter the column number \n");


scanf("%d",&c);
printf("\nSum of the specified column is as followsà\n");
printf("\t%d\t",colsum(c-1));
printf("\nSum of all element is %d",sumall( ));
getch( );
}

int rowsum(int row)


{
int j,sum=0;
for(j=0;j<n;j++)
sum+=a[row][j];
return(sum);
}

int colsum(int col)


{
int i,csum=0;
for(i=0;i<m;i++)
csum+=a[i][col];
return(csum);
}

int sumall( )
{
int i,j,asum=0;
for(i=0;i<m;i++)
for(j=0;j<n;j++)
asum+=a[i][j];
return(asum);
}

#include <stdio.h>
#include <math.h>
int m,n,i,j,rsum,r,c;
int a[10][10];


ã$

Enter the order of matrix A à 3 2

Enter the elements ( 6 ) for matrix A 1 2 3 2 1 2 3 4 1

The elements of matrix A are


1 2 3
2 1 2
3 4 1
Enter the row number 3
Sum of the specified row is as follows 8

Enter the column number 2


Sum of the specified column is as follows 7
Sum of all elements is 19

You might also like