answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

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

Algorithm for calculating the average of 3 numbers?

Algorithm
Step1: Read A, B, C
Step2: If A > B is True, then check whether A > C, if yes then A is greatest otherwise C is greatest
Step3: If A > B is False, then check whether B > C, if yes then B is greatest otherwise C is greatest

Following these steps flowchart can be made.

Explain why programs that are developed using evolutionary development are likely to be difficult to maintain?

When a system is produced using the evolutionary development model, features tend to be added without regard to an overriding design. With each modification, the software becomes increasingly disorganized. System maintenance hampered by these problems, as it is harder identify the source of bugs in poorly designed systems. Also, keeping the documentation up to date over successive "evolution" is uncommon. Poor documentation also makes maintenance more difficult.

  • It leads to implementing and then repairing way of building systems.
  • Practically, this methodology may increase the complexity of the system as scope of the system may expand beyond original plans.
  • Incomplete application may cause application not to be used as the full system was designed.
  • there results incomplete or inadequate problem analysis.

What is global?

Canada is a major world source of minerals, metals, grains, timber and until recently, fish. There is more oil in the Alberta Tar sands than in Saudi Arabia.

Canada has also contributed to what Canadians have regarded as just causes; the two world wars are the best examples. More recently Canada has acted as an international peacekeeping force. Canada has welcomed refugees from all over the world, so much so that some have taken advantage of this.

Canada has sometimes acted as a bridge between our sometimes pugilistic friends to our south and other nations.

Canada contributed to the space program and is active in providing medical care to countries whose people cannot provide it for themselves. Canada is a generator of medical and scientific research.

Canadian schools and universities are world class as are our hospitals.

Not bad for a little guy!

What is the difference between ANSI C and C plus plus?

C is a programming language and ANSI is the standardization committee. The C language is under the auspices of the ANSI committee, which monitors the grammar and structure of the language in a standard way that compiler writers must adhere to.

ANSI C means that it is a standardized version of the C language according to the rules of the committee and should work/compile the same way on any system that uses an ANSI C compliant compiler.

What are the advantage of header linked list?

Header linked list contains a special node at the top,this header node need not represent the same type of data that succeding nodes do,it can have data like,no. of nodes,any data...

header node can access the data of all your nodes

What is insertion sort?

The function on insertion sort is to insert a value into its proper place using an algorithm automatically. It sorts through an array and puts it in the appropriate order according to absolute smallest element.

What is the maximum integer allowed in an integer-type variable?

That varies from each programming language. As a matter of fact, many languages do not put a limit on the maximum size of a variable. It will handle any string, integer, resource, pointer, or other type size, as long as it fits into the memory of the machine running the process.

What is the limitation of DDA line generation algorithm?

1.It drift away from the actual line path because of rounding off float values to integer

2.It causes jaggies or stair-step effect

----------------------------------------------------------------------------------------------------------------

Disadvantage:The accumulation of round of error is successive addition of the floating point increments is used to find the pixel position but it take lot of time to compute the pixel position.

----------------------------------------------------------------------------------------------------------------

More Informationhttp://knol.google.com/k/thiyagaraaj-m/dda-line-algorithm/1lfp8o9xxpx13/78#

http://i.thiyagaraaj.com/articles/articles/dda-line-algorithm

----------------------------------------------------------------------------------------------------------------

the standard version of dda given as in one of its steps as

if(abs(dx)>abs(dy)) steps=abs(dx);

else steps=abs(dy);

this part just supports the positive slop with starting point on left side. Take an example of any other end points as {(8,3) to (2,2) or (4,5) to ( 8,2) or (8,3) to (5,5) } where the slop needs to be negative( for the last two cases) only.

can anyone correct me by suggesting the accurate version of DDA? Or is this the actual DDA??.

What is two types of programming approaches?

Procedural programming, one that is made of one or more procedures and Object-oriented programming (O.O.P.) where a standard model is used for designing using real-world objects to express patterns, called classes in software.

What object-oriented programming language was developed by Sun Microsystems?

Sun Microsystems (now owned by Oracle) did not develop any language in 1990. The development of Java began in June 1991, with the first release appearing in 1995.

What does while mean in computer programming?

The while() statement is used in iterative structures (loops), such that a statement block will iterate so long as a conditional expression evaluates true. The conditional expression can be evaluated at the start or at the end of a loop, thus making it more flexible than the standard for() statement which always evaluates the conditional expression at the start of a loop.

In C++, the while() statement has the following forms:

while( condition ) {

statement;

}

do {

statement;

} while( condition );

In the first form, the statement block only iterates if the condition evaluates true. In the second form, the statement block is executed at least once, and only iterates if the condition evaluates true.

