answersLogoWhite

0

📱

C Programming

Questions related to the C Computer Programming Language. This ranges all the way from K&R to the most recent ANSI incarnations. C has become one of the most popular languages today, and has been used to write all sorts of things for nearly all of the modern operating systems and applications. It it a good compromise between speed, power, and complexity.

9,649 Questions

How do accountants use variables?

They use them to solve an equation they don't know.Accountants use variables to give a visualization to their customers as to how they are doing the accounting

What is a hip pointer?

A hip pointer is a deep bruise on the side of your hip. It feels like a big charlie horse, or like a football players helmet ramming into the side of your hip. It takes time and alot of rest for it to heal correctly. Also it is important to keep an icing it for 2-3 days, every 20 minutes, with 10-15 minute break. If it hurts more than 2 weeks, than you should probably get an x-ray.

Write a c plus plus function to reverse the contents of a stack using two additional stacks?

The following function template will reverse any stack of type T:

template<typename T>

void reverse_stack (sd::stack<T>& A) // Pass by reference!

{

std::stack<T> B, C; // Two additional stacks (initially empty).

while (!A.empty()) { B.push (A.top()); A.pop(); }

while (!B.empty()) { C.push (B.top()); B.pop(); }

while (!C.empty()) { A.push (C.top()); C.pop(); }

// A is now in reverse order.

}

A more efficient method is to pop the stack onto a queue.

template<typename T>

void reverse_stack_optimised (sd::stack<T>& A) // pass by reference!

{

std::queue<T> B;

while (!A.empty()) { B.push_back (A.top()); A.pop(); }

while (!B.empty()) { A.push (B.front()); B.pop(); }

// A is now in reverse order.

}

What is a junket operator?

A junket operator has a similar role to a VIP type host in a casino setting.

Is c plus plus and java are the same?

No. Java takes some ideas from C++, so there are certain similarities, especially in the basic syntax. But it is a different language.

What is regular grammar of a switch in C programming language?

Perhaps you meant 'switch statement' instead of 'a switch'?

Something like this:

->

-> switch ()

-> { }

-> (empty) |

-> [];

-> |

-> case: | default:

-> | break;

What are the three steps of the RCIA program?

there are actually four steps and they are: evangilization, catechumenate, purification and enlightenment and mystagogy.

How to write your own function for standard library functions strcat strcpy strcmp?

Run through the char array

Though i cannot think of a reason do to it (why not use the available methods in the string.h ?) , it is possible to do it manually.
Loop through your character arrays and compare / copy.
Suppose you are char orig[100];
strcmp:
for (int i=0; orig[i] != 0; i++)
if (orig[i] != other[i]) return false;
return true; // because reached the end of the string.

and copy will be similar:
first get the length:
int length = 0;
for (int i=0; orig[i] !=0; i++, length++);
char *other = new char[length];
for (int i=0; i < length; i++)
other[i] = orig[i]; // will also copy the \0


AnswerWriting your own string functions is useful mainly for the challenge or practice. The versions that come with your compiler are most likely well optimized for your system, so you should not consider writing your own for performance reasons. That said, strcmp for one is simple enough to write:

int strcmp(const char *a, const char *b)
{
do
if (*a != *b) return *a - *b;
while (a++, *b++);

return 0;

}

strcpy is even simpler:

char *strcpy(char *dest, const char *src)
{
char *s = dest;
while (*dest++=*src++)
;

return s;

}

strcat is similar to strcpy, but it first finds the end of the dest string before copying the src string to it. I'll leave that as an exercise to the reader.

What is the return value when new operator is not able to allocate memory in c?

There is no operator new in C.

In C++11, there are three versions of operator new, all of which can be overridden. Default behaviour is as follows:

(1) throwing allocation

void* operator new (std::size_t size);

If an allocation of the given size cannot be met, an exception will be thrown. There is no return value after an exception is thrown.

(2) nothrow allocation

void* operator new (std::size_t size, const std::nothrow_t& nothrow_value) noexcept;

