answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Why member function of a class are generally declared as public and data members as private?

Declaring member variables (data) private ensure only the class and friends of the class have access to an object's data.

Declaring member methods (functions) public is required to provide an interface to the private data.

Usually accessor and mutator methods (get/set methods) are declared public to allow user-interaction with the data. However the data itself must remain hidden by the accessors (returned by value) otherwise there's no point in hiding the data -- there is no control. Similarly, the mutators should allow the data to be modified through a controlled interface, thus ensuring the data remains in a valid state at all times. Again, allowing a public mutator to modify the data without validation defeats the purpose of hiding the data in the first place.

Protected access is another option. This is similar to private access, but also permits access to derived classes.

A well-designed class interface should only expose as much as it needs to, and no more. If an object cannot assure its own data integrity at all times, then it is no better than a structure, which is always public by default.

Note that the general rules on class interface design are intended to help not hinder you. Many new programmers find them too restrictive, often making members public when they should really be private. They have entirely missed the point of using a class rather than a structure. That is, a well-designed interface that fully encapsulates an object automatically enlists the help of the compiler to reduce the chances of you or a third party coder from attempting an illegal operation upon the data within the object. If the data integrity can be assured at all times, then the chance of error is greatly reduced. The more complex the data, the more important this becomes.

Will windows automatically select the best allocation unit size when formatting a floppy disk?

Yes. Windows will select the correct allocation unit size according to the disk's capacity. A 1.44 MB disk will use one sector per cluster while a 2.88 MB disk will use 2 sectors per cluster. Short of using a disk sector editor there's no way to change this, but even if you did you'd render the disk unreadable.

Under Windows, all floppy disks are formatted according to the FAT12 specification. Hard disks and flash drives are typically formatted to the FAT32 or NTFS specifications. To support any other specifications besides FAT or NTFS you will need a suitable driver installed, however it's not recommended for normal use since non-standard formats are unreadable on other systems unless the appropriate driver is present on those systems.

FAT is an abbreviation of File allocation Table. The number (12, 16 or 32) simly determines how many bits are used to address clusters. FAT12 is therefore a 12-bit file allocation system, and is used by Windows to format floppy disks. The sectors on a floppy disk are fixed at 512 bytes and the allocation unit size simply determines how many sectors there are per cluster. A cluster is the minimum unit of storage. As such there can only be one file per cluster but a file may occupy one or more clusters. Any unused bytes in the final cluster of a file are wasted bytes, so the smaller the cluster size the better.

A 1.44 MB disk uses an allocation unit size of 1 sector per cluster which is the minimum possible. Any file that is not an exact multiple of 512 bytes will therefore waste anything from 1 to 511 bytes (inclusive) in the final cluster. A 2.88 MB disk uses 2 sectors per cluster, so files must be an exact multiple of 1024 bytes to minimise wastage. Hard disks are typically much larger than floppy disks so they not only use much larger clusters they require more bits to address them.

A 12-bit addressing system can address 4096 clusters in total. However, 33 sectors are reserved so the actual number of sectors for storage can be no more than 4063. This means that you can have no more than 4063 individual files or folders on a floppy disk. However, the more sectors per cluster, the fewer files you can physically store. In reality, the limit is much lower than this. A 1.44 MB disk has an overall capacity of 1,457,664 bytes so at 512 bytes per sector, that equates to just 2847 sectors in total, 33 of which are reserved, leaving 2814 sectors for actual storage.

The boot sector (sector 0) stores the basic disk geometry:

  • Bytes 0 to 10 are ignored.
  • Bytes 11 and 12 store the bytes per sector (512)
  • Byte 13 stores the number of sectors per cluster (1 for 1.44 MB floppy, 2 for 2.88 MB floppy)
  • Byte 14 and 15 store the number of reserved sectors (32)
  • Byte 16 stores the number of FATs (2)
  • Bytes 17 and 18 store the maximum number of root directory entries
  • Bytes 19 and 20 store the total sector count
  • Byte 21 is ignored
  • Bytes 22 and 23 store the number of sectors per FAT
  • Bytes 24 and 25 store the sectors per track
  • Bytes 26 and 27 store the number of heads
  • Bytes 28 to 31 are ignored
  • Bytes 32 to 35 store the total sector count for FAT32 (0 for FAT12)
  • Bytes 36 and 37 are ignored.
  • Byte 38 stores the boot signature
  • Byte 39 to 42 store volume identifier
  • Byte 43 to 53 store the volume label
  • Byte 54 to 61 store the file system type as a character array (e.g., "FAT12", information use only)
  • Bytes 62 and beyond are ignored

