- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 1401 Articles for C
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
437 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
![Sharon Christine](https://www.tutorialspoint.com/assets/profiles/13517/profile/60_82215-1512649681.jpg)
279 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
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
160 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
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
386 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.
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
130 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
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
889 Views
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.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.Here is a simple example of void pointer −Example Live Demo#include int main() { int a = 7; float b = 7.6; void *p; p = &a; printf("Integer variable is = %d", *( (int*) p) ); p = &b; printf("Float variable ... Read More
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
414 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
![Nishtha Thakur](https://www.tutorialspoint.com/assets/profiles/13598/profile/60_104893-1512719058.jpg)
7K+ Views
We can compare pointers if they are pointing to the same array. Relational pointers can be used to compare two pointers. Pointers can’t be multiplied or divided.In CExample Live Demo#include int main() { int *p2; int *p1; p2 = (int *)300; p1 = (int *)200; if(p1 > p2) { printf("P1 is greater than p2"); } else { printf("P2 is greater than p1"); } return(0); }OutputP2 is greater than p1In C++Example#include using namespace std; int main() { int *p2; int *p1; p2 = (int *)300; p1 = (int *)200; if(p1>p2) { cout
![Anvi Jain](https://www.tutorialspoint.com/assets/profiles/13591/profile/60_98631-1512716973.jpg)
4K+ Views
Function Pointers point to code like normal pointers.In Functions Pointers, function’s name can be used to get function’s address.A function can also be passed as an arguments and can be returned from a function.Declarationfunction_return_type(*Pointer_name)(function argument list)Example Live Demo#include int subtraction (int a, int b) { return a-b; } int main() { int (*fp) (int, int)=subtraction; //Calling function using function pointer int result = fp(5, 4); printf(" Using function pointer we get the result: %d",result); return 0; }OutputUsing function pointer we get the result: 1
![Smita Kapse](https://www.tutorialspoint.com/assets/profiles/13597/profile/60_103706-1512718957.jpg)
1K+ Views
To access array elementsWe can access array elements by using pointers.In CExample Live Demo#include int main() { int a[] = { 60, 70, 20, 40 }; printf("%d", *(a + 1)); return 0; }Output70In C++Example Live Demo#include using namespace std; int main() { int a[] = { 60, 70, 20, 40 }; cout