
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

233 Views
A circumcircle is a circle that inscribes a regular polygon inside it. The triangle that is inscribed inside a circle is an equilateral triangle. Area of circumcircle of can be found using the following formula, Area of circumcircle = “(a * a * (丌 / 3))”Code Logic, The area of circumcircle of an equilateral triangle is found using the mathematical formula (a*a*(丌/3)). The value of 丌 in this code is coded as 3.14. The expression is evaluated into a float value.Example Live Demo#include #include int main(){ int a = 5; float area; float pie = 3.14; ... Read More

693 Views
A circle inscribed in a square is a circle which touches the sides of the circle at its ends. I.e. the diameter of the inscribed circle is equal to the side of the square. The area can be calculated using the formula “((丌/4)*a*a)” where ‘a’ is the length of side of square.Logic of the Code - The area of circle inscribed inside the circle is calculated using the formula ((丌/4)*a*a) for this we need to define the value of pie (丌) that mathematically is 22/7 or 3.14. The expression that evaluates to the result is saved in a float variable.Example Live ... Read More

358 Views
A tetrahedron is a pyramid with triangular base i.e. it has a base that is a triangle and each side has a triangle. All the three triangles converge to a point. As in the figure, Code Logic − The code to find the area and volume of tetrahedron uses the math library to find the square and square-root of a number using sqrt and pow methods. For calculating the area we take a floating point and the value of the expression “((sqrt(3)*a*a))” is given to it. Another variable get the value of volume of the tetrahedron that is evaluated by ... Read More

584 Views
Trapezium is a type of quadrilateral that has at least one pair of side parallel to each other. Area and perimeter of a trapezium can be found using the below formula, Perimeter = sum of all sidesArea = ½ x (sum of the lengths of the parallel sides) x perpendicular distance between parallel sidesCode logic − The code will use 5 variables in as all sides of trapezium and one for the perpendicular distance between the two parallel side. For the area variable calculation we will take a float variable that will be initialised with the value. To calculate it ... Read More

488 Views
Tringle is a closed figure with three sides. An equilateral triangle has all sides equal. Area and perimeter of an equilateral triangle can be found using the below formula, Area of equilateral triangle = (√3)/4*a2Perimeter of equilateral triangle = 3 * aLogic of CodeTo find the area of an equilateral triangle program uses square-root and power functions. The math library has both these functions and can be used to do the calculation in the program.The below code display program to calculate the area and perimeter of an equilateral triangle, Example Live Demo#include #include int main(){ int side = ... Read More

276 Views
Rhombus is a simple quadrilateral whose four sides all have the same length. And perimeter of rhombus can be found by two methods.Adding all side.Using the diagonalsA quadrilateral has two diagonal and based on the length of diagonals the area and perimeter of the quadrilateral can be found.To find the perimeter of a rhombus using its diagonals is 2{√(d1)2 + (d2)2 }LOGIC − To find the perimeter of a rhombus using its diagonals. You need the formula 2{√(d1)2 + (d2)2 } for this in your code you need to use the math class that supports the use of squareRoot and ... Read More

518 Views
It is basically pointless to check for a NULL pointer before deleting. Deleting a pointer will do nothing if the pointer set to NULL. It might be the reason to check for the NULL pointer that deleting a pointer which is already set to NULL may indicate bugs in the program.

216 Views
In C++, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0, like −int*p = 0;But in c, a null pointer can be defined by as a null pointer constant is an integer constant expression with the value 0 or such an expression cast to void*, like −Int *p = 0;;Orint*p = (void*) 0;In C++11 a keyword “nullptr” is used to represent nullpointer.int* ptr = nullptr;In CExample Live Demo#include int main() { int *p= NULL; //initialize the pointer as null. printf("The value of pointer is %u", p); ... Read More

1K+ Views
The void pointer is a pointer which is not associate with any data types. It points to some data location in storage means points to the address of variables. It is also called general purpose pointer. Is It Safe to Delete a Void Pointer in C/C++? It is not safe to delete a void pointer in C/C++ because delete needs to call the destructor of whatever object it's destroying, and it is impossible to do that if it doesn't know the type. C Example of Void Pointer In this example, a void pointer (void *p) can store the address of ... Read More

492 Views
A pointer is used to store the address of the variables. To declare pointer variables in C/C++, an asterisk (*) used before its name.Declaration*pointer_nameIn CExample Live Demo#include int main() { // A normal integer variable int a = 7; // A pointer variable that holds address of a. int *p = &a; // Value stored is value of variable "a" printf("Value of Variable : %d", *p); //it will print the address of the variable "a" printf("Address of Variable : %p", p); // reassign the value. *p = 6; printf("Value ... Read More