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

What is the limitation of linear queue and how do you overcome using circular queue?

in linear queue when any element is pop out than we do size-1 value changing ie

like in the pile of coin when we take out the last coin then all changes there places so likewise we have to change the position of each element.....

we can overcome by circular one as we have to change the value of the first and last not the values changes in the array....

but circular queue also had limitation that

either u have to use it as size-1 queue or

it will show you full even though it is empty fully....as first==last...

What are the application of singly linked list?

A singly-linked list is ideally suited to stacks (last in, first out). The list maintains a link with the head node in the list and each node points to the next node in the list (the last node points to NULL). When a new node is added it is added to the head of the list. Since enqueue and dequeue both occur at the head of the list, processing is always in constant time [O(1)].

With slight modification (maintaining a pointer to the tail node as well as the head), singly-linked lists can also be used for queues (first in first out). Processing remains constant time [O(1)].

However, random access and search are both linear [O(n/2) and O(n) respectively]. While the list can be modified to maintain a sorted list, insert and seek times still average [O(n/2)].

What is stack packing?

Stack packing is a method used in computer science and programming to efficiently manage memory allocation for data structures, particularly in the context of function calls and local variables. It involves organizing data in a contiguous block of memory, allowing for quick access and minimizing fragmentation. This technique optimizes the use of the stack memory, ensuring that space is utilized effectively during runtime. Stack packing is particularly useful in environments with limited memory resources or when performance is critical.

When argument are passed by value the function works with the original arguments in the calling program?

When a function is passed by value the calling function makes a copy of the passed argument and works on that copy. And that's the reason that any changes made in the argument value does gets reflected to the caller.

Definition and comments for loop?

The C and C++ for loop is defined as...

for (init-expression; test-expression; loop-expression) loop-statement;

  • The init-expression is executed once.
  • At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.
  • The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.
  • At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.
  • Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.
  • Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.
  • If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.
  • At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.

What is adapter in programming language?

An adapter is a class that subclasses a commonly used class or interface with reasonable default functions provided. For example, the WindowAdapter provides a quick solution that provides default do-nothing functions for 4 common interfaces that a GUI would use. Typically, a developer only needs one or two functions from WindowEvent, for example, but without an adapter, they are required to implement seven functions (with five or six of them "do-nothing" functions), instead of just using an adapter and providing the one or two function bodies they do need.

What is bit loading or binary digits loading?

Bit loading is a technique used in multicarrier communication system (eg. OFDM) to assign bits efficiently based subchannel quality, whcih means, it allows more bit to be transmitted within higher quality subchannels and less bits within lower quality subchannnels.

Difference between normal dll and com dll?

A dynamic-link library (DLL) is an executable file that acts as a shared library of functions. Dynamic linking provides a way for a process to call a function that is not part of its executable code. The executable code for the function is located in a DLL, which contains one orA dynamic-link library (DLL) is an executable file that acts as a shared library of functions. Dynamic linking provides a way for a process to call a function that is not part of its executable code. The executable code for the function is located in a DLL, which contains one or more functions that are compiled, linked, and stored separately from the processes that use them. DLLs also facilitate the sharing of data and resources. Multiple applications can simultaneously access the contents of a single copy of a DLL in memory

The Component Object Model (COM) is a component software architecture that allows applications and systems to be built from components supplied by different software vendors. COM is the underlying architecture that forms the foundation for higher-level software services, like those provided by OLE. OLE services span various aspects of component software, including compound documents, custom controls, inter-application scripting, data transfer, and other software interactions. more functions that are compiled, linked, and stored separately from the processes that use them. DLLs also facilitate the sharing of data and resources. Multiple applications can simultaneously access the contents of a single copy of a DLL in memory

Program using putstr function in pointer in c?

#include <stdio.h>

int main (int argc, char **argv)

{

puts (argv[0]);

return 0;

}

C plus plus program using function median that take three parameters of type double and returns the median of the three?

There are several ways to implement this, however the basic principal is to sort the doubles in ascending order and return the middle element (in this case the 2nd element). The simplest implementation uses a 3-element array which is then sorted using an insertion sort, as shown in the following example.

#include<iostream>

#include<list>

double median(double& x, double& y, double& z)

{

// initialise the array

double a[3] = { x, y, z };

// sort the array

for(int i=1; i<3; ++i)

{

int hole=i;

int prev=hole-1;

double cur=a[hole];

while(hole && cur<a[prev])

{

a[hole]=a[prev];

--hole, --prev;

}

a[hole]=cur;

}

// return the middle element.

return( a[1] );

}

int main()

{

using namespace std;

double a, b, c;

a = 0.9;

b = 0.1;

c = 0.5;

cout<<"a="<<a<<endl;

cout<<"b="<<b<<endl;

cout<<"c="<<c<<endl;

cout<<"median="<<median(a,b,c)<<endl;

return(0);

}

Output:

a=0.9

b=0.1

c=0.5

median=0.5

It should be noted that when dealing with an even number of elements (such as 4 or 6), then there is no middle element, so you therefore need take the mean of the two middle elements instead. So if the sorted numbers are 0.1, 0.2, 0.5 and 0.9, then the median is the mean of 0.2 and 0.5, which is 0.35 (e.g., ( 0.2 + 0.5 ) / 2).

Which program do you need gor golive2 stix?

To go live with STIX (Structured Threat Information Expression), you typically need a platform or software that supports STIX, such as MISP (Malware Information Sharing Platform) or OpenDXL. Additionally, you may need a proper understanding of threat intelligence frameworks and possibly integration with other cybersecurity tools that utilize STIX for data sharing and analysis. Make sure to verify compatibility with your existing systems for effective implementation.

What is sequential programming?

In the early days of computing, programs were serial, that is, a program consisted of a sequence of instructions, where each instruction executed one after the other. It ran from start to finish on a single processor.

reference: http://code.google.com/edu/parallel/mapreduce-tutorial.html

What program can be written to count the number of alphanumerics in a string?

public int getStringLength(String val) {

return val.length();

}

There is an inbuilt functionality in strings that counts the number of alphabets in a string called length()

List of graphics commands in C?

1. There are no commands in C.
2. Graphics can be used by system-dependent libraries so you have to specify the platform you are using (MS DOS, MS Windows, X Window, etc).

What is the advantage of switch over multiple IF Statement?

In my own personal opinion the switch statement is easier to understand and to add newer cases to without disturbing the logic.

In some compilers the switch statement may generate better machine code because the switch is actually wired into the hardware.