answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What are the disadvantages of client side processing?

The code is exposed to the client. This can reveal implementation details that should be kept private, including intellectual property.

What is register and advantages of register?

registers are a small high-speed memory inside CPU. one advantage of using them is increase in CPU speed because of their high access rate in comparison by ram.

What does NP equal P mean?

It is still an open question. NP is the class of problems which can be solved in polynomial time by a program run by the theoretical non-deterministic machine. (That is, there is a polynomial upper-bound for the time it would take for the machine to compute the answer, with respect to the size of the input).

P is the class of problems which can be solved in polynomial time by a program run by an actual computer (or some abstract model thereof).

So far it is not known for sure whether the two classes are the same or not. There are many problems which are known to be NP, and for which no polynomial solution for a real computer is known. However, there is currently no proof that such a solution does not exist (perhaps it does and no one has found it yet). That is why whether P equals NP or not is still an open problem.

How do you print array variable without using array subscripts?

Well the most prolific answer to this query would be the use of pointers.Use a pointer and allocate it to the array of interest and start printing.

What is the program for palindrome numbers from 500 to 100?

#include<iostream>

// forward declarations...

unsigned reverse (unsigned, const unsigned base = 10);

bool is_palindrome (const unsigned);

// the program...

int main (void) {

const unsigned max {500};

const unsigned min {100};

std::cout << "Palindromes from " << max << " to " << min << std::endl;

for (unsigned num {max}; num>=min; --num) {

if (is_palindrome (num)) {

std::cout << num << std::endl;

}

}

}

// Returns the reverse of a number using the given base (default: base 10)

// Note: trailing zeroes do not become leading zeroes so reverse (100) returns 1 not 001.

// However, the reverse of 0 is obviously 0.

unsigned reverse (unsigned num, const unsigned base /* = 10 */) {

unsigned rev {}; // zero-initialised

while (num) {

rev *= base;

rev += num % base;

num /= base;

}

return rev;

}

// If the reverse of a number is the same number, that number is a palindrome.

// All single-digit numbers are palindromes, including 0.

bool is_palindrome (const unsigned num) {

return num == reverse (num) ;

}

What is the absolute machine code?

The very lowest possible level at which you can program a computer is in its own native machine code, consisting of strings of 1's and 0's and stored as binary numbers. The main problems with using machine code directly are that it is very easy to make a mistake, and very hard to find it once you realize the mistake has been made.

How do i write a program in c langua ge for the implementation of binary search with output?

There are various ways to implement a binary search, but the simplest makes use of a sorted array. It must be sorted because we need to know where values are in relation to one another. That is, if we know that element X has the value Y, then all values less than Y must be in the first half of the array, and all values greater than Y must be in the second half of the array.

We begin by looking at the middle element of the array. If there is no middle element (the array is empty) then the value does not exist. But if the middle value holds the value we are looking for, we are done. Otherwise we compare values to decide which half of the array can be eliminated. We then repeat the process with the remaining half of the array.

What is the difference between copy command and move command?

A move command is simply a copy command which deletes the original once it's finished.

Write a shell script to count the number of times is appears in a given text file?

You don't need a shell script to do this; use the 'grep' command with the '-c' option to count the number of occurrences of some pattern.

Dereferencing operator in c?

When we are talking about dereferencing in C we are talking about the pointers and how to get value from them, not address.

Dereferencing operator notation is "*".

Here is a simple example of dereferencing:

int num;

int pNum*;

pNum = # /* make pNum pointer point to numlocation in memory/stack */

*pNum = 7; /* setting pNum value to 7. Note! numvalue becomes 7 too, because pNum points to the same memory location as num */

Who is Marician Hoff?

hi bye i hate yo! Marcian Hoff was one of the inventors for the microprocessor. The microprocessor is like the engine for the computer. When you turn on the computer the microprocessor helps the computer start.

How does a subroutine work in Linux?

With Linux being mostly written in C and normally interfaced via C libraries, I'll give an example from the C point of view, thus I'll refer to functions in place of sub routines.

Using the following C function as an example:

int add(int number1, int number2) { return (number1 + number2); }

Before the add function is called, the values of its arguments are pushed onto the stack by the caller in reverse order (number2 then number1).

When the function is called, it reads the values of number1 and number2 from the stack into CPU registers where the addition is done, leaving the answer in register eaxbefore returning from the function.

Different activities in the 6 phases in classical waterfall model?

1) Identify client requirements

2) Identify system requirements

3) Create an overall design

4) Create a detailed design

5) Develop product

6) Test product

What is assembly program?

An assembly program is a machine-dependent program written in a low-level symbolic code known as assembly language.

Program for derived class in cpp?

#include<iostream>

class base

{

int m_data;

public:

base(const int data):m_data(data){}

base(const base& cpy):m_data(cpy.m_data){}

base& operator=(const int rhs){m_data=rhs;return(*this);}

base& operator=(const base& rhs){m_data=rhs.m_data;return(*this);}

virtual ~base(){}

};

class derived

{

public:

derived(const int data):base(data){}

derived(const derived& cpy):base(cpy){}

derived& operator=(const int rhs){return(base::operator=(rhs));}

derived& operator=(const derived& rhs){return(base::operator=(rhs));}

virtual ~derived(){}

};

int main()

{

derived d=42;

}

Signed binary subtraction 000000111001-111010000101 equals 000110101110 right?

Wrong. You don't say whether you are using ones-complement notation or twos-complement notation, but in either case you'd be wrong. Your answer of 000110101110 is 430 decimal, but the correct answer is 435 or 436 depending on which notation you use.

Ones-complement notation:

000000111001 - 111010000101 = 000110110011

Decimal equivalent:

57 - (-378) = 57 + 378 = 435

Twos-complement notation:

000000111001 - 111010000101 = 000110110100

Decimal equivalent:

57 - (-379) = 57 + 379 = 436

Note that in ones-complement, converting the sign of any value simply inverts all the bits. So if we invert 111010000101 we get 000101111010 which is 378, thus the original signed value was -378. In twos complement we invert all the bits (as per ones-complement) and add 1, so 000101111010 + 1 is 000101111011 is 379, thus the original signed value was -379.

QED.

Which data structure is used for recursion?

this question depends on what the recursion is being used for.....

sumit kumar srivastava

9455587002

What is the difference between deadlock and a race condition?

Race Conditions

A race condition occurs when two threads access a shared variable at the same time. The first thread reads the variable, and the second thread reads the same value from the variable. Then the first thread and second thread perform their operations on the value, and they race to see which thread can write the value last to the shared variable. The value of the thread that writes its value last is preserved, because the thread is writing over the value that the previous thread wrote.

Deadlocks

A deadlock occurs when two threads each lock a different variable at the same time and then try to lock the variable that the other thread already locked. As a result, each thread stops executing and waits for the other thread to release the variable. Because each thread is holding the variable that the other thread wants, nothing occurs, and the threads remain deadlocked.