If an allocation of the given size cannot be met, nullptr is returned.

(3) placement

void* operator new (std::size_t size, void* ptr) noexcept;

Always returns ptr. You use this version when memory has already been allocated and you are merely providing placement for an object within that allocation.

What is multidimensional array in c plus plus?

A multidimensional array in C or C++ is simply an array of arrays, or an array of an array of arrays, etc. for however many dimensions you want.

int a; // not an array

int a[10]; // ten int a's

int a[10][20]; // twenty int a[10]'s, or 200 int a's

int a[10][20][30]; // and so on and so forth...

What is the algorithmic unsolvability?

There are many problems for which it can be proven that they are, at least in the general case, unsolvable - in other words, no algorithm can ever be found to solve them. As an example, one of the first problems for which this unsolvability has been proven is the Halting Problem - determining whether an arbitrary computer program will ever stop, or run forever. Alan Turing showed that solving the halting problem is not possible, in the general case. Note that for some specific computer programs, it might be possible to show that they stop, or that they will continue running forever - but such an algorithm is not possible for ALL computer programs.

What is the difference between c and c plus plus extension?

c language is the structure oriented language and c does not follows the object oriented paradigms . c++ obeys the all object oriented language characteristics

==========

C++ is a set of extensions to the C language to allow some (not all) principles of object-oriented programming to be used. Originally, C++ was a front end pre-processor for C and C++ compilers will translate C language functions.

How use find command in c language?

C language doesn't have commands only instructions. Sadly, 'find' is not an instruction in C, you might have misunderstood something.

What does primitive method mean in programming?

All the objects in Alice that have a set of common set of built-in methods for performing basic options.

What is root drive?

A root drive is when a SATNAV tells you to go to the main root , and what that means is when you found your main root you have gone straight to the root drive. And that what's root drive means.

What are the different types of bathtub drains?

copper

Cast Iron

PVC

ABS

Galvanized wrought

Galvanized Steel

What are the advantages of RAD modelling language?

Advantages of UML:

  • it provides most of diagram types (14 diagrams in UML 2.2) needed for object-oriented analysis and design (OOAD)
  • it is standardized (by OMG Group), not proprietary, supported by software industry
  • is explained and described in every aspect by vast amount of publications, resources, textbooks, etc.
  • it could be customized and extended for specific application domain, software process, or implementation platform.

Can you increment the value of a variable by 2 using any increment operator?

There is no such increment operator in C language to increment the value of a variable by 2.An increment operator only increments the value by 1.

however you can apply the increment operator twice to get an increment of

3. No: you cannot: ++(++a) won't compile.

Yes. Example: a += 2; but += is not an increment operator, it's a shorthand of a=a+2; just like a++ is a shorthand for a= a+1

What is soft swap?

To share spouse with another through pics/video or oral sex only.

Advantages and disadvantages of arrays in java?

Arrays permit efficient (constant time) random access but not efficient insertion and deletion of elements. Consequently, arrays are most appropriate for storing a fixed amount of data which will be accessed in an unpredictable fashion.

Another advantage of arrays that has become very important on modern architectures is that iterating through an array has good locality of reference, and so is much faster than iterating through (say) a linked list of the same size, which tends to jump around in memory. However, an array can also be accessed in a random way, as is done with large hash tables, and in this case this is not a benefit.

Arrays also are among the most compact data structures; storing 100 integers in an array takes only 100 times the space required to store an integer, plus perhaps a few bytes of overhead for the whole array. Any pointer-based data structure, on the other hand, must keep its pointers somewhere, and these occupy additional space. This extra space becomes more significant as the data elements become smaller. For example, an array of ASCII characters takes up one byte per character, while on a 32-bit platform, which has 4-byte pointers, a linked list requires at least five bytes per character. Conversely, for very large elements, the space difference becomes a negligible fraction of the total space.

Because arrays have a fixed size, there are some indexes which refer to invalid elements - for example, the index 17 in an array of size 5. What happens when a program attempts to refer to these varies from language to language and platform to platform.