answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What are Short circuit operators in c language?

&& and are short circuit operator in C.

It means that expressions chained with these operators are only evaluated until the result is unambiguously determined. For example, the expression a && b is guaranteed to be false if a is false. In this case, the term b is not evaluated, and any possible side-effects of b will not occur. The logical OR () is implemented in a similar fashion: c d is guaranteed to be true of c evaluates to true, and d is not being evaluated in this case.

The ternary ? operator is not a short circuit operator (this was listed as a short-circuit operator in a previous revision of this answer). An expression that uses the ternary operator, for example e = f ? g : h is nothing but an alternative form of an if-else construct. The terms f, g and h may each contain short-circuit operators and be evaluated in the manner discussed above, but the ternary operator itself has no short-circuit characteristic.

What is the difference between structures and class?

HedgingI have removed all but one answer while writing this. Please check my references to the c++ standard before removing this as vandalism; nearly every info bit on this page was incorrect or misunderstood to begin with. BackgroundThe question here regards specifically c++. This is not a cross-language question; neither struct nor class means the same thing from language to language, and c++ is the only language which has both in a way such that they are related (as well as its offshoots, such as concurrent c++.) This question is a common misunderstanding, though, for novice c++ programmers, and is frequently given in c++ faqs. Outside of c++, the answer is "those terms could mean anything." Primary answerThe fundamental issue is that of maintaining backwards compatability with C. When Bjarne created C++ (under the old name C with Classes) he wanted to emulate Smalltalk's object model in C. One of the important features Bjarne was adding to C++ was the concept of accessor privelege (private, public and protected.) When those things are added to a language, it is generally done such that private is the default.

In order for code from C to work with C++, the members of a structure would be expected to be public. However, Bjarne knew that default privacy was important. The solution chosen was to clone the "struct" keyword and make this one small change. In fact structs and classes are the same thing; you can inherit structs from classes and vice versa (though it's pretty stupid, it's legal.) The ONLY technical difference between structs and classes is whether members default to private or public accessorship. This can be derived from the language of section 3.1 of the C++ standard (ISO IEC 14882-1998.)

Repeat with me: "The only difference in C++ between struct and class is that struct is default public, whereas class is default private."

Extra informationSeveral misunderstandings were in place here. I will explain them one by one, so that their removal is not protested. Value and Reference Typing"''structures are value typed where as classes are refernce typed''"'''Incorrect'''. This was the case in Microsoft Visual C++ 5 and 6. The problem is that MSVC5 and 6 are older than C++; they implemented speculative versions of the language before the standard came out. Both have quite a few errors which were good guesses but didn't pan out; this is one of them. An easier example is:

for (int i=0; i<10; ++i) {} int i;

The compiler will incorrectly flag that as a redeclaration and fail.

Inheritance"''Class can be inherited But Structure can't be inherited''"'''False''', and easily tested.

#include

struct base {

public: virtual int foo() { return 5; }

};

struct child {

public: int foo() { return 9; }

};

int main() { base* example = new child; std::cout << child.foo(); }

Initialization"''In structures we cannot initilase the variable during the declaration while in classes we can.''"'''False'''. You may tuple initialize any structure or class which is pure POD, and you may not tuple initialize any structure or class which contains methods. However, you may initialize structures or classes with methods in their constructor instead. Anonymous Classes and Anonymous Structures"''Structure can be declared without a tag at the first time, but not in case of class.''"'''Wrong'''. The fault is in the example code. Old code:

struct { int something; } sFoo;

sFoo sfoo; // works fine

class { int something; } cFoo;

cFoo cfoo; // error: cannot instantiate

The problem is not about classes and structures; it's about default publicity. Structures are default public and classes are default private. When declared in that fashion, since there is no explicit constructor, a constructor is generated by the compiler for each. The constructor for the structure is default public, so the structure constructs just fine. However, the constructor for the class is default private, meaning that at instantiation time, the programmer does not have the access privelege to construct it. The error that results in most compilers talks about being unable to instantiate the class, and that can easily be misunderstood as a code bug, when in fact it's a usage bug.

