What is a macro and its advantages?
Macros are preprocessor statements which will have specific set of instructions which are repeated in source code for several times and which wil be replaced at every call made.
1. Reduce source code length
2. Prog more readable.
3. Any modification to instructions in macro reflects in every call
4. No performance drawback by macros
1. Every call will be replaced and hence internally code length will be large.
Are the expressions 'arr' and ' and arr' are same for an array of integers?
No arr refers to address of array &arr refers address of address of array but compiler treats arr and & arr, so even you place arr and & arr no error only warnings will be displayed.
Can a Volatile variable be static also?
Probably; I don't see anything in the standard that says you can't. However, the use of the volatile keyword is usually in embedded code, or multi-threading in which you don't want the compiler to do optimizations on the variable itself.
Yes, sure.
Memory is used more evenly because the search for a free partition does not always start at the beginning of the list (forcing higher use of these partitions and lower use of the partitions at the end of the list).
An array is a collection of similar data types. An integer array is nothing but a collection of integer data types.
Ex: int a[100], int arr[100][100]
There are several types. 1D array, 2D array, Multi-Dimensional array.
But array is a contiguous allocation. And array size will always be positive. It can be given in the declaration stage or we can specify it dynamically by using malloc function.
Ex: int *a;
a=(int*)malloc(sizeof(int)*HOW_MANY_NUMBERS_YOU_WANT);
How you can access data member inside the main program in c plus plus programming language?
Public, protected and private accessors only apply to code outside of the class. Instances of a class (objects) have complete and unrestricted access to all their own instance variables (data members). They also have unrestricted access to the instance members of all other instances of the same class whenever those instances are passed as arguments to a class member method. Static methods of the class have the same privilege, as do friends of the class.
So the question isn't why an object can access its own public members without using an operator or member function. Any code outside of the class has that exact same right, but if an object has unrestricted access to its protected and private members, why should its public members be treated any differently?
C is a programming language.
Compiler is used to convert our source code which is in high-level language or human understandable code into machine language. Compiled source code can be executed any where once if it is compiled .
Is Microsoft Word an input device?
"An Input device is any piece of computer hardware equipment used to provide data and control signals to an information processing system (such as a computer). Input and output devices make up the hardware interface between a computer and the user or external world " - Wikipedia Egs. Keyboard , mouse etc. Whereas, MSWord is part of the Microsoft office which is an application s/w introduced by Microsoft in 1989. So, obviously it's not a DEVICE!
No such thing as 'if-loop', you can choose from:
while (expression) statement
for (expression; expression; expression) statement
do statement while (expression)
Meaning c plus plus pointer to an array and pointer to a structure?
They both mean the same thing; an array is a type of data structure (a linear structure). A pointer variable is just a variable like any other, but one that is used to specifically store a memory address. That memory address may contain a primitive data type, an array or other data structure, an object or a function. The type of the pointer determines how the data being pointed at is to be treated. Pointers must always be initialised before they are accessed, and those that are not specifically pointing at any reference should always be zeroed or nullified with the NULL value. This ensures that any non-NULL pointer is pointing at something valid. Remember that pointer variables are no different to any other variable insofar as they occupy memory of their own, and can therefore point to other pointer variables.
How can create a exe file in c?
An 'exe' extension file is created by a compiler that translates source code to machine code, usually in a Windows environment.
An executable program can open any file (including other executable files) by using the standard file API calls with a binary open option.
Unless you are doing something very specific with executable files it doesn't make much sense to read in an executable file from another executable file or program.
Write a program to count the number of characters words and lines in given text c plus plus?
#include<iostream>
#include<fstream>
int main()
{
std::ifstream infile ("example.txt", std::ios::in);
unsigned chars(0);
unsigned words(0);
unsigned lines(0);
std::string delim("\t\n ");
char ch(0);
char last(0);
if (!infile.good())
{
std::cerr << "The filename is invalid." << std::endl;
return -1;
}
while (infile.get(ch))
{
switch (ch)
{
case ('\n'):
++lines;
case (' '):
case ('\t'):
// only count words if the last char was not a word delimiter
if (delim.find(last) == std::string::npos)
++words;
default:
++chars;
}
last = ch;
}
infile.close();
std::cout << "Number of chars:\t" << chars << std::endl;
std::cout << "Number of words:\t" << words << std::endl;
std::cout << "Number of lines:\t" << lines<< std::endl;
}
It is a table containing : various combinations of inputs and output desired for that particular combinations. It is similar to truth table.
These lookup tables abbr. as LUT. are used in programming CPLDs or FPGAs.
What does the developmental of hook and loop tape illustrate?
the role of the microscope world in creating new materials
How linked list can be used for the polynomial manipulation?
Header linked list are frequently used for maintaining polynomials in memory. The header node plays an important part in this representation, since it is needed to represent the zero polynomial. This representation of polynomial will be presented in the context of a specific
Is it true global variable may have several declaration but only one definition?
Yes, indeed it is.
In all the declarations, you need to use the keyword "extern".
Rgds,
Karthick S.
What is meant by the complexity of an algorithm?
Complexity of an algorithm is the study of how long a program will take to run, depending on the size of its input & long of loops made inside the code
Specifically, the complexity of an algorithm is a measure of how long it takes to complete (give an answer) relative to increasing sizes of input data. Thus, complexity is not concerned with how long it took the algorithm to run using X amount of data. Rather, it is concerned with the relationship in runtime when using X amount of data, 2X amounts of data, 10X amounts of data, etc. While complexity usually refers to execution time, it can also be applied to other resource usage (for example, memory allocation). In all cases, complexity is concerned with the relationship between the rate of increase in resource consumption and the rate of increase of the size of the data set being worked on.
Complexity is closely related to the concepts of scalingand efficiency, but is NOT an exact equivalence to either.
Why it is necessary to avoid infinite loop in program design?
It is not necessary to avoid infinite loops. You are perhaps confusing infinite loops with endless loops which are to be avoided at all costs. An endless loop is an infinite loop that has no reachable exit condition; the loop will iterate until we forcibly terminate the program.
We use the the term infinite loop in the sense that it is impossible to measure or calculate when the exit point will be hit. the following are all examples of infinite loops in their simplest form:
for (;;) {
// ...
}
while (true) { // ... }
do while (true) {
// ...
}
endless:
// ...
goto endless;
The conditional expressions in each of these loops can never be false thus we cannot easily determine when these loops will exit. We typically use infinite loops when there are many exit conditions to consider and it is either impractical or inefficient to evaluate all of those conditions via the controlling expression alone. We take it as read the exit conditions are contained within the body of the loop.
If the body of the loop has no reachable exit condition then it becomes an endless loop. It is the programmer's responsibility to ensure that all infinite loops can exit at some point.
You can have #include
Sadly, built-in functions and library functions are different things... there are no built-in functions in C (except for sizeof, which isn't an actual function).
There Are Two main types of data. Qualitative data are expressed As numbers, obtained by counting or measuring. Another type of data is called an inference.An inference is a logical interpretation based on prior knowledge or experience.
1) first you have to find the reverse of an integer..
code is given below,
#include<stdio.h>
void main()
{
int a,b,m,s=0;
printf("enter the value of a");
scanf("%d",&a);
b=a;
while(a!= 0)
{
m=a%10;
s=s*10+m;
a=a/10;
}
if(s == b)
{
printf("original number is equal to the reversed number");
}
else
{
printf("original number is not equal to the reversed number");
What are the different aspects of the cost of programming languages?
The cost of programming languages can vary based on several aspects, including:
Licensing fees: Some programming languages require payment of licensing fees, while others are open source and can be used for free.
Development time: The time it takes to develop software using a particular programming language can affect its cost. Programming languages with a shorter development time can be less expensive than those that require more time and effort to develop.
Maintenance costs: The cost of maintaining and updating software written in a particular programming language can also affect its overall cost. Some programming languages are easier to maintain than others, which can save money in the long run.
Availability of skilled developers: The cost of programming languages can also be affected by the availability of skilled developers who are proficient in a particular language. Languages with a smaller pool of skilled developers may be more expensive to use.
Performance and scalability: The performance and scalability of a programming language can affect the cost of software development. Languages that are faster and more scalable can result in more efficient and cost-effective software.
Compatibility with existing systems: If a programming language is not compatible with existing systems, it can be expensive to integrate and may require significant changes to the existing infrastructure.
Security: The security of a programming language can also affect its cost. Languages that are more secure may be more expensive to develop with, but can help prevent costly security breaches in the long run.
What is Basic structure of low level language?
Most people only consider the assembly languages (and plain bytecode) to be "low level" languages. Due to this, the "structure" of a low level language is simply a sequence of instructions for the CPU.
The actual code depends on whether the list is singly-linked or doubly-linked, however the algorithm is largely the same for both. Of course if the list is doubly-linked there is no need to reverse the list at all since the list can simply be traversed in reverse. However, for the sake of completeness, example code is provided for both.
Set the current node to be the head node then repeatedly extract the current node's next node and insert it at the head of the list until the current node's next node is NULL.
Assuming the list is a reference that has a head node pointer, and each node in the list has a next node pointer, a singly-linked list can be reversed as follows:
// Ensure there is a head node.
if(Node* current = list.head)
{
// Ensure the current node has a next node.
while(Node* temp= current->next )
{
// Move the next node to the head of the list.
current->next = temp->next;
temp->next = list.head;
list.head = temp;
}
}
In doubly-linked lists, it is assumed each node has a previous node pointer as well as a next node pointer. The algorithm is essentially the same but the node pointers obviously need to be adjusted in both directions, as follows:
// Ensure there is a head node.
if( Node* current = list.head )
{
// Ensure the current node has a next node.
while(Node* temp= current->next )
{
// Move the next node to the head of the list.
current->next = temp->next;
temp->next.prev = current;
temp->next = list.head;
list.head->prev = temp;
list.head = temp;
temp->prev = NULL;
}
// If the list also has a tail node, remember to reset it!
list.tail = current;
}
In both cases, when the while() loop finishes, the current node ends up pointing at the tail node. However, the current node never actually changes -- it always points to the same node, the original head node. As each loop progresses, the current node is demoted towards the tail, one position at a time, to eventually become the tail node. When the current node has no next node, the loop terminates and the list is completely reversed.
Repeating the reversal will naturally restore the list to its original order.
The exact same algorithm can also be applied to circular lists. The only major difference is that you terminate the loop when temp points to the head of the list, rather than when it is NULL.
Should I learn C or C plus plus first if I want to learn C?
Very! C++ isn't the best language out there, it certainly has its issues, but it's very powerful. It's also fairly low-level, as far as modern languages are concerned. Python has all the power with few of the costs. If you already know how to program, you should be able to pick it up in less than two hours. Most the concepts you learned in C++ (inheritance, polymorphism, etc) still apply, too. Python has the advantage of plenty of super easy-to-use libraries for many thing (such as downloading a web page). It can't hurt to try, so give Python a spin and see if it benefits you.
see related link below