Infinite loops have the following forms:

while( 1 ) {

statement;

}

do { statement;

} while( 1 );

The latter form is redundant since both loops will iterate at least once, however the former is deemed more acceptable in terms of readability than the infinite for() statement:

for(;;) {

statement;

}

As with for() statements, while() loops can use break, return or goto to conditionally exit the loop at any point, or use continue to prematurely begin a new iteration.

Although for() and while() are interchangeable to an extent, the form you use is largely dependant upon which is more readable or makes the most sense in your code. If the condition must be evaluated at the end of the loop then you must use do..while(), but for all other loops you often have a choice of using for() or while(). However, there are differences. Generally speaking, for() statements are used whenever you need to operate upon a control variable in a consistent manner (such as incrementing an index value at each iteration) whereas while() statements are used when changes to the control variable are dependant upon other conditions which are determined within each iteration of the loop itself. Moreover, control variables in while() loops must be in scope prior to entering the loop and will remain in scope when the loop terminates, whereas for() loops can both declare and initialise control variables, rendering them local to the loop. Depending on the type of loop, these facts can help determine which is the better form to use, but in terms of performance there is no real difference. It's all a question of which form makes the most sense for the type of loop you are trying to control.

What the meaning of cell pointers in Microsoft Excel?

A cell pointer in excel is just the cell where you point the cursor in which its row and column can be seen is called a cell pointer.

Describe why it is a bad idea to implement a link list version a queue which used the head of the list as the rear of the queue?

It isn't. In fact it is a very good idea. Since the list is circular, you need only maintain a reference to the tail (rather than the head), because the tail provides constant time access to both the head and the tail. In this way you get constant time insertions at the tail and constant time extractions at the head via a single reference -- exactly what you want from a queue. If the list were not circular, you would need two references, one to the head and one to the tail. That's a waste of memory when the tail has an otherwise redundant link that's always null. Point it at the head and refer to the tail instead of the head and you save memory.

How do you write a program in Basic to display all the even numbers up to 100?

In visual basic:

Module Module1

Sub Main()

Dim Inst As Integer

For Inst = 0 To 100 Step 2

Console.WriteLine(Inst)

Next

End Sub

End Module

How does the for loop work in c?

  • For loop is "Counter controlled loop" i.e. a counter or control variable is used to process the for loop , as discussed in earlier chapters.
  • For loop is an "Entry controlled loop" i.e. the condition to iterate the loop must be check at the starting of the loop and loop body will not execute if the condition is False. Source website:

http://codedunia.in/c-language/for-loop-in-c-programming.php

Write the program in c language for the addition of two matrices using pointer?

#include<stdio.h> #include<conio.h> int main() { int n,m,i,j,k; int a[38][38],b[38][38],p[38][38]; printf("\nEnter the number of rows and coloumns "); scanf("%d %d",&n,&m); printf("\nEnter the elements of first matrix "); for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",(*(a+i)+j)); } } printf("\nMatrix is "); for(i=0;i<n;i++) { printf("\n"); for(j=0;j<m;j++) { printf("%d",*(*(a+i)+j)); printf("\t"); } } printf("\nEnter the elements of second matrix "); for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",(*(b+i)+j)); } } printf("\nMatrix is "); for(i=0;i<n;i++) { printf("\n"); for(j=0;j<m;j++) { printf("%d",*(*(b+i)+j)); printf("\t"); } } printf("\nAfter ");

Number 15 in binary form?

Rather than tell you what the answer is, I think it better that you learn how to do this your self. By asking the question you must realize that each binary digit can have a value of one or zero. Just like with decimal numbers, the digit of lest value is on the right and has a decimal value of one. The digit immediately to its left has a value that is twice that of it neighbor to the right and also half the value of its neighbor to the left.

Here is the decimal values of 8 binary digits.

[128][64][32][16][8][4][2][1] decimal value

( 8)( 7)( 6)( 5)(4)(3)(2)(1) digit place

Lets convert 25 decimal into binary.

The largest decimal value that can be subtracted is 16 with 3 digits to the left, write down 3 zeros as place holders for the 3 left digits. Follow by a one.

0001

25 - 16 = 9

The next binary digit to the right has a decimal value of 8 and can be subtracted from 9 so we write down another 1.

00011

9 - 8 = 1

Now for each binary digit that has a decimal value greater than the remainder write a zero.

0001100

Now there is just the 1 left to deal with. Any time there is only 1 left you can just write down a 1.

00011001

So with that short intro to converting decimal into binary you should be dangerous enough to do your own decimal to binary conversions. (If still in doubt try, Google for an explanation that makes more sense to you).