Polymorphism"''Structure s does not support polymorphism while class does.''"Simply '''false''', and a common and often repeated misunderstanding. The test for inheritance above also happens to display polymorphism. POD versus UDT"''A structure is an entity that is defined in terms of other structures or primitive datatypes. As a result, a structure is normally considered to be a complex-, or compound datatype. With structures the default access type is public. Classes are similar to structures in that they are made up of other datatypes, but they differ in one significant respect - classes contain information on the program functions (formally termed "methods") that will be used to manipulate the data that the class can store. The default access type for classes is private.''"'''This is a more complex issue'''. Whereas this is generally the case in code, that's by convention; the language makes no such requirement. In fact the author of this comment even tips his hat to that structures may have methods later, but the phrasing here suggests that this is part of c++, whereas in fact it is not. More clearly put, there is the concept of a "POD type." POD, or Plain Old Data, is any type which consists solely of inert storage - pointers, integers, arrays, that sort of thing. The alternative is called a UDT, or user-defined type; whereas most POD is user defined and whereas most POD is typal, what a user-defined type is meant to mean is a type which has user-defined behavior, ie something other than what the hardware does. Good examples are arithmetic number classes (a class which stores a numerator and a denominator, instead of the real value, so that there is no loss of precision) and many instances of the C++ string class, which frequently implement such things as shared buffers and lazy copies. The fundamental issue here is that most C++ programmers use the struct keyword to make POD and the class keyword to make everything else, and the behavior is so common that it's important to know it; however it's also important to realize that that's an idiom, not a language requirement, because sometimes POD should have methods like copy constructors, such as when copying the data requires things that aren't usually handled, like copying a word at a time over a limited-range bus. AnswerIn structure,the default access specifier is public,where in class the default access specifier is private.

What are the softwares or languages that i should learn along with software testing tools like QTP to become a good software testing engineer?

The fact is that there is no END to learning software testing. however you can be proficient and in great demand if u have these skills. Functional Testing: Read CSTE book of knowledge - for testing concepts.

Winrunner for automation

QTP for automation

IBM's Rational for automation Performance testing:

Loadrunner for automation

Silktest for automation

Rational Suite for automation

Are alternative operating systems as susceptible to viruses as Windows?

If by "susceptible" you mean "likely to get them", then no. By definition, alternative operating systems have fewer users, and are thus less interesting for virus writers to target. Some alternative operating systems, such as Linux or FreeBSD, have a better security model than Windows, and thus would not be as vulnerable even if they were in the majority. Others, such as AROS have very weak security schemes and lack viruses only through obscurity. Finally, work-alikes of older operating systems, such as FreeDOS, are as susceptible to viruses as their ancestor (MS-DOS). No one writes DOS viruses anymore, though, so FreeDOS is relatively safe in that regard.

Describe about storage allocation and scope of global extern static local and register variables?

Global Varible:

The variable which is declared as "Global" one : having the preveleges to use and access that variable in any class and object( means any where in the program) just like PUBLIC keyword in OOPS concepts.

Static Variable :

If we declare a variable as Static , then it wont have the permission to access that variable through out the program and u have to use it inside the class or object which u declared itself.

All the Best

Annapurna

Why does Microsoft access auto number keep resetting by itself?

When you use the compact and repair tool, the Auto Number in a table will be reset to one greater than the largest existing AutoNumber value. For example, consider a table with an AutoNumber field that has 10 rows with autonumbered values from 1 to 10. If you delete rows 6, 9, and 10, and then compact and repair the database, the AutoNumber seed will be reset to 9 (1 greater than the maximum AutoNumber value in the table, which in this example is 8). If the table has no data in it, the AutoNumber will be reset to 1.

What attribute is used to specify the thickness of a hr tag?

Use the size attribute to specify the height (or thickness) of the rule.

For example:



Note: Since HTML 4.01, the


align, noshade, size and width attributes are deprecated. Use style properties instead.

Is there a way to connect an IRC applet to QuakeNet?

QuakeNet has its own webchat applet named 'qwebirc'. Preferably using their own applet. Information about their applet can be found on their website. A direct link to incorporating a client hosted on their server follows, http://webchat.quakenet.org/. Incorporating their applet on your own server is possible too, by installing their applet's source code on your server. A direct link to the source code for the applet can be found at http://qwebirc.org/.

