answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

How are pointer different from other variables?

A pointer variable is a variable that contains the memory location of another variable or an array (or anything else in memory). Effectively, it points to another memory location.

For standard variables, you define a type, assign a value to that variable or read the value from it, and you can also read the memory location (&n = memory location of n) of the variable.

For pointers, you can point them to any variable, even another pointer, and you can get the value of the variable it points to (*p), the location of that variable in memory (p), or the address in memory of the pointer itself (&p).

Consider:

long n = 65;

long *p;

p = &n;

Results:

Type | Name | Location | Value

long n 0xA3FF 65

long * p 0x31DF 0xA3FF

So p points to n. Now,

n = 65

&n = 0xA3FF

p = 0xA3FF

*p = 65

&p = 0x31DF

You may find yourself having to use typecasts frequently when using pointers.

Pointers are useful when passing data to functions.

For instance, consider the following function:

void add(int a, int b, int c) { c = a + b; }

The problem here is that the computer copies each variable into a new memory location before passing them to the function as local variables. This function effectively does nothing. However, if you change the function to:

void add(int a, int b, int *c) { c = a + b; }

and call the function by passing in the location of the variable to the function:

add(a,b,&c);

then you can modify the variable itself.

Pointers are also good for working with arrays:

char *c = "Hello World";

int i=0;

while (c[i] != 0x00) { cout << c[i]; c++ } //print one letter at a time.

Why for loops is used?

The for loop is used when you want to do a procedure, a certain amount of times.

The for loop is used when you already know how many times the loop will be repeated.

for example... you want to scan an array.

you can do something like this.

for(i=0;i<myArray.length;i++){

if(myArray[i] == 5){

alert("This array position contains the number five.");

}

}

the code above is javascript.

But the idea is the same in any language.

This is one use, but as I said. You use it when you already know the amount of times the loop will be repeated.

Algorithm of conversion decimal to hexadecimal?

The hexadecimal notation is base-16, so for small numbers, arrange them right to left as powers of 16 (units 0 to 9 and A through F representing 10, 11, 12, 13, 14, and 15).

Examples: 21 = 15 hex (16+5) and 31 = 1F (16+15)

For larger numbers, see the process at the related link below.

Here is a program:

#include

#include

void main()

{

int n;

clrscr();

printf("Enter Decimal Number: ");

scanf("%d",&n);

printf("Hexadecimal value is: %x",n);

getch();

}

How do you say daddy in binary code?

It depends on the encoding but if we assume standard ASCII encodings, the representation is the same for all systems, the only difference being the number of leading 0 bits per character.

7-bit ASCII (ISO/IEC 646):

1100100 1100001 1100100 1100100 1111001 0000000

8-bit ASCII (ISO/IEC 8859, Windows-1252 and UTF8):

01100100 01100001 01100100 01100100 01111001 00000000

UTF16:

00000000 01100100 00000000 01100001 00000000 01100100

00000000 01100100 00000000 01111001 00000000 00000000

To perform these conversions, convert each character to its ASCII representation (in decimal):

d = 100

a = 97

d = 100

d = 100

y = 121

For completeness, we should also include the null-terminator, character code 0.

null = 0

Now convert each decimal value to its 8-bit representation in hexadecimal:

100 = 0x64

97 = 0x61

100 = 0x64

100 = 0x64

121 = 0x79

0 = 0x00

Convert each hexadecimal digit to its 4-bit binary representation:

0x6 = 0110

0x4 = 0100

0x6 = 0110

0x1 = 0001

0x6 = 0110

0x4 = 0100

0x6 = 0110

0x4 = 0100

0x7 = 0111

0x9 = 1001

0x0 = 0000

0x0 = 0000

Place the binary codes in sequence.

"daddy" = 01100100 01100001 01100100 01100100 01111001 00000000

Finally, add or remove leading zero bits to suit the actual encoding.

What is the difference between linking and embedding?

"Linking" refers to providing a "reference" to the source data; if the source is deleted, the link no longer functions; many different types of files, programs, and programming interfaces refer to displaying externally located data as linking. Linking is advantageous when the data might later change and the program or file that contains the link would benefit from having the latest version of the data.

