Login(Email) Password Forget Password? Account Settings
Home ASP.net System Info C# Books Java Script Visual C++(MFC) C/C++ Win API Java Contact Us
Vehicle Parking Program[source code] in C++
You are required to model a vehicle parking lot system. The parking lot has a facility to park cars and scooters. The parking lot contains four parking lanes-two for cars and two for scooters. Each lane can hold ten vehicles. There is an operator with a console at the East end of the parking lot. The system should be able to handle following scenarios. Arrival of a vehicle: 1. Type of vehicle (car or scooter) and Registration No. of vehicle should be entered 2. Program should display suitable parking slot 3. Vehicles arrive at East end, leave from West end

 Departure of Car: 1. If not western most, all cars should be moved to the west
2. When the car is driven out, rest of the cars should be moved to the left

3. Vehicle data should be updated Departure of Scooter: <1. Scooters should be able to drive out at random 2. Vehicle data should be updated Note that when desired the operator must be able to obtain information like number of vehicles, number of scooters or number of cars currently parked in the parking lot. Also, the system should be able to display all the parking lots (currently occupied) if desired.download
A program in c++ (source code) that demonstrates how an array can be used to show working of lifts in a multi-storeyed building.

A program that demonstrates how an array can be used to show working of lifts in a multi-storeyed building. A 30- storeyed building has got about 5 wings where there would be a lift in each of the wing. You have to make available a lift to the person who presses a button to get a lift. Follow the steps given below for designing the program.

1. The floors of the building should be numbered as 0 - 29.

2. The lifts should be numbered as 0 - 4.

3. Display a menu that would have following options

a. Do you wish to use a lift?

 b. Show lift status

 c. Exit

 If user selects, option 1 then get following information from the user.

-Get the floor number where the person is standing

-Whether user wishes to go up/down.

-Get the floor number where the user wishes to go.

The validation checks should be there for the data that user enters. The validation checks are as given below.

1. The floor number where the user is standing and the floor number where user wishes to go should be in a range of 0 to 29.

2. If the user is standing on ground floor, i.e. 0th floor, then selecting the direction for the lift to go down would be invalid.

3. If the user is standing on topmost floor, i.e. 29th floor, then selecting the direction for the lift to go up would be invalid.

4. The direction for the lift whether up or down should be entered as 'u' or 'd' only.

 Check for the lift that can be made available to the person. Before making a lift available to the user consider the following.

1. The lift, which is nearer to the user, i.e., the floor where he is standing should be made available.

2. If the user is standing on a floor, say 8th floor for example. And there are two lifts one on the 7th floor and the other on the 9th floor. Both the lifts are nearer to the user. In such a situation, first check where the user wishes to go, up/down? If up then the lift on the 7th floor should be made available. And if down then the lift on 9th floor should be made available.

3. If the user is standing on say 4th floor for example. And there are 3 lifts, lift number 0, 2, and 4, standing on the 0th floor. All the three are nearer to the user. In such a situation lift that comes first in the order should be made available. download

strings form an acrostic

Write a program that checks if given set of strings form an acrostic. The set of strings is said to form an acrostic when the strings read in any direction come in same order. For example,

ROTAS
OPERA
TENET
AREPO
SATOR

the above strings if read horizonatally from left to right and right to left, or vertically from top to bottom and from bottom to top come in same order. download

Dictionary  Programs[Source code]

Write a program to simulate a dictionary using linked list. It should be a menu driven program with the options for adding a word and its meanings, searching a word and displaying the dictionary. Steps to develop the program are as given below:

1. Declare a structure with the fields as

- a word, - meaning of a word
- counter that holds the number of meanings
- link to the next node.

Each word added to the list can have maximum 5 meaning(s). Hence, variable used to store meaning(s) of a word would be a two dimensional character array.

2. The program should have following menu.
- Add a word
- Search for a word
- Show dictionary - Exit

download
Program in C++ to read the FAT of Floppy disk and Hard Disk
Exploring The Disk

By far the most widely used storage mediums are the floppy disks and the fixed disks (hard disks). Floppy disks and hard disks come in various sizes and capacities but they all work basically in the same way - information is magnetically encoded on their surface in patterns. These patterns are determined by the disk drive and the software that controls the drive. Although the type of storage device is important, it is the way the stored information is laid out and managed that concerns programmers most. Therefore we would focus our attention on how information is organized and stored on the disk.

The Disk Structure

As most of us know, the disk drives in DOS and Windows are organized as zero-based drives. That is, drive A is drive number 0, drive B is drive number 1, drive C is drive number 2, etc. The hard disk drive can be further partitioned into logical partitions. Each drive consists of four logical parts-Boot Sector, File Allocation Table (FAT), Directory and Data space. Of these, the Boot Sector contains information about how the disk is organized. That is, how many sides does it contain, how many tracks are there on each side, how many sectors are there per track, how many bytes are there per sector, etc. The files and the directories are stored in the Data Space. The Directory contains information about the files like its attributes, name, size, etc. The FAT contains information about where the files and directories are stored in the data space.

