CS609 Assignment No 03 Fall 2020 Solution & Discussion Due Date: 28-01-2021
Problem Statement:
Write a complete C program that will read the physical block of the Hard Drive / Removable Drive
based on last two digits of your student ID using biosdisk() function and write the data in a file
using fwrite() function. (See detailed instructions)
Detailed Instructions:
1) If last two digits of your Student ID is even (for example in BC123456788, last two digits are 88
and 88 is even) then your program will read the block from first fixed drive of your system
2) If last two digits of your Student ID is odd (for example in BC123456783, last two digits are 83
and 83 is odd) then your program will read the block from first removable drive of your system
3) To read a physical block of the hard disk, we will use biosdisk() function. This function
requires several parameters which are given below:
Parameters Parameter values
Command operation 2 (read the disk)
Head number Get from the user at run time
Track number Get from the user at run time
Sector number Get from the user at run time
Next sectors to read 1 (current only)
Buffer to read Fixed size of 512 bytes
(initialize it with zeros)
4) Values inputted by the user (Head, Track, and Sector numbers) must be converted to integer
values
5) After successfully reading into the buffer, write the data in a file using fwrite() function. Take
name of the file from user at runtime. Open the file in Write/Binary format
6) Also perform error checking during disk read operation. If, for some reason, disk is not read,
the relevant error message should be displayed instead of abnormal termination of the
program
Sample Output:
Case 1: If last two digits of Student ID is EVEN:
Suppose the last 2 digits of your Student ID is 88 and 88 is even. Student will read data from first
fixed drive of his/her system. Following is the sample screenshot of desired final output. The values
entered by the user is for example only:
Case 2: If last two digits of Student ID is ODD:
Output will be exactly the same as in above screenshot. The only difference is that Student will read
from first removable disk.
Creation of File after running the program:
In either case (even or odd), when you successfully run the program, a file will be created in C: >
TURBOC3 > BIN folder as in the following screenshot:
Tags:
Share the Assignment Questions & Discuss Here....
Stay touched with this discussion, Solution idea will be uploaded as soon as possible in replies here before the due date.
CS609_Assignment_No_03_Solution_Fall_2020
Click on the below link to download the file
cs609 assignment 3 fall 2020 cs609 assignment no3 fall 2020 cs609 assignment solution cs609 assignment no 3 solution 2020 cs609 solved assignment 2020 cs609 assignment solution last date 28 jan 2021
CS609 Assignment 3 Fall 2020 Solution idea:
Code:
#include <bios.h>
#include <dos.h>
#include <stdio.h>
FILE *fp;
unsigned char buf[512];
unsigned char st[60];
unsigned char headno[10 ];
unsigned char secno[10 ];
unsigned char unsigned char trackno[10 ] ;
void main (void)
{
int i;
for (i = 0; i < 512; i++)
buf[i] = 0;
printf("Please Enter Name ot the file);
gets(st);
fp=fopen(st,"wb");
printf("Please Enter Head Number:");
gets(headno);
printf("Please Enter Sector Number:");
gets(secno);
printf("Please Enter Track Number");
gets(trackno);
i = biosdisk(2,0x00,atoi(headno), atoi(trackno),atoi(secno),1, buf) ;
if (*(((char *)(&i))+1)== )
{
fwrite(buf,1,512,fp);
fclose(fp);
printf("Data is Written Successfully on the file");
}
else
{
printf("Cannot Read Error",i);
}
getch();
}
If you find any mistake please correct it by yourself.
Regards.
Solution :-
#include <bios.h>
#include <dos.h>
#include <stdio.h>
FILE *fp;
unsigned char buf[512];
unsigned char st[60];
unsigned char headno[10 ];
unsigned char secno[10 ];
unsigned char unsigned char trackno[10 ] ;
void main (void)
{
int i;
for (i = 0; i < 512; i++)
buf[i] = 0;
printf("Please Enter Name ot the file);
gets(st);
fp=fopen(st,"wb");
printf("Please Enter Head Number:");
gets(headno);
printf("Please Enter Sector Number:");
gets(secno);
printf("Please Enter Track Number");
gets(trackno);
i = biosdisk(2,0x00,atoi(headno), atoi(trackno),atoi(secno),1, buf) ;
if (*(((char *)(&i))+1)== )
{
fwrite(buf,1,512,fp);
fclose(fp);
printf("Data is Written Successfully on the file");
}
else
{
printf("Cannot Read Error",i);
}
getch();
}
CS609 Assignment 3 Solution-converted
Click on the below link to download the file
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post