"Embedding" has a slightly different context depending on the context that you are using it. If you are referring to a file (such as a Flash file, Microsoft executable file, and so on), embedding refers to storing the data directly within the other data type. An executable can store Icon files, for example, which alter their presentation on the Desktop or Start Menu by showing an identifying image so users can tell programs apart visually. Embedding in a document file depends on the type of document file in question. Some document files store a copy of the data in the file, while other document formats simply imply that a plugin program is embedded into the document's data. Finally, applications can embed other applications within them during execution. For example, a program could be written to embed an Internet Explorer web viewer into a larger program.

When embedding refers to "storing a copy", the benefit is that the source file can be deleted without affecting this dependent file. The disadvantage, of course, is that updates to the source data require updating the dependent file through whatever means available (applications have to be recompiled, documents have to be edited, etc).

When embedding refers to "running a copy of a program within another program", there are many advantages: less code has to be used each time a component is reused, the component can be upgraded independently of the main program, and a component can crash without crashing the entire application (possibly including recovering data from the failed component). The disadvantage of embedding is, of course, memory usage will be higher than having a single, unified program.

What is the difference between a programming language and a application software?

You use a programming language in order to create applications. The programming language is typically implemented within an integrated development environment (IDE), which is itself an application that was written in a previous incarnation of the same language or in another language altogether.

Explain the differences between strategic planning and operational planning?

Strategic planning is deciding what a company will do. Operational planiing is deciding how that will be done. For example, Kodak made a strategic decision to enter the digital photography business when the tradition film market began to deteriorate. They decided what products offered opportunities in that industry. Then, they had to formulate an operational plan - product development, manufacturing process and location, etc. The operational plan will also include some strategic planning. For example, the Marketing department had to decide how to best position the products in the marketplace (and which markets or locations) and then plan how to design the marketing materials.

What is pseudo code in c?

Writing in pseudo code means writing in a natural language, not in any specific programming language, so there is no thing as "pseudo-code used in C" as opposed to "pseudo-code used in Java".

When you write in pseudo-code, you don't have to follow any specific syntactic rules, just to describe the steps you will use in your algorithm.

For example, pseudo-code for bubble sort (taken from wikipedia):

procedure bubbleSort( A : list of sortable items ) do swapped = false for each i in 1 tolength(A) - 1 inclusive do: if A[i-1] > A[i] then swap( A[i-1], A[i] ) swapped = true end ifend for while swapped end procedure

It is not written in any programming language, but it should be easy to implement this in any language after you understand the idea from the pseudo-code.

How much does a computer programmer charge per hour?

That depends upon who the programmer works for. Some companies pay weekly, some every other week. Contractors might bill and get paid once a month. If you do piece work (self-employed) you might get paid by the job.

What is a command argument?

Command line arguments are provided at the time of running the program. Example: Suppose that your program needs input name and its value then running it from commandline(DOS prompt) you provide the values after the program name java xyz name JAX(name is name and value is jax)

What is 4 generation programming language?

There is no standard which defines what 4GL (fourth generation language) actually means. The terms 1GL, 2GL and 3GL were introduced retrospectively but they have no actual meaning because we never classify a programming language by generation. If we did, C++ would be a 10th generation language!

The term 4GL was formally introduced in 1981 to refer to high-level, non-procedural languages but marketing types were quick to describe their client's procedural languages as being 4GL -- because 4GL is "better" than 3GL -- without having to actually explain what 3GL meant. It was nothing more than meaningless jargon.

There have been many unsuccessful attempts to standardise the meaning of 4GL, but none have succeeded. Part of the problem is that 1GL is usually used to classify machine code (as used on first-generation computers) while 2GL is used to classify assembly languages 9despite assembly language being used on first-generation hardware), leaving 3GL for all the high-level languages (portable languages). Attempting to distinguish one portable language from another by calling it 4GL is somewhat pointless given there are already far better ways to classify languages.

High-level languages are best classified by the paradigms they support: declarative; imperative; structured; procedural; object-oriented; functional; logical; and so on. We can also classify by the domains they were primarily intended for: general-purpose; database management; applications software; artificial intelligence; and so on. Dividing high-level languages into two distinct groups (3GL and 4GL) tells us next to nothing about a language's capabilities, particularly when no-one can agree on what 3GL or 4GL actually means -- despite Wikipedia's repeatedly unsuccessful attempts to the contrary.

What are the simalarities of high and low level programming?

