Found 1339 Articles for C

C vs BASH Fork bomb in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:25:12

442 Views

It is already cleared that the BASH fork bomb is much more powerful than its version of C program. The main cause is that in BASH the created process is detached from the parent. If the parent process (the one we initially started) is destroyed or killed, the remaining or rest of the processes live on. But in case of the C implementation, the listed child processes die automatically if the parent is destroyed or killed. A script is responsible to communicate with the system directly.The fork bomb program in C can be updated or modified. We can be able ... Read More

AA Trees in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:18:07

1K+ Views

An AA tree in computer science is defined as a form of balanced tree implemented for storing and retrieving ordered data efficiently. AA trees are treated as a variation of the red-black tree, a form of binary search tree which supports efficient addition and deletion of entries. As opposed to red-black trees, red nodes on an AA tree can only be added as a right subchild, no left subchild. The result of this operation is the simulation of a 2-3 tree instead of a 2-3-4 tree, which causes simplification the maintenance operations. The maintenance algorithms for a red-black tree require ... Read More

A-Buffer Method in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:07:58

2K+ Views

A-Buffer technique in computer graphics is a simple hidden face detection mechanism used to medium scale virtual memory computers. This technique is also known as anti-aliased or area-averaged or accumulation buffer. This technique extends the algorithm of depth-buffer (or Z Buffer) technique. As the depth buffer technique can only be implemented for opaque object but not for transparent object, the A-buffer technique provides advantage in this scenario. Though the A buffer technique requires more memory, but different surface colors can be correctly composed implementing it. Being a descendent of the Z-buffer algorithm, each position in the buffer can locate or ... Read More

A Number Link Game in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:04:03

261 Views

The Game − Suppose an n × n array of squares. Out of these, some of the squares are empty, some are solid, and some non-solid squares are set by integers 1, 2, 3, … .Each integer maintains or occupies exactly two different squares on the board. The task of the player is to connect the two occurrences of each integer on the board with the help of a simple path implementing horizontal and vertical movements alone. No two different paths are permitted to intersect one another. No path may include any solid square (solid squares are not permitted to ... Read More

0/1 Knapsack using Branch and Bound in C/C++?

Ravi Ranjan
Updated on 05-May-2025 12:29:17

3K+ Views

In the 0-1 knapsack problem, a set of items is given, each with a weight and a value. We need to determine the number of each item to include in a collection so that the total weight is less than or equal to the given limit and the total value is as large as possible. What is Branch and Bound Algorithm?The branch and bound algorithm breaks the given problem into multiple sub-problems and then uses a bounding function. It eliminates only those solutions that cannot provide optimal solutions. In this article, we will discuss how to solve the 0-1 knapsack problem ... Read More

System() Function in C/C++

Sunidhi Bansal
Updated on 06-Sep-2023 21:57:43

37K+ Views

Given the task is to show the working of system() in C/C++.The system() function is a part of the C/C++ standard library. It is used to pass the commands that can be executed in the command processor or the terminal of the operating system, and finally returns the command after it has been completed. or should be included to call this function.SyntaxThe syntax is as follows −int system(char command)This function returns zero if the command is executed without any errors.ExampleInput: system(“date”) Output: The current date is: Fri 12/27/2019Explanation − The following example shows how we can use the system ... Read More

strstr() function in C/C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:10:22

803 Views

strstr() function is a predefined function in “string.h” header file which is used for performing string handling. This function is used to find the first occurrence of a substring let’s say str2 in the main string let’s say str1.SyntaxSyntax of strstr() is as follows −char *strstr( char *str1, char *str2);Parameters of strstr() arestr2 is the substring which we wish to search in the main string str1Return value of strstr() isThis function returns the address pointer of the first occurrence of the substring which we are searching if found in the main string, else it will return a null when the ... Read More

Difference between float and double in C/C++

Mahesh Parahar
Updated on 24-Feb-2020 08:04:39

2K+ Views

As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them.In simple words it could be state that double has 2x more precision as compare than float which means that double data type has double precision than as compare to that of float data type.In terms of number of precision it can be stated as double has 64 bit precision for floating point ... Read More

Difference between Structure and Array in C

Mahesh Parahar
Updated on 25-Feb-2020 07:13:01

7K+ Views

In C both Structure and Array are used as container for data types i.e in both structure and array we can store data and also can perform different operations over them.On the basis of internal implementation following are some basic differences between both.Sr. No.KeyStructureArray1DefinitionStructure can be defined as a data structure used as container which can hold variables of different types.On other hand Array is a type of data structure used as container which can hold variables of same type and do not support multiple data type variables.2Memory AllocationMemory allocation for input data in structure does not necessary to be ... Read More

Difference between strlen() and sizeof() for string in C Program

Mahesh Parahar
Updated on 25-Feb-2020 06:57:24

320 Views

As we know that in programming string can be defined as the collection of characters. Now for the requirement of finding how many characters are being used to create a string, C provides two approaches which are strlen() and sizeof().As mentioned in above point both of these methods are used to find out the length of target operand but on the basis of their internal implementation following are some basic differences between both.Sr. No.Keystrlen()sizeof()1Definitionstrlen() is a predefined function defined in a Header file named string.h in C.On other hand sizeof() is a Unary operator and not a predefined function.2Implementationstrlen is ... Read More

Advertisements