answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

Where are data structures used?

It would probably be easier to ask where they aren't used. Even a one-dimensional array is a data structure, thus all strings are data structures. There are relatively few programs that don't require strings and even fewer that don't require arrays. But even they will use one or more data structures because a program without data of any kind would be completely useless.

What is difference between linked list and singly linked list?

Answer

singly linked list has the node inserted only at one end. and the pointer corresponds to the next pointer.
but in a doubly linked list, the node pointer points to the both previous and the next node.
singly linked list has two nodes
doubly linked list has three nodes

A doubly linked list makes sense when you need to traverse the list in both directions. You aren't able to do that with a singly linked list.

Types of programming language that is machine independent?

FORTRAN (FORmula TRANslator) is the best-known earliest example of machine independent language. This is where the language is not dependent on the characteristics of the computer.

COBAL (COmmon Business-Orientated Language) is the other type of programming language that is machine independent. COBAL was developed by the US Navy for business applications.

Why is object oriented system important?

At "AchieversIT," we emphasize the importance of object-oriented systems (OOS) for modern software development. Here are the key reasons why OOS is essential, especially in the context of our training:

Modularity and Manageability: OOS promotes a modular approach, breaking down complex software into manageable components. This aligns with our focus on building structured and maintainable code, making it easier for our students to understand, modify, and extend their applications.

Reusability: Reusability is a core concept we instill. By teaching the principles of objects and classes, we empower our students to create reusable components, saving development time and fostering best practices.

Encapsulation for Security: Encapsulation is vital for data security and integrity. We stress the importance of encapsulating data and methods within objects, ensuring proper access control and reducing the risk of unintended data manipulation.

Abstraction for Clarity: Our training covers the value of abstraction in simplifying complex systems. Through modeling real-world entities as classes, we help students focus on essential features, leading to cleaner and more maintainable code.

Inheritance and Code Organization: Inheritance facilitates code reuse and organization. By understanding inheritance, our students learn to build well-structured class hierarchies, making their codebase more efficient and extensible.

Polymorphism for Flexibility: Polymorphism, a crucial OOS concept, fosters adaptability in software. Our students grasp the power of polymorphism, enabling them to create flexible systems where objects can respond differently to common method calls.

Collaborative Development: Our training promotes collaboration among developers. We teach students to work cohesively, leveraging the modular nature of OOS for parallel development, enhancing efficiency, and reducing bottlenecks.

Scalability Principles: We highlight the scalability benefits of OOS. Our students learn how to add new functionality without disrupting existing code, a crucial skill for building scalable applications.

Real-world Modeling: OOS aligns with real-world modeling, enhancing communication between developers and stakeholders. Through OOS, our students gain the ability to model complex systems more naturally and effectively.

Maintenance and Evolution Mastery: OOS simplifies maintenance and evolution. Our training equips students with the skills to make changes efficiently, reducing the risk of introducing errors in other parts of the system.

By imparting these OOS principles, "AchieversIT" ensures that our students not only master the technical aspects but also understand the fundamental design principles that underlie modern software engineering. This holistic approach prepares them to excel in the dynamic field of software development.

What is the difference between cut and a copy command?

a copy command would copy the contents of the selection and when you paste it somewhere else, the original contents would still be there. the contents would be available in both the original location and the new location

a cut command would remove the contents of the selection and when you paste it somewhere else, the original contents would be lost. it would be available in the new location only.

Write a program which uses Command Line Arguments?

IN C++

#include <iostream> int main(int argc, char *argv[]) { using namespace std; cout << "There are " << argc << " arguments:" << endl; // Loop through each argument and print its number and value for (int nArg=0; nArg < argc; nArg++) cout << nArg << " " << argv[nArg] << endl; return 0; }

How compile the code compiler and interpriter?

No generic answer for this question, specify your operating system and compiler.

For example in unix: cc -g -o myprog myprog.c

in linux: gcc -g -W -Wall -pedantic -o myprog myprog.c