high level language; is a computer language that is near to human language.

high level programming is a process of programming high level language.Example,c++,java,cobol are one of them. The reverse is true for the low level language.

Is the C Plus Plus language good for making software?

C++ is one of the most flexible programming-languages there is. So, my first answer would be 'Yes'. However the question is, if C++ is the most suited language for the software that you want to make. There may be a alternative, easier language, in wich you can develop your software. Jahewi :-)

Show the data processing cycle?

The data processing cycle is the process of converting data into useful information.

The data is processed again and again until the accurate result is achieved.

The three basic activities of data processing are:

1. Input

2. Processing

3. Output

How constructor is different from normal member function?

A constructor differs from a normal member function in three ways:

  1. A constructor never returns a result. The constructor's declaration reflects this by not even declaring the function as "void."

    The common design hypothesis is that a well-designed constructor cannot fail, other than maybe in an irrecoverable way (such as a fatal running out of memory).

  2. A constructor is never called explicitly except with the new operator.
  3. Constructors impose further restrictions. For example, they cannot be declared abstract or virtual, and may have visibility requirements.

    The common design practise is that at least the default constructor is declared public.

What are the advantages of a program over an algorithm?

The term algorithm is now applied to many kinds of problem solving that employ a mechanical sequence of steps, as in setting up a computer program. The sequence may be displayed in the form of a flowchart in order to make it easier to follow.

In computational devices with a built-in microcomputer logic, this logic is a form of algorithm. As computers increase in complexity, more and more software algorithms are taking the form of what is called hard software. That is, they are increasingly becoming part of the basic circuitry of computers or are easily attached adjuncts, as well as standing alone in special devices such as payroll machines. Many different applications algorithms are now available, and highly advanced systems such as artificial intelligence algorithms may become common in the future.

Characteristics of procedural programming?

FeaturesWhen the creation of Embedded Wizard started in 2003, the main idea was to deliver the comfort - known from PC development tools - to embedded systems. With the help of customer's feedback, it has been improved ever since, to support the daily GUI development workflow in the best possible way.

See 10 features that will simplify your GUI project:

1. Integrated Development Environment (IDE)

Embedded Wizard's comfortable IDE provides drag-and-drop, copy-and-paste and undo-redo functionality. Sophisticated utilities, like the object browser and the 'assistants', enable an easy overview over the application structure and a quick access to its members. Developers will find everything they need in one familiar place.

2. Visual Programming Approach

Create GUI applications by clicking, dragging and connecting visual to logical components with the mouse. Benefit from instant WYSIWYG (What you see is what you get) and evaluate your GUI's appearance already at design time. Even target constraints, like limited color range, can be displayed in the IDE. And with Embedded Wizard's instant prototyper you can step-by-step verify your GUI's design, behaviour and usability.

3. Flexibility & Platform Independence

Implement the desired behavior of a single GUI component or the entire application in Embedded Wizard's own, platform independent programming language, called 'Chora'. It is very similar to C, C++ and easy to learn. Besides standard statements like if, for, while, switch and local variables, Chora also provides useful operators and data-types especially for GUI applications. Chora also includes a garbage collector. Finally, Embedded Wizard analyses your project, intercepts possible errors and generates ANSI C code out of the project - optimized for each target (See 9. Targeting).

4. Object Oriented Programming

All components of a GUI application are realized as classes. Embedded Wizard's programming language 'Chora' supports derivation of classes, inheritance, overriding of inherited class members and polymorphy. This enables a highly iterative development process and results in well-structured, easy to maintain projects and reduced code size. Developers, who are familiar with OOP, can benefit from that knowledge, however, Embedded Wizard also supports a very simple programming model, which allows also developers without deep OOP knowledge, to create great results in a very fast time.

5. Ready-to-use components

For an easy start-up, the 'Mosaic' class library was designed. It provides visual components for displaying text, images, color gradient, etc. as well as sophisticated widgets like buttons, select boxes, text fields, menus, panels and more. The class library also includes infrastructure for animation effects, event handling, focus handling, alignment, arrangement, touch screen and mouse support, and many more.

6. Localization

Develop multilingual applications, which can change text, graphics, fonts and even layout for each language. Thanks to UNICODE support, GUI applications can combine Greek, Cyrillic, Japanese, Far East and other notations within a single text. Whenever the current user language is switched, all dependencies are evaluated and displayed automatically.

