
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1339 Articles for C

7K+ Views
Here we will see the ASCII NUL, ASCII 0 and the Numeric Literal 0. The ASCII null is represented as 0x00, and zero is represented as 0x30. The ASCII NUL character is used to denote the end of the string in C or C++. When programmer used ‘0’ (character 0) it is treated as 0x30. This is a hexadecimal number. The decimal equivalent is 48. To put ASCII NUL we have to mention ‘\0’ instead of ‘0’.char asciiNul = ‘\0’; int zero = 0; char zeroChar = ‘0’;The first one is ASCII NUL, second one is numeric 0, and the third one is character 0.

295 Views
Here we will see how to generate the biggest number by rearranging the given numbers. Suppose there are {45, 74, 23} is given, the program will find the largest number, that is 744523. So each digit will not be arranged. but the whole number will be placed to make largest number.To solve this problem, we will use the string sorting. But the comparison logic is different. The comparing function will take two numbers a and b, then concatenate them to form ab and ba. Among them which one is bigger, that is considered.AlgorithmcompareStrings(a, b)begin ab := concatenate b with ... Read More

2K+ Views
Here we will see about the argument coercion in C or C++. The Argument Coercion is one technique by which the compiler can implicitly convert the arguments from one type to another type. It follows argument promotion rule. If one argument is lower datatype, that can be converted into higher datatypes, but the reverse is not true. The reason is if one higher datatype is converted into a lower datatype, it may loss some data.Let us see one pyramid that can express how the implicit conversion takes place.Example Live Demo#include using namespace std; double myAdd(double a, double b){ return a+b; ... Read More

144 Views
Here we will see how to get the area of a triangle formed by the x and y axis and another straight line. The diagram will be look like below. The equation of the straight line is −𝑎𝑥+𝑏𝑦+𝑐=0The line is cutting the x-axis at the point B, and cutting the y-axis at the point A. The intercept form will be like below −So the x-intercept is −𝑐∕𝑎 and y-intercept is −𝑐∕𝑏 . So the area of the triangle isExample Live Demo#include #include using namespace std; double areaTriangle(double a, double b, double c){ return fabs((c*c) / (2*a*b)); } main() { ... Read More

842 Views
In this section we will see how to get all permutations of a string. The recursive approach is very simple. It uses the back-tracking procedure. But here we will use the iterative approach.All permutations of a string ABC are like {ABC, ACB, BAC, BCA, CAB, CBA}. Let us see the algorithm to get the better idea.AlgorithmgetAllPerm(str)begin sort the characters of the string while true, do print the string str i := length of str – 1 while str[i - 1] >= str[i], do i := ... Read More

682 Views
Here we will see what are the differences of sizeof and the alignof operator in C++. The alognof() operator is introduced in C++11.The alignof() operator is used to get the alignment in bytes. It requires instances of type. the type is either complete type or a reference type. There is another operator called the sizeof() operator, that returns the size of one type. For normal datatypes the sizeof and the alignof returns the same value. For some user defined datatype, the alignof returns some different value. Let us see the example to get the idea.Example Live Demo#include using namespace std; struct ... Read More

505 Views
Here we will see one problem, where we will add two n digit numbers but the carry will not be propagated. We can understand this concept through an example −So we can see that here only digits are getting added and answer is placed. Here is one trick. We have to scan the numbers from right to left. So the sum of 3+2 = 6 will be calculated first, but it will be placed at the end. So we will use stack to store intermediate results.AlgorithmnoPropagateCarry(a, b)begin size = max of length of a and length of b ... Read More

265 Views
Here we will see how to calculate the remainder of array multiplication after dividing the result by n. The array and the value of n are supplied by the user. Suppose the array is like {12, 35, 69, 74, 165, 54} so the multiplication will be (12 * 35 * 69 * 74 * 165 * 54) = 19107673200. Now if we want to get the remainder after diving this by 47 it will be 14.As we can see this problem is very simple. we can easily multiply the elements then by using modulus operator, it can get the result. ... Read More

665 Views
In this section we will see how we can get the product of unique prime factor of a number in an efficient way. There is a number say n = 1092, we have to get product of unique prime factors of this. The prime factors of 1092 are 2, 2, 3, 7, 13. So the unique prime factors are {2, 3, 7, 13}, the product is 546. To solve this problem, we have to follow this rule −When the number is divisible by 2, then multiply 2 with product, and divide the number by 2 repeatedly, then next 2s will ... Read More

519 Views
Here we will see how the brick sort works. The Brick sort is one modification of bubble sort. This algorithm is divided into two parts. These parts are odd part and even parts. In the odd part we will use the bubble sort on odd indexed items, and in the even part we will use the bubble sort on even indexed elements. Let us see the algorithm to get the idea.AlgorithmbrickSort(arr, n)begin flag := false while the flag is not true, do flag := true for i := 1 to n-2, increase ... Read More