What is the best method of data processing?

There are different methods of data processing. Some methods are manual data processing, mechanical data processing, online processing, batch processing and electrical data processing.

How do you get backgrounds on your laptop?

You can find free (public domain) backgrounds on: ---- ---- Go on the net, ask for free software, you will get plenty of sites. Choose one, most have background screens to down load, cost you nothing. I have a beautiful aquarium I bought at wall marts for ten bucks.

Why you use array in c language?

The idea of an array is to store data for different related items, using a single variable name. The different items are distinguished by a subscript (a number, which may also be a variable or some other expression)

For example, if you want to track scores for four different players in a computer game, you could create an array for those scores.

The idea of an array is to store data for different related items, using a single variable name. The different items are distinguished by a subscript (a number, which may also be a variable or some other expression)

For example, if you want to track scores for four different players in a computer game, you could create an array for those scores.

The idea of an array is to store data for different related items, using a single variable name. The different items are distinguished by a subscript (a number, which may also be a variable or some other expression)

For example, if you want to track scores for four different players in a computer game, you could create an array for those scores.

The idea of an array is to store data for different related items, using a single variable name. The different items are distinguished by a subscript (a number, which may also be a variable or some other expression)

For example, if you want to track scores for four different players in a computer game, you could create an array for those scores.

What is redundant code in object oriented programming language?

The basic idea is to duplicate as little code as possible. This helps make the program shorter, but especially, it makes it easier to maintain - if there is an error, or you want to add a feature, you do the change in a single place.

How are instructions converted to machine language?

Compilers or interpreters translate high-level code to machine language. Interpreted languages require a runtime to perform the conversion when the high-level code is executed whereas compiled languages are typically compiled to native machine code which requires no further translation. However, some languages compile the high-level code to an intermediate code known as byte code which is then interpreted to produce the machine code. This is typically done to improve performance, because it is quicker to interpret byte code than it is to interpret high level code (primarily because the byte code is more compact). Also, the byte code need only be compiled once but can be execute on any machine with a suitable interpreter. Java is a typical example of this (compiled Java byte code can be interpreted by the Java virtual machine on any physical machine). While this greatly improves performance and portability, the need for a runtime means the language is not suitable for general purpose programming (such as operating system kernels, device drivers, subsystems and so on), it can only be used to develop applications software. Despite the improved performance, compiled native machine code programs will always perform better than interpreted byte code. And although native machine code programs are not portable (they are machine-specific), the high-level source can be portable, it simply needs to be recompiled.

What problem is overcome by using a circular array for a static queue?

//Library File

#include

//Class to hold a person's data

class person

{

public:

int arr_time,trans_time;

};

//Class to implement queue

class Queue

{

private:

person data[5]; // An array object of the person class

int front,back; // 'front' and 'back' variables to point to the front value and back value

int count; //'count' counts the no. of elements present in the queue

public:

Queue() //Constructor

{

front=back=0;

count=0;

}

void inqueue(int a_tym,int t_tym) // Function to add data into the queue

{

if(count>=5)

cout<<"\n The queue is full.";

else

{

data[back].arr_time=a_tym;

data[back].trans_time=t_tym;

if(count<5&&count>0&&back!=4)

back++;

else if(count<5&&count>0&&back==4)

back=0;

count++;

}

}

void dequeue() // Function to remove data from the queue

{

if(count<=0)

cout<<"\n The queue is empty.";

else

{

if(count<5&&count>0&&front==4)

front=0;

else if (count<5&&count>0&&back!=4)

front++;

count--;

}

}

void Front() // Function to show the first element on the queue

{

cout<<"\n The arrival time of the first customer is :"<

cout<<"\n The transaction time is :"<

}

void Empty() // Function to check if the queue is empty or full

{

if(count<=0)

cout<<"\n The queue is empty.";

else if(count>=4)

cout<<"\n The queue is full.";

else

cout<<"\n The queue is not empty.";

}

};