7. Variants & Diversified GUIs

"Variants" are a unique concept of Embedded Wizard, to facilitate the handling of different themes, layouts and screen resolutions within one GUI project. Variants of a GUI can be determined at compile time or switched at runtime. Moreover, the integrated JPEG file support, enables dynamic loading of JPEG images from hard disk or a content provider into the GUI for more flexibility and variety.

During runtime, the intelligent resource management takes care, that only the needed resources (e.g. fonts, images) are loaded to save memory.

8. Debugging

If your GUI application does not behave as desired, the powerful integrated debugger enables the step by step execution of 'Chora' statements, the setting of breakpoints and inspection of all variables and objects. Thus, you can be sure, that any GUI code generated by Embedded Wizard runs perfectly stable.

9. Targeting

To bring your application to a particular target, Embedded Wizard analyses the project, intercepts possible errors and translates it into optimized, highly reliable and well-documented ANSI C code. The result can be compiled and linked with your main software. All target specific aspects, like the CPU architecture, the operating system and color format of the screen are handled by 'platform packages', which are tailored for a specific target platform. You can simply exchange the platform packages to generate code for various targets out of a single GUI project.

10. Documentation

To document the structure of your GUI application, Embedded Wizard can automatically create Microsoft HTML help files (chm), which are especially helpful when transferring your project to colleagues or third parties for maintenance and modifications. The documentation describes components, shows their inheritance and lists their members. It is enriched with descriptions that can be entered by developers optionally for every member in the project.

How do you create and run assembly language?

Assemblies are the smallest functional unit of deployment.They are created whenever we compile a Csharp program.They contain file or collection of different modules. There are two type :Shared Assembly and private assembly.

Private assembly is created when the functionality of the component is specifically associated with an application.

Shared assembly is created to have a single copy of it which is kept in the GAC ,GAC is Global Assembly Cache.

There are 4 components of assemble 1.MSIL Code, 2)Metadata 3)Manifest 4)Resource.

Manifest contains the assembly information such as assembly version,security,identity,references to other assembly.

Msil Code:It is Microsoft Intermediate Language,this can be efficiently converted to native code by the JIT Compiler i.e Just-in-Time Compiler. Resources are the resources allocated to that assembly.Metadata provides information about the type defined in the assembly such as classes ,interfaces.

What are queues?

A queue is a first-in, first-out data structure. We use queues when one thread needs to communicate with another but they operate at different frequencies (asynchronously), such that the first thread may produce input for the second thread faster than the second thread can actually process each input. Thus the first thread will place each input on a shared queue and the second thread can deal with each in turn as and when it is ready. To avoid data races, all operations that modify the queue must be mutually exclusive, such that only one thread can gain access to these operations at any given moment. This can be implemented using a lock, such that only one thread can "own" the lock while all others must wait until the lock is released.

Example of formatted functions in C?

formatted functions::: Follows a fixed format like scanf,printf

Unformatted functions:::Do not have fixed format like gets,getchar

What is assembly language. Give its advantages over machine language?

Machine language is a stream of bytes interpreted by the CPU to perform operations on the computer. Reading machine language directly requires knowledge of or access to a list of "opcodes" (the numeric value associated with each instruction) in the program. Assembly language is a human-readable translation of machine language with additional features such as mapping of symbols to actual memory addresses or registers. People who use assembly language ultimately also become proficient in understanding machine language.

For example, in the x86 architecture, this machine language:

  • B8 05 00
is represented in assembly language as:
  • mov ax, 5
It is clear for someone who understands the assembly language that the instruction will move the immediate value "5" into the register "ax."

What are the factors that determine the choice of programming language when developing an application?

It's more often than not, not a programmers choice, but when it is, typically:

Platform (e.g. if you are writing something for Android, or iOS, your choices are somewhat limited, same goes for cross OS compatibility) Objective (e.g. are you writing a kernel module or a website)

Familiarity (e.g. if i know Ruby and don't know PHP)

Performance needs (e.g. am i writing a network stack or a text editor)

Libraries (e.g. PHP built-in database libraries, Java does not)

Language specifics/purpose (e.g. it's a good idea to write a protocol in more functional programming language like Scala than in Perl or Java)