Why is binary data representation and signaling the preferred method of computer?
The short answer is that it's cheaper. Base 2 (binary) is the most primitive form of numeric notation there is and it is extremely simple to implement using a bewildering array of mediums. For example, a switch is either on or off; a capacitor has a sufficient charge or it does not; polarised particles are either positively or negatively charged; a punch card has a hole at a given position or it does not; a DVD either has a flat or a land; a barcode element either reflects light or it absorbs light; and so on.
While it is certainly possible to implement a digital computer using a numeric base other than base 2, the complexity (and the cost!) of interpreting those bases increases exponentially. Polarised digital states (yes/no, true/false, on/off, black/white, positive/negative) are extremely simple to detect and represent because there are only 2 possible states and 1 threshold per digit. More importantly, switching from any one state to any other state is a constant time operation.
Consider the capacitor: it either has sufficient charge or it does not, but it must be refreshed at regular intervals in order to maintain state (if we don't refresh often enough, a full charge will drain away in just a few milliseconds resulting in a misread digit). But if the specific level of charge actually indicated a digit in the range 0 to 9 we'd not only need much larger capacitors to cover the range with comfortable margins of error between refreshes, we'd also need extremely precise transistors to both read and refresh the charge. The more digits we represent per capacitor, the more complex it becomes.
Explain event driven programming?
Let's say, I were to go create a button object for the program user to click on...; the button text might say.
[Click here]
...or,...
[Click here to see Help]
...or,...
[Click here to sort list]
-etc.
At first, the button would just simply sit there; and, therefore, the program would take no further action; except to wait for an 'event' to happen.
Whenever the user of my program clicks on that button; then, the button 'click event' will get triggered.
The users click might trigger off some other code to start working...such as, when the button is clicked on do this/or, do that...display a text message/or, sort list/ -etc.
Each seperate object has it's own list of possible events. For example, a button can have the following list of events...
button.Focus()
button.Click()
button.DoubleClick()
-etc.
so, the program waits to see what type of event is happenning, first ...and, when a certain type of event does, eventually, occur...then, this leads to more programming code getting executed.
This is how OOP/Object Oriented Programming languages...programming using objects/objects that are 'event driven' works.
How do you correct syntax error logical error?
Your IDE should include syntax checking, which highlights errors as they occur (similar to a grammar/spell checker in a word-processor). Attempting to compile a program that contains a syntax error will fail to compile, but it should provide a list of all the errors that need to be fixed. If the error is an obvious one, the error list may include a solution to the problem, but you must make the necessary changes manually -- the syntax checker won't modify any code for you, even if the error is an obvious one, such as using . instead of -> on a pointer.
DLL files are files shared between a number of software programs (and are similar to .EXE files), used in Microsoft Windows and OS/2 operating systems. A static library attaches itself to the executable itself and hence supose some function A is to be used by n applications, all n apps will have functions A definition in their executables. BUT if func A is written in a dynamic link library or DLL, first DLL should export this function. and then n apps can call into this function. it will save a lot of memory. you can also dynamically load the library by calling LoadLibrary function. generally DLL will export all required functions which are supposed to be called by applications.
What is the program structure of C language and C plus plus?
There is no single structure to a C++ program. C++ is multi-paradigm and allows programmers to use any combination of C-style programming, object-oriented programming and template metaprogramming using a mixture of primitive built-in types, standard library types and user-defined types.
Write a c program to implement tower of hanoi moves?
/* hanoi.c */
#include <stdio.h>
#include <stdlib.h>
static long step;
static void Hanoi (int n, int from, int to,int spare)
{
if (n>1) Hanoi (n-1,from,spare,to);
printf ("Step %ld: move #%d %d-->%d\n", ++step, n, from, to);
if (n>1) Hanoi (n-1,spare,to,from);
}
int main (int argc, char **argv)
{
int n;
if (argc==1 (n= atoi(argv[1]))<=0) n= 5;
step= 0;
Hanoi (n, 1, 2, 3);
return 0;
}
How do you write a function that counts the number of characters in a string?
As this is probably a homework question, I will give you some pseudo code:
[code]
num_chars = 0
READ ch FROM string
WHILE ch IS NOT END OF STRING
num_chars = num_chars + 1
READ ch FROM string
END WHILE
[/code]
Remember that in C, we use what are called "C-strings". C-strings are a pointer to a continuous group of characters in memory which are terminated by a null character. The null character is '\0', and has an integer value of 0.
The C-string generally points to the first character in the string. To access the value of this character, you must use the dereferencing operator, *. If you want to move to the next character, you simply add 1 to the pointer.
So if you have a C-string:
char *str = "abcd";
then:
*str '\0'
Anything past the null character is undefined. Trying to access this data is considered to be a buffer overflow, and is very dangerous.
Note that c-strings created as pointers should always be treated as immutable, as trying to change them might produce errors. Many compilers will allocate the above string inside the static data area, along with any constants or literals which can not fit inside the immediate field of an instruction.
If you want a mutable string, then declare it as a character array:
char str[] = "abcd";
This method of declaration will explicitly allocate memory on the stack to store the c string in, and as such, the string can be safely manipulated without fear of unintended side effects.
What part of the computer processes information?
Computers takes input through input devices like keyboard and mouse. Every actions on or by the input devices are converted into electromagnetic signals. These electrical signals are sent to Signal Processing Units, which converts the analog signal into digital one and transfers it directly to processor or to processor via memory for further processing. Like sensors inside the mouse record every movement of mouse into electrical signals and transfer it to ADC (analog to digital converter.)
What is the oldest programming language?
Plankalkül (Plan Calculus), created by Konrad Zuse for the Z3 computer in Nazi Germany, may have been the first programming language (other than assemblers). This was a surprisingly advanced programming language, with many features that didn't appear again until the 1980s.
The first high-level programming language that we know of is the IBM Mathematical Formula Translating System, or Fortran for short.
What is the C plus plus program for regula falsi method?
#include
#include
#include
/* define prototype for USER-SUPPLIED function f(x) */
double ffunction(double x);
/* EXAMPLE for "ffunction" */
double ffunction(double x)
{
return (x * sin(x) - 1);
}
/* -------------------------------------------------------- */
/* Main program for algorithm 2.3 */
void main()
{
double Delta = 1E-6; /* Closeness for consecutive iterates */
double Epsilon = 1E-6; /* Tolerance for the size of f(C) */
int Max = 199; /* Maximum number of iterations */
int Satisfied = 0; /* Condition for loop termination */
double A, B; /* INPUT endpoints of the interval [A,B] */
double YA, YB; /* Function values at the interval-borders */
int K; /* Loop Counter */
double C, YC; /* new iterate and function value there */
double DX; /* change in iterate */
printf("-----------------------------------------------------\n");
printf("Please enter endpoints A and B of the interval [A,B]\n");
printf("EXAMPLE : A = 0 and B = 2. Type: 0 2 \n");
scanf("%lf %lf", &A, &B);
printf("The interval ranges from %lf to %lf\n", A,B);
YA = ffunction(A); /* compute function values */
YB = ffunction(B);
/* Check to see if YA and YB have same SIGN */
if( ( (YA >= 0) && (YB >=0) ) ( (YA < 0) && (YB < 0) ) ) {
printf("The values ffunction(A) and ffunction(B)\n");
printf("do not differ in sign.\n");
exit(0); /* exit program */
}
for(K = 1; K <= Max ; K++) {
if(Satisfied 0) { /* first 'if' */
Satisfied = 1; /* Exact root is found */
}
else if( ( (YB >= 0) && (YC >=0) ) ( (YB < 0) && (YC < 0) ) ) {
B = C; /* Squeeze from the right */
YB = YC;
}
else {
A = C; /* Squeeze from the left */
YA = YC;
}
if( (fabs(DX) < Delta) && (fabs(YC) < Epsilon) ) Satisfied = 1;
} /* end of 'for'-loop */
printf("----------------------------------------------\n");
printf("The number of performed iterations is : %d\n",K - 1);
printf("----------------------------------------------\n");
printf("The computed root of f(x) = 0 is : %lf \n",C);
printf("----------------------------------------------\n");
printf("Consecutive iterates differ by %lf\n", DX);
printf("----------------------------------------------\n");
printf("The value of the function f(C) is %lf\n",YC);
} /* End of main program */
Where is Hexadecimal commonly used?
Hexadecimal is commonly used in comoputing to represent a memory byte.
Why you use linked list instead of arrays?
You would use linked lists instead of arrays in two instances:
1) You don't know how long your list will be and it is apt to dramatically change length.
2) You will make lots of additions and removals in the middle of your list.
What is insertion sorts in worst case time?
Best case for insertion sort is O(n), where the array is already sorted. The worst case, where the array is completely reversed, is O(n*n).
The data structures are user defined data types specifically created for the manipulation of data in a predefined manner. Examples of data structures would be stacks,queues,trees,graphs and even arrays(also reffered as data structure)
What is the best way to learn algorithm?
By examples. That's the only way, I think.
# Choose a generic purpose programming language, like ANSI C. # Install in your computer the needed software for compiling and running routines. # Find a Tutorial in the Internet (There are lots of ANSI C tutorials) # Read it and try to make little examples of every little thing explained. Find code examples in the Internet. # Step by step you'll find out that you can do more complicated things with a little effort.
Good Luck!
What are the advantages of using string in c plus plus?
I assume you mean std::string rather than strings in general. Programs that need to convey any information to the user will usually require many strings, and when retreiving input from the user, a string (in conjunction with a string stream) are the best way of checking that data before processing it. The std::string (and its wide-character counterpart, std::wstring) needn't be used for all strings, of course, but they are much easier to work with when strings need additional processing, such as when concatenating strings, or searching within strings. And if you need more functionality than is provided by std::string alone, you can always derive a new string object from std::string and embelish it as required. Of course, if you require less functionality than is provided by std::string then you have the option of creating your own lightweight string class from scratch. However, for most applications, std::string is lightweight enough, and if you use std::string at all, then there's little point in writing your own string class. Aside from re-inventing the wheel (one of the reasons the STL exists), it's only going to increase your code size. However, for new programmers, it can be an interesting excercise creating your own string class, if only to show how std::string works and why re-inventing wheels is rarely a good thing.
There is no such element called Ai. Although Al is the atomic symbol for Aluminium (aluminum). Aluminium, as you probably know, is a metal and is in group (column) 13 of the periodic table and in period (row) 3.
Why did c plus plus become more popular inspite of so many object oriented languages available?
All languages are interesting to some degree or another. Programming languages in particular allow us humans to communicate with and ultimately control computers, bending them to our will. However, some languages are better than others for certain tasks. C++ is a general purpose, cross-platform, high-level language that can produce highly-efficient machine code (the native language of the computer). What makes it interesting is subjective -- each programmer will have their own likes and dislikes -- but ultimately the language gives a high-degree of control over the hardware, exploiting specific features of the architecture.
The same kind of thing can be achieved using Assembly Language (a low-level language), and in many ways would be regarded as a more interesting language than C++. But it is extremely difficult to work with. Even if you have access to a vast library of pre-written routines, you still require intimate knowledge of the underlying hardware and must write programs in minute detail. C++ can achieve similar results, but the abstraction between the hardware and the code you write is such that you needn't concern yourself with the hardware quite so much. That is, a single instruction in C++ can easily generate dozens of assembly instructions.
C++ becomes more interesting when compared to languages that don;t provide the level of control, such as Java. This is an entirely object-oriented programming language, with a higher-degree of abstraction (with little or no interaction with the underlying architecture). Rather than producing machine code, Java produces byte code which can be run on any platform that supports the Java Virtual Machine. As such, it is more portable as programs need only be compiled once to run on any platform whereas C++ code must be compiled separately for each platform, and must include code to filter out code that is irrelevant to the current platform. However, since Java programs must run in a virtual machine, they are very much slower than equivalent C++ programs.
C++ is also more interesting in that you aren't restricted to using object-oriented programming principals. You can choose to mix C++ code with C-style code (which is a structured language) and also raw assembly routines, thus making it far more flexible than Java, which is entirely object-oriented.
Although there's little you can't do in C++, that doesn't make it the best language in every situation. For instance, if you have a deadline to meet, C++ might be too complex a language to meet that deadline, thus forcing you to use a more abstract language designed specifically for rapid application development (RAD). For instance, it's often useful to model algorithms and design concepts using a RAD before committing yourself to a more lengthy software development in C++. The feedback from the RAD can, in fact, reduce the overall development cycle as the models can often be incorporated into the final design with only minimal or trivial modification.
However, C++ comes into its own when high-performance is the main criteria, and raw Assembly Language would be far too costly to implement in a reasonable time-frame. Modern compilers can optimise the machine code in much the same way an Assembly Language programmer exploits hardware features to produce highly-efficient code, but there's often room for further improvement. However, C++ is flexible enough to allow the programmer to make these adjustments by hand. And, for me, that's where things can get really interesting.
top pointer of a stack is the pointer that refers to the top most element of the stack.
It doesn't matter what is the speed is on the USB it depends on the computer's speed on its hardrive, internet, or both the speed is not based on the 2.0 USB, is the computer either its old or new or in between.
What is a PID and how is it useful when troubleshooting a system?
PID stands for Process Identifier, a uniquely assigned integer that identifies a process in the operating system. In any system, applications use PID to identify the process uniquely. Also, it is used in diagnosing the problems with the process in Multi-Tasking systems.
What is the disadvantage of change high level language to machine language?
The biggest disadvantage of machine level language is that it is extremely hard for humans to work with. Everything is in binary code, which is nothing more than a series of ones and zeroes. Programming anything in machine level language takes a very long time.
malloc allocate a memory section whereas memset manipulate the content of the memory section, (for example fill a memory section pointed by pointer ptr with 0, we use memset(ptr,0,sizeof(ptr_data_type)) A memory section must be allocated(using either 'malloc' or 'new' in C++) before memset can be used on it.