Ex:No:1
STUDY OF OS COMMANDS
Aim: To study MS-DOS commands for performing Character User Interface (CUI) operations in Files
and Directories.
Procedure:
1. Go to START → RUN and type ‘Cmd’ and click ok button. The command prompt window will
open.
2. The default directory location is C:\Documents and Settings\Username> ,now change the
prompt like C:\> D:
3. Type the following commands in the prompt D:\> to see the result
DIRECTORY RELATED COMMANDS:
1. DIR:
This command is used to display the files and directories of the current drive and directory.
Syntax: DIR [drive:][path][filename]
DIR /P: To display files and directories page wise.
DIR /W: To display files and directories width wise ( horizontally ).
DIR /AD: To display directories only.
DIR /AH: To display hidden files only.
DIR /AR: To display read only files.
DIR /ON: To display files in sorted order name wise.
DIR /OS: To display files in sorted order size wise.
Example:
D:\> DIR
D:\> DIR /P
D:\> DIR /W
D:\> DIR /AH
Page | 1
2. MD [MAKE DIRECTORY]:
This command is used to create a new folder or directory.
Syntax: MD [drive:] [path]
Where drive is the floppy \ hard disk drive on which you want to create a new directory.
Example:
D:\> MD Christ
D:\> DIR /P
3. CD [CHANGE DIRECTORY]:
This command is used to change current directory to another directory.
Syntax: CD [drive:][path]
CD.. : This command is used to go to previous directory.
CD\ : This command is used to root directory.
Example:
D:\> CD CCET
D:\CCET>
D:\> CD..
D:\>
4. RD [REMOVE DIRECTORY]:
This command is used to remove the directory.
Syntax: RD [directory]
Where directory is the name of the directory which we want to remove.
Example:
D:\> RD CCET
D:\> DIR /P
Page | 2
FILE RELATED COMMANDS:
1. COPY CON COMMAND :
This command is used to create a new file.
Syntax : COPY CON [File Name]
Example:
D:\> copy con college
Christ College of Engineering and Technology
Ctrl Z or F6 – to save the file.
2. TYPE COMMAND:
This command is used to display the contents of the file.
Syntax: TYPE [File Name]
Example: D:\> Type college
3. COPY COMMAND:
This command is used to copy an existing file to a new file.
Syntax: COPY [Existing Filename] [New Filename]
Example: D:\>Copy college newcol
4. REN COMMAND:
This command is used to change the file name.
Syntax: REN [Old File Name] [New Name]
Example:
D:\>REN newcol newcollege
5. DEL COMMAND:
This command is used to delete the file.
Syntax: DEL [File Name]
Page | 3
Example:
D:\>DEL college
6. CLS COMMAND:
CLS is a command that allows a user to clear the complete contents of the screen and
leave only the prompt.
Syntax: CLS
Example:
D:\> CLS
7. TIME COMMAND:
To display the time and to change the current time
Syntax: TIME [ time ]
Example:
D:\> TIME
8. DATE COMMAND:
To display the date and also to change the Current date.
Syntax: DATE [ date ]
Example:
D:\> DATE
9. EDIT COMMAND:
This command is used to change or edit the content of the given file.
To Save file - Ctrl+F+S
To Exit file - Alt + X
SCREEN SHOT:
Page | 4
RESULT:
Thus the given MS DOS directory related and file related commands have been
studied and executed successfully.
Page | 5
Ex:No:2 : Write a c program to find the area of a triangle
AIM :
To write a C program to find the area of a triangle.
Formula of area of any triangle:
Area = √(s*(s-a)*(s-b)*(s-c))
Where s = (a + b + c)/2
ALGORITHM:
Step 1 : start
Step 2 : Declare the variable a, b, c, s, area
Step 3 : Get the value of a, b, c
Step 4 : Find s value s=(a+b+c)/2
Step 5 : Find area = sqrt(s*(s-a)*(s-b)*(s-c))
Step 6 : Print the value of area
Step 7 : Stop
FLOW CHART :
START
Read a,b,c
s=(a+b+c)/2
area = sqrt(s*(s-a)*(s-b)*(s-c))
PRINT area
STOP
Page | 6
SOURCE CODE :
#include<stdio.h>
#include<math.h>
#include<conio.h>
void main()
{
float a,b,c;
float s,area;
clrscr();
printf("Enter size of each sides of triangle");
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle is: %.3f",area);
getch();
}
Page | 7
SCREEN SHOT:
RESULT:
Thus the given program to calculate area of a triangle has been executed and verified
successfully.
Page | 8