Sectors 1 to 9 hold the primary FAT while 10 to 18 hold the secondary FAT. The secondary FAT provides a backup of the FAT.

Sectors 19 to 32 store the root directory. Each sector can hold 16 entries of 32 bytes each. The number of entries consumed is determined by bytes 17 and 18 in the boot sector.

Sector 33 marks the start of the actual data. Logically, this is cluster 0.

The FAT is simply a directory of clusters. FAT entries 0 and 1 are reserved so FAT entry 2 represents logical cluster 0 (starting at physical sector 33).

The root directory (which always exists) stores the root file entries, each of which holds a file's name, its timestamps (created, modified and accessed times), file size, file attributes (read-only, system, archive, hidden or directory) and the logical start cluster. Directories always have the directory attribute while files do not. Other than that both files and folders are treated exactly the same.

The logical start cluster determines where the file (or directory) physically starts. However, as files are created, modified and destroyed, the files can become fragmented, so the cluster that immediately follows the start cluster needn't necessarily be the next cluster for that file. To keep track of which files are using which clusters and in which order, the FAT entry for the start cluster will point to the next cluster, and it will point to the next, and so on, thus creating a daisy chain of clusters. By de-fragging drives, you not only ensure files occupy contiguous clusters but also that the chain of FAT entries is also contiguous. This reduces head movement and thus improves performance.

FAT values in the range 0xFF0 to 0xFFF are reserved. In particular, 0xFF7 is used to mark bad clusters. These are detected when the disk is formatted (unless you use quick format) or when you run a disk diagnostic program such as SCANDISK or CHKDISK. You can attempt to recover bad clusters to make them usable again but once a cluster is marked bad it's reliability is questionable at best.

FAT entries in the range 0xFF8 through 0xFFF are used to mark the final cluster of a file. As mentioned previously, if the file doesn't fully occupy the final cluster the unused bytes are wasted since no two files can share the same cluster.

What do the function gcvt do in C?

The gcvt() function converts a floating-point number to a string. It converts given value to a null-terminated string.

example....

#include #include int main(void) { char str[25]; double num; int sig = 5; /* significant digits */ /* a regular number */ num = 9.876; gcvt(num, sig, str); printf("string = %s\n", str); /* a negative number */ num = -123.4567; gcvt(num, sig, str); printf("string = %s\n", str); /* scientific notation */ num = 0.678e5; gcvt(num, sig, str); printf("string = %s\n", str); return(0); }

Output:

string = 9.876

string = -123.46

string = 67800

How do you convert .wpd files to .doc format?

you could try this free converter at http://www.zamzar.com

this link below says it will convert .wpd to doc:

http://blog.zamzar.com/2007/04/19/convert-wpd-wordperfect-files-to-doc-odt-pdf-and-txt/

another option to try:

When you try to open a wpd file in Microsoft office it should ask you if you want to convert it.

try this:

1. Open Microsoft Word

2. Click File

3. Click Open

4. In the Files of Type: dropdown box change to All Files (*.*)

5. Browse to the file

6. Click it and select OK

7. It will perform the conversion

What port number should you use when writing the code of client and server on same system?

The port number which you use is arbitrary as long as you use the same port for the listener (daemon/server) as you use for the client. The IP address which you use is 127.0.0.1.

Why do you need to study file systems?

In computing, a file system (often also written as filesystem) is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. File systems may use a data storage device such as a hard disk or CD-ROM and involve maintaining the physical location of the files, they might provide access to data on a file server by acting as clients for a network protocol (e.g., NFS, SMB, or 9P clients), or they may be virtual and exist only as an access method for virtual data (e.g., procfs). It is distinguished from a directory service and registry.

More formally, a file system is a special-purpose database for the storage, organization, manipulation, and retrieval of data

Filesystems need to be investigated for security and stability if you want your data Tobe safe.

Why an odd-degree function must always have at least one real root?

An odd-degree function approaches positive infinity in one direction and negative infinity in the other direction so the graph must cross the x-axis at least once, giving it at least one real root.

How do you write a program that outputs a given characters in reverse?

write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)

What is the range of 64 76 46 88 88 43 99 50 55?

that's simple...

the highest number: 99

minus the lowest number: 43

99-43=56

