Static variable in c plus plus?
There are two uses for a static variable in C++. When declared outside of a class, a variable is regarded as being global. However a static variable is deemed local to the file in which it is declared. That is, the variable is scoped to the file, and cannot be accessed by code outside of that file. This aspect was inherited from C.
C++ also allows static variables to be declared inside a class. In this case, the variable is local to the class. By contrast, instance variables (non-static member variables) are local to each instance of the class. With static variables, there is only one instance of each variable which can be shared by all instances of the class. It is not unlike a global but it is scoped to the class.
Since all static variables are instantiated at compile time, they exist for the entire duration a program runs. Even if they fall from scope, they never lose their value. Static variables defined within a class are also available even when no instances of the class are instantiated. Their visibility outside of the class is dependent upon whether they are declared public, protected or private.
Why use static variable in programming language?
For C programming, the use of a static variable has two uses:
One reason is to hide the variable from other modules. The scope of the static variable is limited to the compilation unit that it is described in.
The second use of a static variable is to keep the value of the variable intact through the entire program execution unit.
Start by taking the number in Fahrenheit and subtracting 32. Then divide the number by 9, and then multiply it by 5. This is how you convert Fahrenheit to Celsius or use the equation C = (F - 32) × 5/9
In this case, the answer is about 215.56 degrees Celsius.
Complexity of sequential search?
The simplest and slowest searching method; the only possible method when the data is unsorted and/or only sequential access is possible (eq. processing a tape file).
I think he's looking for time complexity which I believe is just n
Why static variables in a function have global extent?
A variable declared static outside of a function has a scope the of the source file only. It is not a global variable. A variable declared outside of a function and without the static qualifier would be a global variable.
Who is the author of Borland Turbo C?
A company called Borland. (Actually it was based on the former product Wizard C of Bob Jervis.)
Why the built in pointer a useful feature of the microscope?
It gives users a better way to identify and point out certain parts of the slide. The feature also highlights special aspects Êor characteristics found among the selection.
What is difference constructor and function in programming C plus plus?
A Constructor is called when you are making a new instance of a class and member functions are functions that you can call within your class or else call using the instance of that class.
for example
class Foo {
public:
int bar;
Foo(int bar) {this->bar = bar;}
inc_bar(); {this->bar++;}
};
Foo instance(10); // Constructor is called and bar is set to 10
cout << instance.bar << endl;
instance.inc_bar(); // call the member function to increment bar
cout << instance.bar << endl;
What is difference between source programm and an abject module?
Source code is the "source" of a program. This means that this is the code provided by a programmer in a human readable and modifiable form. When a programmer writes a program, he/she will develop source code in a programming language such as C, C++, maybe Pascal among others.
An object module can mean two different things depending on the context. An object module generally is an intermediate step between source code and an executable file like a .EXE on Windows. An executable file is actually what is generated by a compiler (like GCC or Visual C++) from source code and is effectively "machine language". It is not human readable and to a certain extend is not even machine readable as a whole. The way it works is that part of an executable file contains information to tell the operating system how to read the file into memory and where to start running it. The operating system will then tell the CPU where to start reading the program while it is in memory. The executable is a series of instructions understandable by the CPU and it performs them one by one as the program defines. Consider this overall process of compiling as someone writing a recipe for a certain type of food and then another person will compile a list of instructions in way that a resturant kitchen staff can follow it over and over. A different compiler might even translate the recipe to a different spoken language. In a similar fashion, one compiler might translate from C to Intel x86 while another would translate to IBM PowerPC.
An object file often is an intermediate step between source and executable. This file is the result of compiling a single source file as opposed to all the source files of an entire program. Some programs fit in a single source file, but others can be hundreds or even thousands of source files. To compile the Linux kernel in it's full form as a single static executable can require compiling tens of thousands of files. Once each file is mostly translated to machine language and stored as an object file, a program called a linker is used to merge those files together into a single executable. This process might be seems as taking the recipe for and English muffin, another for hollandaise sauce and a final one for Eggs Benedict and merging all the steps together into a single recipe which a kitchen staff can execute in a given order to start with raw ingredients and produce the final product.
What is the difference between preprocessor directives and header files?
Preprocessor: All the preprocessor commands written in a high level language are processed by the preprocessor before compiler takes over.
Example: "#define MAX_ROWS 10"
Preprocessor finds all the places and replaces MAX_ROWS with 10 in the files of the project.
Compiler: This software, converts the code written in high-level language into object file. Compiler converts all the files of a given project at once.
Is c procedural or structural language?
Structural language is a language in which a particular structure is defined. It is used to make execution and understanding easier.
Ex : COBOL
Structural language does not have function calls.
Procedural language is a language in which function calls are allowed.
Ex : C
In this a particular procedure is followed every time.
IMB.
What are the rules of creating identifier?
Identifiers refers to the names of variables, functions and array. These are user defined names and consist of a sequence of letters and digits, with a letters as a first character.Both uppercase and lowercase letters are permitted, although lowercase letters are commonly used. The underscore character is also permitted in identifiers. It is usually used as a link between two words in long identifiers.
In C, identifiers may contain any alphanumeric characters (a-z, A-Z, 0-9) as well as underscores (_), but must not begin with a number.
Why should you indent the statement in the body of a loop?
In some programming languages like Python, the indentation of the text indicates how nested it is and is required for a loop to function properly. However, for most languages, indenting the body of the loop is simply for style and readability.
Is there anything similar between C and C plus plus with reference to data hiding?
No. Data hiding is a feature of object oriented programming. C does not support OOP, and therefore has no private member access. All members are public in C.
What is the importance of data sturture in a programming language?
According to Wikipedia-"In computer science, a data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.Data structures are used in almost every program or software system. Data structures provide a means to manage huge amounts of data efficiently, such as large databases and internet indexing services. Some formal design methods and programming languages emphasize data structures, rather than algorithms, as the key organizing factor in software design."
What are some manifest functions of using the internet?
By helping the world connect through our computers.
What are the properties of binary tree?
What time of loop is used when you know how many times the loop instructions should be processed?
It's best to use a for loop.
For example, if you want 10 iterations:
for (int i = 1; i <= 10; i++)
{
// Any commands you write here will repeat 10 times.
}
Flowchart to find the sum of the square of first 30 even numbers?
The flowchart in deriving the sum of the square root of first N even numbers, You may follow the steps provided below:
# Draw the start symbol then a flow line connecting to item #2 # Draw the init box for the syntax: set variable_A=0, variable_Chk=0, variable_Sum=0, variable_Sqrt, then a flow line connecting to item #3 # Draw the input box and write variable_A then a flow line connecting to item #4 # Draw the decision box for 'Is variable_A not numeric?'. if yes, draw a flow line connecting to item#3 else draw a flow line connecting to item#5 # Draw the process box for the syntax: compute variable_Chk=variable_A / 2 then a flow line connecting to item #6 # Draw the decision box for 'Is variable_chk not whole number?. if yes, draw a flow line connecting to item #3 else draw a flow line connecting to item #7 # Draw the process box for the syntax: compute variable_Sum=variable_Sum + variable_A then a flow line connecting to item #8 # Draw the decision box for 'Do you want to add another number?'. if yes, draw a flow line connecting to item#3 else draw a flow line connecting to item #9 # Draw the process box for the syntax: compute variable_Sqrt=SQRT(variable_Sum) then a flow line connecting to item #10 # Draw the output box and write variable_Sum, variable_Sqrt then a flow line connecting to item #11 # Draw the end symbol.
Where:
variable_A contains a given N number, variable_Chk contains the quotient of variable_A / 2, variable_Sum contains the sum of N numbers and variable_Sqrt contains the result.
How many types of classes in c?
There are no classes in a C program.C is not a object oriented programming language only object oriented programming language has classes c++ is a object oriented programming language.
Class can be defined as a blueprint from which individual objects are created.eg:Car is a Class BMW is an Object of that class.
Join http://www.c-madeeasy.blogspot.com for c programming source codes,tutorials and advanced programming advice.
What is the code for date validation in c plus plus?
You need to check the day, month and year separately, to ensure they are within range. You also need to deal with leap days (29th February) which is every 4 years, but not the 100th unless it is the 400th. Finally, you need to deal with the change from the Julian to Gregorian calendars, which skips the 5th to 14th October, 1582.
bool checkdate(unsigned int d, unsigned int m, unsigned int y)
{
return( !(( d<1 d>31 m<1 m>12 ( y==1582 && m==10 && (d>4 && d<15 )))
( d==31 && ( m==2 m==4 m==6 m==9 m==11 ))
( m==2 && ( d>29 ( d==29 && ( y%4 ( !( y%100 ) && y%400 )))))));
}
What is the difference between Oracle data types char and varchar2?
Character string values storage:
1. CHAR:
§ Stores strings of fixed length.
§ The length parameter s specifies the length of the strings.
§ If the string has smaller length it padded with space at the end
§ It will waste of a lot of disk space.
§ If the string has bigger length it truncated to the scale number of the string.
2. VARCHAR:
§ Stores strings of variable length.
§ The length parameter specifies the maximum length of the strings
§ It stores up to 2000 bytes of characters
§ It will occupy space for NULL values
§ The total length for strings is defined when database was created.
3. VARCHAR(2):
§ Stores strings of variable length.
§ The length parameter specifies the maximum length of the strings
§ It stores up to 4000 bytes of characters
§ It will not occupy space for NULL values
§ The total length of strings is defined when strings are given
Is array made up of number of data items?
Yes, that's the idea of an array.
Yes, that's the idea of an array.
Yes, that's the idea of an array.
Yes, that's the idea of an array.