Convert the hexadecimal number 0xFEDB to the octal?

0o177333 For more like this, use Google. Yes! Google can do these conversions quite simply. Just go to http://www.google.com/search?client=opera&rls=en&q=0xFEDB+in+octal&sourceid=opera&ie=utf-8&oe=utf-8 to see for yourself.

The difference between Digital signal and analog signal?

I'm not sure if you are speaking of a specific instance.... However, a digital signal is a binary representation of the analog signal. The analog signal is constantly measured and the amplitude (voltage at the time of sample) of the analog signal is converted to a binary number at specific intervals (the frequency of the sample rate). The higher the frequency of the sample rate, the more accurate the representation of the analog signal.

Do data on a spreadsheet or in a chart graph true because it's been created using a computer?

Not necessarily. Computers are just tools used by people. If we don't put in the correct information or tell it what we want to do properly, then there may be errors. If you want a computer to add two numbers but accidentally tell it to multiply them, it will multiply them and give you the answer, as that is what it was told to do. It doesn't know that you meant to tell it to add them. If you don't even notice you've done that, then you or whoever sees the final figures may think they are right and not realise there is an error. So it is more important for the users of computers to be careful in how they do things. If you do things correctly, then the results you get should be correct. It is important to always check that the results are correct, so you can find mistakes you've made and fix them. That way, the next time the computer does the calculation it will do it the way you want it.

Computers will do what you tell them to do, but not always what you want them to do, so you have to make sure what you tell them is what you want. So if you want it to add two numbers for you then make sure you have told it to add two numbers and not told it to multiply them or subtract them or divide them, because it will do what you tell it. Most errors in computers are in fact human errors, because people have given the wrong instructions.

What is a difference between high level language and low level languagei n computer?

A low level language would be "Machine Code". In simplistic terms coding operations are performed directly into CPU hardware registers which the CPU understands without any translation. These codes must adhere to recognised instruction sets hardcoded into the CPU architecture.

High Level languages have an interface which isolates the programmer and translates the programmers code on the fly/after compilation into instruction sets a CPU can understand.

Why are few programs written in binary form?

The lower-level the language, the harder it is to write programs in. It takes a long time to write a program in machine language...and it is way more trouble than writing it in an abstracted language.

Write down the algorithm to delete a node from doubly linked list whose data item is given?

1. Find the element is the list. Let pointer 'p' point to it.

2. Delete it from the list:

if (p->Prev) p->Prev->Next = p->Next;

else List->First = p->Next;

if (p->Next) p->Next->Prev = p->Prev;

else List->Last = p->Prev;

3. Release the memory associated with it.

Is Visual C plus plus a good Game Development Language?

Hmm...
Visual C++ isn't really a language, it's more like an environment in which you can create programs using different tools.
Anyway, C++ is the best language you can learn if you want to get started as a game programmer. It's the most efficient and it's probably gonna stay that way. Hope that helped.


Rocamora

What is mean by functions in oops?

Functions are used to carryon a specific task or to perform specific operation.

How can you write TSR using C?

printf("TSR");

If you are talking about a terminate and stay resident DOS program, the easiest way to write a TSR is to use a TSR toolkit, which does all of the basic work for you. Otherwise, even to describe the process would take too long (it can be quite complex).

Where are the random numbers placed in slot machines?

While older slot machines used a mechanical/mathematical approach (the number of icons on each wheel, combined with the required combination of those to yield various winning matches), today's typical slot machine are completely computerized. They generate thousands of random combinations per second, and when you pull the handle (or push the button), the cycle stops and you get the number it was up to. The handle, the slowing-down of the wheels, etc., are there simply for historical purposes.

Difference between second language and target language?

the second language is the language that one learns after ones native language,whereas target the language is the language of translation,situation or sitting in which reader needs to ude the language.

How do you make an int value increase every 24 hours in JavaScript?

setInterval ( "increaseIntVal()", 86400000);

function increaseIntVal( )

{

// (do something here)

}

What is the difference between a foreground and a background task?

Foreground task is a process which happens on screen and background task is a process which is run offscreen.

Ex: If you are clicking on a link and a page is opened ie foreground output bt to show that page to the end-user, there is a process in the programming language which is created off-screen by the developer of the program or website.