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
Programming Articles - Page 2174 of 3366
236 Views
In this tutorial, we will be discussing a program to convert a binary tree to a doubly linked list.For this we will be provided with a binary tree. Our task is to convert it into a doubly linked list such that the left and right pointers become the previous and next pointers. Also the sequential order of the doubly linked list must be equal to the inorder traversal of the binary tree.For this we are having a very straight forward approach. We will be traversing the binary tree in in order way making the nodes of the doubly linked list ... Read More
164 Views
In this tutorial, we will be discussing a program to convert a given Binary tree to a tree that holds Logical AND property.For this we will be provided with a binary tree. Our task is to convert it into a tree that holds the logical AND property means that a node has a value of the AND operation of its children nodes. Note that every node can have a value either zero or one.Example Live Demo#include using namespace std; //node structure of binary tree struct Node{ int data; struct Node* left; struct Node* right; }; //creation of a ... Read More
3K+ Views
A String is an object that represents a sequence of characters and immutable in Java. We can reverse a string entered by the user using the charAt() method of String class to extract characters from the string and append them in reverse order to reverse the entered string.In the below example, we need to reverse a string using lambda expression with the help of the Scanner class.Exampleimport java.util.Scanner; interface StringFunc { String func(String n); } public class StringFuncLambdaTest { public static void main(String args[]) { Scanner sc = new Scanner(System.in); StringFunc reverse = (str) -> { // ... Read More
826 Views
The Serialization is a process for writing the state of an object into a byte stream so that we can transfer it over the network. We can serialize a lambda expression if its target type and its captured arguments have serialized. However, like inner classes, the serialization of lambda expressions is strongly discouraged.In the below example, we can serialize and deserialize a lambda function using a Function interface.Exampleimport java.io.*; import java.util.function.Function; interface MyInterface { void hello(String name); } class MyImpl implements MyInterface { public void hello(String name) { System.out.println("Hello " + name); } } public class SerializeDeSerializeLambdaTest { public static void main(String[] args) ... Read More
389 Views
strncmp() and strcmp compares two strings using ASCII character comparison. strncmp takes one additional parameter as number to characters upto which a string is to be compared. It is very useful as if a string is not valid, then strcmp will not be able to complete its operation. strcmp searches for end character ('/0') at string end to finish its operation. strncmp uses no. of characters to end its operation and thus is safe.Example#include int main() { char str1[] = "TutorialsPoint"; char str2[] = "Tutorials"; // Compare strings with strncmp() int result1 = strncmp(str1, str2, ... Read More
13K+ Views
PointerIn C programming language, *p represents the value stored in a pointer and p represents the address of the value, is referred as a pointer.const char* and char const* says that the pointer can point to a constant char and value of char pointed by this pointer cannot be changed. But we can change the value of pointer as it is not constant and it can point to another constant char.char* const says that the pointer can point to a char and value of char pointed by this pointer can be changed. But we cannot change the value of pointer ... Read More
4K+ Views
PointerIn C programming language, *p represents the value stored in a pointer and p represents the address of the value, is referred as a pointer.const int* and int const* says that the pointer can point to a constant int and value of int pointed by this pointer cannot be changed. But we can change the value of pointer as it is not constant and it can point to another constant int.const int* const says that the pointer can point to a constant int and value of int pointed by this pointer cannot be changed. And we cannot change the value ... Read More
14K+ Views
Format SpecifiersIn C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs. scanf() function detects base using %i but assumes base 10 using %d.Example (C) Live Demo#include int main() { int num1 ,num2; int num3, num4; scanf("%i%d", &num1 , &num2); printf("%i\t%d", num1, num2); num3 = 010; num4 = 010; printf("%i\t%d", num3, num4); ... Read More
964 Views
CIn C programming language, if a function signature is not having any parameters then it can take multiple arguments as input but the same is not true with C++. The compilation will fail if arguments are passed to such a function in C++. This is reason int main() and int main(void) are same in C, but int main(void) is better approach, which restricts the user to pass multiple arguments to main function.Example (C) Live Demo#include int main() { static int counter = 3; if (--counter){ printf("%d ", counter); main(5); } }Output2 ... Read More
496 Views
Ternary operatorTernary operator is used to replace if else statements into one statement.Syntax(condition) ? expression1 : expression2;Equivalent Expressionif(condition) { return expression1; } else { return expression2; }If condition is true, then it returns result of expression1 else it returns result of expression2. void is not allowed in condition or expressions.Null coalescing operatorNull coalescing operator is used to provide not null value in case the variable is null.Syntax(variable) ?? expression;Equivalent Expressionif(isset(variable)) { return variable; } else { return expression; }If variable is null, then it returns result of expression.Example PHP Example Outputnot passed not passed