void main()

{

Queue q1;

q1.inqueue(33,4);

q1.Front();

q1.inqueue(34,6);

q1.Front();

q1.dequeue();

q1.Front();

q1.inqueue(34,1);

q1.inqueue(35,3);

q1.inqueue(36,5);

q1.inqueue(39,7);

q1.Empty();

q1.Front();

}

How i can Write the program in fortran using goto statement?

The use of GOTOs in programming is generally considered to be bad form, because it very rapidly leads to "spaghetti code" where it is difficult or impossible to follow the program's logic flow.

However, given Fortran's comparatively weak set of flow controls, there are times when a GOTO is unavoidable or actually clearer than using a more-structured layout. A simple example would be a subroutine that checks its arguments for validity and exits immediately if it finds something incompatible. The alternatives would be

(A) Put a GOTO 99999 after each invalid condition is detected, where 99999 is the program's RETURN statement

(B) Set flags after each condition, falling through and checking more and more flags until you "naturally" reach the module's RETURN.

An example of (A) would be (using slight variations on Fortran 90 syntax)

subroutine foo(x,y)

implicit none

real*4 x, y

! Check for negative arguments

if (x < 0.0) then

print *, 'Argument X is negative'

goto 99999

endif

if (y < 0.0) then

print *, 'Argument Y is negative'

goto 99999

endif

! (Code body goes here ....)

99999 continue

return

end

Inheritence and its types in object oriented programmings?

There are only two types of inheritance in object oriented programming:

Single inheritance: where a class inherits directly from just one base class.

Multiple inheritance: where a class inherits directly from two or more base classes.

Multi-level inheritance is often thought of as being a separate type of inheritance, however inheritance relates to a derived class and those that it directly inherits from. If a base class is itself a derived class (an intermediate class), then its base class or classes are simply indirect base classes of the derivative. But in isolation, the intermediate class either uses single or multiple inheritance, even if its base class or classes are also intermediates.

Virtual inheritance is also thought of as being a separate type, however virtual inheritance doesn't change the relationship between classes within the hierarchy. the only difference virtual inheritance makes is that the virtual base class or classes are constructed by the most-derived class within the current hierarchy, rather than by their most direct descendants. In this way, only one instance of each virtual base exists in the hierarchy, rather than multiple instance as would normally exist. The actual inheritance is still single or multiple, however.

Some programming languages are typeless. What are the obvious advantages and disadvantages of having no types in a language?

The disadvantage is poor reliability due to the ease with which type errors can be made, coupled with the impossibility of type checking detecting them

What are the advantages of bresenhams's line drawing algorithm over the cartesian slope ana ddadigitial defrantial analyser?

DDA uses float numbers and uses operators such as division and multiplication in its calculation. Bresgenham's algorithm uses ints and only uses addition and subtraction. Due to the use of only addition subtraction and bit shifting (multiplication and division use more resources and processor power) bresenhams algorithm is faster than DDA in producing the line. Im not sure, though if i remember right, they still produce the same line in the end.

One note concerning efficiency: Fixed point DDA algorithms are generally superior to Bresenhams algorithm on modern computers. The reason is that Bresenhams algorithm uses a conditional branch in the loop, and this results in frequent branch mispredictions in the CPU. Fixed point DDA also has fewer instructions in the loop body (one bit shift, one increment and one addition to be exact. In addition to the loop instructions and the actual plotting). As CPU pipelines become deeper, mispredictions penalties will become more severe.

Since DDA uses rounding off of the pixel position obtained by multiplication or division, causes an accumulation of error in the proceeding pixels whereas in Bresenhams line algorithm the new pixel is calculated with a small unit change in one direction and checking of nearest pixel with the decision variable satisfying the line equation.

What are preprocessor directive?