What is the difference between a process and thread?

The same metaphor: the difference of a person (thread) and a family (process)

A process has at least 1 thread and may have many threads, while 1 thread must live within a process

Is wanting to become a computer hacker bad?

It depends on what you mean by hacker.

Being a true hacker is someone who knows lots about a particular technology and is good at modifying it to make it better. Whether hacking is a good or bad thing depend on what you hack. If you hack some thing with a copyright or cause destruction then yes it is bad. If you use those skills to improve open source software, do legal penetration testing, digitalize a toaster, build your own chat program, ect. then hacking is a good, legal, and fun hobby or possibly even a profession.

What is definition of terms?

1. A term is a word or expression used for some particular thing.

Insect is the correct term for a bug.

2. It is also a limited period of time.

I hereby sentence you to a prison term of two years behind bars.

3. In price the terms are amount of money needed to purchase something.

The terms of your lease is $400 per month.

4. Terms can also mean an agreement or conditions for something.

The terms of your release from jail are that you stay away from the victim and do not harass them, contact them, nor threaten them.

What is a VPE file viewer?

It is a program that is used to view .vpe files, which are virtual print engine files. They are rare but are used by some, for me I received a receipt from a courthouse in .vpe format and had to download a VPE file viewer to open it, see it, and print it.

Como puedo ganar dinero?

Te puedo recomendar lo que hasta ahora me ha dado mejor resultado

pagan por Click y por registro, cuando acumules 40 dolares

te envian una tarjeta de debito a tu casa para retirar las ganancias en cajeros ATM

llevo mas de un año ganado con ellos, hasta hora cero problema

http://u.bb/29276/tcredito

Suerte. !

How do you program with .dlls?

Introduction to DLLs......

DLLS as the name suggests are the Dynamic Linked Libraries, majorly comprises of the Classes (inclusive of Constructors, Procudures and Function) in case of Object Oriented Paradigm, and / or procedures / functions in case of Procedural Language, are basically used to provide a Service / serve the Application in question!!!

Towards the Question ......

DLLs cannot be executed directly rather its been made call by any of the Application running. So while Designing an Application, the Dlls are either imported or rather is refered to/by the application program.

For Example :-

In VB.NET the syntax for importing a DLL to an application is as below

imports somedll.

In C#.NET the sysntax is

using somedll;

where "somedll" is a dll file name (somedll.dll)that has been imported from the Computer's HDD mem0ry.

Based on this import of dlls we create either an object or directly make a function call located in that DLL file, like here it is somedll.dll...........

Value of automatic variable that is declared but not intialized?

The value of an automatic variable that is declared but not initialized is indeterminate.

Some debug implementations will preset uninitialized variables to a known state, such as 0xcccccccc, or my favorite, 0xcacacaca, but that is just a hint that you are doing something very, very wrong if you ever encounter such a value.

What tasks can be accomplished using Task Manager?

When using task manager, it can turn off programs that locked up.

like enternet explorer, or windows media player.

What is the purpose of a system call?


System calls are used whenever a program needs to access a restricted resource, eg a file on the hard disk, any hardware device, or when it needs to print or draw to the screen



Advantage and distadvantage in hash table?

ANSWER A hash table is a way to find data in an array, when you have a known key and an unknown value that corresponds to the key. You use a hashing function on the key to create an index into the hash table containing the value. In the ideal case, this directly returns the corresponding value. In the usual case, a collision can occur. This means that the hashed key points to multiple possible values. A hash table is usually used on large arrays that would take a long time to search using other methods. A hash table can be very fast and use very little memory, and does not require the array to be sorted. The source code is slightly more complicated than some search methods. With a poorly designed hashing function when the hashed keys do not correspond one-to-one with the values, the secondary search after a hash collision can take a large amount of time.

Difference between in-system programming and in-application programming?

simple , In system/circuit Programming [ISP/ICP] is process with which entire on chip controller flash is programmed, where as In application Programming [IAP] is scheme in which a running program - re-programs controller flash by receiving new .hex file from any of the serial interface.

Compare multi-core and dual core?

"Dual core" implies that there are two separate instruction execution units placed on a single "die." Some use shared components, such as cache, while others have two full processors, including all sub-components. All dual core processors could be considered multi-core (which simply means multiple "cores" or "processors"). However, a tri-core or quad-core is also a multi-core. Therefore, all dual cores are multi-cores, but not all multi-cores are dual cores.