When a file/directory is created on the disk, instead of allocating a sector for it, a group of sectors is allocated. This group of sectors is often known as a cluster. How many sectors together form one cluster depends upon the capacity of the disk. As the capacity goes on increasing, so also does the maximum cluster number. Accordingly, we have 12-bit, 16-bit or 32-bit FAT. In a 12-bit FAT each entry is of 12 bits. Since each entry in FAT represents a cluster number, the maximum cluster number possible in a 12-bit FAT is 212 (4096). Similarly, in case of a 16-bit FAT the maximum cluster number is 216 (65536). Also, for a 32-bit FAT the maximum cluster number is 228 (268435456. Only 28 of the 32 bits are used in this FAT). All FAT systems are not supported by all versions of Windows. For example, the 32-bit FAT system is supported only in Win 95 OSR2 version or later. There are differences in the organization of contents of Boot Sector, FAT and Directory in FAT12/ FAT16 system on one hand and FAT32 on the other.

The File Allocation Table

The File Allocation Table (FAT) maps the usage of the data space of the disk. It contains information about the space used by each individual file, the unused disk space and the space that is unusable due to defects in the disk. Since FAT contains vital information, two copies of FAT are usually stored on the disk. In case one gets destroyed, the other can be used. A typical FAT entry can contain any of the following:

- Unused cluster
- Reserved cluster
- Bad cluster
- Last cluster in the file
- Next cluster number in the file

There is one entry in the FAT for each cluster in the file area. If the value in a FAT entry doesn't mark an unused, reserved or defective cluster, then the cluster corresponding to the FAT entry is part of a file, and the value in the FAT entry would indicate the next cluster in the file. This means that the space that belongs to a given file is mapped by a chain of FAT entries. Each FAT entry points to the next entry in the chain. The first cluster number in the chain is the starting cluster number in the file's directory entry. When a file is created or extended, a cluster is allocated to the file by searching the FAT for unused clusters and adding them to the chain. Vice versa, when a file is deleted, the cluster that has been allocated to the file is freed by clearing corresponding FAT entries (by setting them to 0). The FAT chain for a file ends with an entry FFFFh in the FAT. This file occupies cluster number 3, 5, 6 and 8 on the disk. Hence the starting cluster number in the directory entry for the file is 3. Suppose this file is to be loaded into memory then OS would first load starting cluster number-3's contents into memory. To find out the next cluster belonging to this file OS looks at entry number 3 in FAT where it finds a value 5. Therefore, now it loads the contents of cluster number 5 into memory. Once again OS looks at the FAT and finds in entry number 5 a value 6, hence it loads the contents of cluster 6 into memory. This process goes on till the OS finds an entry FFFFh in FAT, which indicates that there are no more clusters belonging to the file. Hence the process stops. Now that we have understood how the FAT chain is traversed, let's dig a little deeper into the FAT. The entries present in FAT are 12, 16 or 32 bits long depending on the storage capacity of the disk. Though a 12-bit FAT can handle 4096 clusters only 4078 clusters are available for use since some values are reserved. Similarly, for a 16-bit FAT out of the possible 65536 clusters that it can handle only 65518 are available for use. In a 12-bit FAT three bytes form two entries. The first two entries (0 and 1) in the FAT are reserved for use by the OS. This means that first 3 bytes in a 12-bit FAT, first 4 bytes in 16-bit FAT and first 8 bytes in a 32-bit FAT are not used for storing cluster numbers. Out of these 3 (or 4, or 8) bytes, the first byte is the media descriptor byte and the balance contains the value FFh. These balance bytes remain unused. The media descriptor byte specifies the type of the disk. It typically has a value FDh, F9h, F0h, F8h for a 360 KB, 1.2 MB, 1.44 MB and a hard disk respectively. The contents of a FAT entry are interpreted as shown below.

Value Meaning
12 bit                          16 bit                                  32 bit
000h                          0000h                                  0000000h                                  Cluster available
FF0h-F6h                   FFFFh-FFFF6h                       FFFFFFFh-FFFFFF6h Reserved cluster
FF7h                          FFF7h                                   FFFFFF7h                                  Bad cluster if not part of chain
FF8h-FF                     FFF8h-FFFFh                         FFFFFF8h-FFFFFFh Last cluster of file
xxx                            xxxx                                      xxxxxxx           Next cluster in file

Meaning of FAT entries.

As we saw earlier, two identical copies of FAT are maintained on the disk. All copies are updated simultaneously whenever files are modified. If access to a FAT fails due to a read error, the OS tries the other copy. Thus, if one copy of the FAT becomes unreadable due to wear or a software accident, the other copy may still make it possible to salvage the files/directories on the disk. Here is a program that prints the contents of the first sector of two copies of FAT for a 12-bit or a 16-bit FAT. On similar lines it can be extended to work for a 32-bit FAT. Each disk contains two copies of FAT. In the function fat_info( ) the starting sector of each copy of FAT is determined. Next, the function read_fat_info( ) is called for reading and displaying contents of each FAT copy. Since each copy contains several entries, we have displayed only the first 16 entries for a 12-bit & 16-bit FAT. The organization of the FAT types is shown in above table

