
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 26504 Articles for Server Side Programming

914 Views
Yes, an object can be instantiated and a method can be called on a single line using PHP. This feature has come into effect beginning from PHP version 5.4.An object can be instantiated by accessing the class member of the class. This can be seen in the below snippet −(new my_var)-> my_instance()Code explanation − Here, my_instance is the method and my_var is the object that needs to be instantiated.Example Live Democlass Test_class { public function __construct($param) { $this->_var = $param; } public function my_method() { return $this->_var * 2; } ... Read More

639 Views
Since can’t be used with single quotes, we need to resort to other options.When using command line interface, the constant PHP_EOL can be used.When using with browsers, the ‘’ can be used.Both the options have been demonstrated below.Suppose our option was not cli, the ‘else’ part will be executed and a newline will be printed −Example Live DemoOutputThis will produce the following output −hi hello hihello

236 Views
If there are two nested loops, the break statement can be used −break 2;Below is a demonstration with the foreach loop −foreach(...) { foreach(...) { if (my_var_1.name == my_var_2) break 2; //it breaks out of the outermost foreach loop } }For PHP version>=5.3, the below lines of code can be used −foreach (...) { foreach (...) { if (my_var_1.name == my_var_2) goto top; } } top:

262 Views
In this tutorial, we will be discussing a program to understand MakeFile in C++ and its applications.The task is to break the entire program with MakeFile. It is usually done by making .cpp files and .h files with all the classes/functionalities and link them together.Examplemain.cpp#include #include "function.h" using namespace std; //main execution program int main(){ int num1 = 1; int num2 = 2; cout

491 Views
In this tutorial, we will be discussing a program to understand Kruskal’s minimum spanning tree using STL in C++.For this, we will be provided with a connected, undirected and weighted graph. Our task is to calculate the Minimum spanning tree for the given graph.Example Live Demo#include using namespace std; typedef pair iPair; //structure for graph struct Graph{ int V, E; vector< pair > edges; Graph(int V, int E){ this->V = V; this->E = E; } void addEdge(int u, int v, int w){ edges.push_back({w, {u, v}}); } ... Read More

316 Views
In this tutorial, we will be discussing a program to understand the lower bound in C++.lower_bound() method in C++ is used to return the very first number in the container object which is not less than the given value.Example Live Demo#include int main(){ std::vector v{ 10, 20, 30, 40, 50 }; std::cout

729 Views
In this tutorial, we will be discussing a program to understand how to read the alternate nth byte and write it in another file.For this, we will be provided with two .txt files. Our task is to write the contents from one file to another file using Iseek() which is used to change the pointer of the file descriptor.Example#include #include #include #include void func(char arr[], int n){ int f_write = open("start.txt", O_RDONLY); int f_read = open("end.txt", O_WRONLY); int count = 0; while (read(f_write, arr, 1)){ if (count < n) ... Read More

158 Views
In this tutorial, we will be discussing a program to understand iterator invalidation in C++.While iterating over the elements of a container object, sometimes it can become invalidated if we don’t apply bound checks. This mainly occurs due to the change in the shape and size of the container object.Example Live Demo#include using namespace std; int main() { //declaring a vector vector v{1, 5, 10, 15, 20}; //changing vector during execution //which will cause bound invalidation for (auto it=v.begin();it!=v.end();it++) if ((*it) == 5) v.push_back(-1); for (auto ... Read More

255 Views
In this tutorial, we will be discussing a program to understand the internal details of std::sort() in C++.std::sort() function is used to sort down an array using a comparison of the elements. If we look at the in-depth functionality of std::sort() it uses IntroSort algorithm to sort the elements of a container object.Example Live Demo#include using namespace std; int main(){ int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0}; int n = sizeof(arr)/sizeof(arr[0]); sort(arr, arr+n); cout

2K+ Views
In this tutorial, we will be discussing a program to understand integer literal in C/C++ (Prefixes and suffixes).Integer literals are literals for integer values directly represented in the source code. Further, they are of two types −Prefixes − Prefixes denotes the base of the value. For example, 0x10 indicates hexadecimal value with 0x.Suffixes − Suffixes denotes the type of the value. For example, 8465484156155LL denotes a long long integer.Example Live Demo#include using namespace std; int main(){ //prefixes cout