Preprocessor directives are used to mark code that is specific to a particular compiler and thus to a specific machine architecture. In this way, programmers can write cross-platform code in the same source and let the compiler decide which parts of the source to compile and which to ignore. In reality, the compiler never actually sees the preprocessor directives since the preprocessor creates new files containing only the code that is to be compiled. Hence the preprocessor is often called the precompiler. Normally, the intermediate source files are deleted as they are compiled, however your development environment should contain an option that allows you to view these files so you can see what the compiler actually works with.

In C and C++, all preprocessor directives have a leading # symbol, such as #include and #define.

#include is by far the most common preprocessor directive. When the precompiler encounters a #include statement, the named header file is essentially copy/pasted in place of the directive. However, all header files should also contain #ifndef header guards to ensure headers are only included once per compilation and these have to be preprocessed as well. Macro definitions are also preprocessed, replacing all instances of the macro symbol with the definition. Macro functions are also inline expanded but since the compiler only sees the expanded code, never the macro itself, the compiler cannot help you debug errant macros. This is why non-trivial macro functions are best avoided.

Short note on motherboard of computer?

motherboard is a most important part of system.Motherboard also now as main board or main CKT board or plaenboard all the component of system intrigrated are attached vaya motherboard.

Is it true or false that A linked list is a collection of nodes?

It is true that a linked list is a collection of nodes.And a node contains data part and a link part which contains address of the next node.

What does binary code 10101010 mean?

  • 170/2 = 85 R 0. Therefore binary number so far is 0.
  • 85/2 = 42 R 1. Therefore binary number so far is 10.
  • 42/2 = 21 R 0. Therefore binary number so far is 010.
  • 21/2 = 10 R 1. Therefore binary number so far is 1010.
  • 10/2 = 5 R 0. Therefore binary number so far is 01010.
  • 5/2 = 2 R 1. Therefore binary number so far is 101010.
  • 2/2 = 1 R 0. Therefore binary number so far is 0101010.
  • 1/2 = 0 R 1. Therefore binary number so far is 10101010.
  • The integer portion of last division was 0 so for the decimal number 170, the binary equivalent is 10101010.

Draw the logic circuit for a haly adder using nand gates only?

____

____ c ----->|xor |------------> s

a ->|xor |-+------------>|____|

b ->|____| | _____ _____

+--->|nand |------>|nand |--> c

c ----->|_____| +-->|_____|

_____ |

a ----->|nand |--+

b ----->|_____|

What is absolute and relative error?

An absolute measurement is based on first principle measurements. Most measurements are comparison. An absolute measurement doesn't rely on calibration of the instrument. For example wavelength measurements can be made without calibration by looking at the number of beats per seconds (Hertz).

Absolute error is the magnitude of the difference between the exaxt value of the value measured. It can be expressed as a number, e.g. the molecular weight measured is 27 000 grams per moles while the known molecular weight of the structure is 27 500, the absolute error is 500 grams per mole.

How can you use abstract classes instead of interfaces?

In most cases, you will want to use abstract classes IN ADDITION to interfaces.

You should use an abstract class in the following circumstance:

  1. the abstract class is clearly part of class hierarchy, and does not just describe some sort of basic functionality. Specifically, abstract classes are a good idea where they will be directly inherited from to create a concrete concept, but the abstract class itself is too indistinct to have any specific instance of it created.
  2. You want to provide an implementation for a set of methods that will be reused by a significant number of other classes, all of which can be fit into a class hierarchy.

In practice, abstract classes are a good way to collect common code into one place, to make maintenance easier.

For instance, say you have a class and interface structure like this:

Class A

Interface X

Class B extends A implements X

Class C extends A implements X

Both B and C will have the all the methods declared in X; if the implementation of those methods is the same (or can be made the same), then X is a good candidate for changing to an abstract method:

Class A

Abstract Class X extends A

Class B extends X

Class C extends X

Thus, you have removed the code duplication that was happening when using interfaces.

Note that doing the above is NOT a good idea if any class which implement interface X cannot be made a subclass of the new abstract class X.