12-bit FAT
8 bits 8 bits 8 bits

E2 E3 O3 E1 O1 O2
16-bit FAT

8 bits 8 bits 8 bits 8 bits
E3 E4 E1 E2 O3 O4 O1 O2
32-bit FAT 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits 8 bits
E7 E8 E5 E6 E3 E4 E1 E2 O7 O8 O5 O6 O3 O4 O1 O2

For a 32-bit FAT the seven nibbles (a nibble is a group of 4 bits) E1-E2-E3-E4-E5-E6-E7-E8 form the even entry. Note that the arrangement of these nibbles is E7-E8-E5-E6-E3-E4-E1-E2 because the lower byte is always stored in memory earlier than the higher byte. This means if the value of the 4-byte FAT entry is ABCD, it would be stored as DCBA. The odd entry is represented using the set of nibbles O1-O2-O3-O4-O5-O6-O7-O8. In reality the nibble E8 and O8 don't contribute to the cluster number since each entry in the 32-bit FAT is only 28 bits long. On similar lines in a 16-bit FAT the four nibbles E1-E2-E3-E4 form the even entry whereas the set O1-O2-O3-O4 form the odd entry. Similarly, the even and odd entries in a 12-bit FAT are formed by E1-E2-E3 and O1-O2-O3 respectively. Picking up the values present in odd or even entries from a 32-bit FAT or a 16-bit FAT a relatively simple job. However, to pick up the values from a 12-bit FAT we have to use bitwise operators to discard one nibble out of a group of 4 nibbles. This is done in our program through the functions getfat_12( ).  download

Function Calls and Stack
A stack is used by programming languages for implementing function calls. write a program to check how function calls are made using stack. download
Tower Of Hanoi
Tower of hanoi is a historical problem, which can be easily expressed using recursion. There are N disks of decreasing size stacked on one needle, and two other empty needles. It is required to stack all the disks onto a second needle in the decreasing order of size. The third needle can be used as a temporary storage. The movement of the disks must confirm to the following rules,
1. Only one disk may be moved at a time
2. A disk can be moved from any needle to any other.
3. The larger disk should not rest upon a smaller one.  download
A Program[Source Code] in C++ for the Simulation of an Airport

There is a small busy airport with only one runway. In each unit of time one plane can land or one plane can take off, but not both. Planes arrive ready to land or to take off at random times, so at any given unit of time, the runway may be idle or a plane may be landing or taking off. There may be several planes waiting either to land or to take off.  download

Car Parking Program in C++ source code
Parking Garage contains 10 parking lanes, each with a capacity to hold 10 cars at a time. As each car arrives/departs, the values A/D (representing arrival /departure) is entered along with the car registration number. If a car is departing the data should get updated. If a new car is arriving then on the screen a message should be displayed indicating suitable parking slot for the car. Cars arrive at the south end of the garage and leave from the north end. If a customer arrives to pick up a car that is not the nothernmost, all cars to the north of the car are moved out, the car is driven out, and the other cars are restored in the same order that they were in originally. Whenever a car leaves, all cars to the south are moved forward so that at all times all the empty spaces are in the south part of the garage. Write a program that implements this parking system. download
A deque is a data structure that allows both deletion as well as insertion of elements to be done at both ends. Write a program to demonstrate working of a deque using a linked list.  download
In an input restricted deque the insertion of elements is at one end only, but the deletion of elements can be done at both the ends of a queue. Write a program that demonstrates an input-restricted dque.  download
In an output restricted deque, the deletion of elements is done at one end only, and allows insertion to be done at both the ends of a deque. Write a program to demonstrate output-restricted deque. download
When the hard disk is new the files and directories are properly organized. As the hard disk grows old, some laxity sets in and one tends to create files with duplicate names in different directories. Write a program to locate these duplicate filenames. download
Write a program that asks user an ID, name, age and salary of 5 employees. Store all the ID's into one array and sort the array in asscending order. Now to display the records in asscending order search for each elements from the array into records and display the corresponding records. download
Write a program that accepts a set of 5 records for students. Ask user to enter name, age and height of a student. Sort these records in ascending order of their names. If the names are alike then sort according to their age. download
Take any five dates in dd\mm\yyyy format, and arrange them in asscending order. Steps to develop the program:
1. Dates are entered as strings.
2. Convert the dates into integer values.
3. Check for validation of dates.
4. Sort the dates with respect to their integer values.
5. Display the sorted dates.
To increase the range of dates, we have stored it in 4 bytes using a long intger variable (Under DOS dates are stored in 2 bytes). So to store the day the lower 5 bytes are used. Now to store a month in next 4 bytes we need to multiply the month by 32. Similarly, to store the year it is multiplied by 512. This is done because we are required to store the entire date in one single entity, which is later used to sort the dates.  download