Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Ankith Reddy
Page 5 of 73
FILTER_VALIDATE_FLOAT constant in PHP
The FILTER_VALIDATE_FLOAT constant validates a value as a float number.ReturnThe FILTER_VALIDATE_FLOAT constant does not return anything.ExampleOutputThe following is the output.float(291.9)
Read MoreFull Date Short Time ("f") Format Specifier in C#
The Full Date Short Time standard format specifier represents a combination of the long date ("D") and short time ("t") patterns.UseDateTime to set the date.DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);Now, use the (“f”) format specifier like this −myDate.ToString("f", CultureInfo.CreateSpecificCulture("en-US"))The following is an example −Exampleusing System; using System.Globalization; class Demo { static void Main() { DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0); Console.WriteLine(myDate.ToString("f",CultureInfo.CreateSpecificCulture("en-US"))); } }OutputWednesday, August 29, 2018 1:10 AM
Read MoreFILTER_VALIDATE_URL constant in PHP
The FILTER_VALIDATE_URL constant validates a URL.FlagsFILTER_FLAG_SCHEME_REQUIRED − URL must be RFC compliant.FILTER_FLAG_HOST_REQUIRED − URL must include host name.FILTER_FLAG_PATH_REQUIRED −URL must have a path after the domain name.FILTER_FLAG_QUERY_REQUIRED −URL must have a query string.ReturnThe FILTER_VALIDATE_URL constant does not return anything.ExampleOutputThe following is the output.Valid URL!Let us see another example.ExampleOutputHere is the output.Invalid URL!
Read MoreCompute modulus division by a power-of-2-number in C#
We have taken the number as the following −uint a = 9; uint b = 8;Above, a is a divisor and b is dividend.To compute modulus division.Exampleusing System; class Demo { static uint display( uint a, uint b) { return ( a & (b-1) ); } static public void Main () { uint a = 9; uint b = 6; Console.WriteLine( a + " modulus " + b + " = " + display(a, b)); } }Output9 modulus 6 = 1
Read MoreWhen to use new operator in C++ and when it should not be used?
Use of the new operator signifies a request for the memory allocation on the heap. If the sufficient memory is available, it initializes the memory and returns its address to the pointer variable.The new operator should only be used if the data object should remain in memory until delete is called. Otherwise if the new operator is not used, the object is automatically destroyed when it goes out of scope. In other words, the objects using new are cleaned up manually while other objects are automatically cleaned when they go out of scope.The following is the syntax of new operator.pointer_variable ...
Read MoreSchedule a task for repeated fixed delay execution in Java
In fixed-delay execution, each execution is scheduled with respect to the original execution time of the preceding execution. If an execution is delayed for a particular reason (case in point, garbage collection), the subsequent executions will be delayed as well.There are two ways in which a task can be scheduled for repeated fixed-delay execution. They are as follows −Scheduling a task for repeated fixed-delay execution at a specified timeScheduling a task for repeated fixed-delay execution after a specified delayScheduling a task for repeated fixed-delay execution at a specified timeThe void schedule(TimerTask task, Date firstTime, long period) method schedules tasks for ...
Read MoreC# Console.WindowLeft Property
The WindowsLeft property gets or sets the leftmost position of the console window area relative to the screen buffer.Declare an integer variable to get the leftmost position.int left;Now, use the Console.WindowLeft property.left = Console.WindowLeftLet us see the complete example.Exampleusing System; class Demo { static void Main() { int left; left = Console.WindowLeft; Console.WriteLine("Left position of the Console window = "+left); } }OutputNote: The output may vary accordingly based on the position of the Console WindowLeft position of the Console window = 0
Read MoreException Propagation in C#
Exception Propogation can be understood by how exception handling works in C#.In try, when an exception occurs the corresponding catch blocks are checked. This is done to see if they can catch the exception. If no matching exception is found, the exception is propagated to a higher-level try block. This repeats until the exception is caught. In case, the exception isn’t caught, the execution of the program comes to an end.The above concept is explain in the below example showing nested try statements.Exampleusing System; using System.Text; public class Demo { public static void Main() { try ...
Read MoreHow to return local array from a C++ function?
A local array cannot be directly returned from a C++ function as it may not exist in memory after the function call. A way to resolve this is to use a static array in the function. As the lifetime of the static array is the whole program, it can easily be returned from a C++ function without the above problem.A program that demonstrates this is given as follows.Example#include using namespace std; int *retArray() { static int arr[10]; for(int i = 0; i
Read MoreFILTER_SANITIZE_NUMBER_FLOAT constant in PHP
The FILTER_SANITIZE_NUMBER_FLOAT constant deletes all illegal characters from a float number.FlagsFILTER_FLAG_ALLOW_FRACTION − Allows fraction separatorFILTER_FLAG_ALLOW_THOUSAND − Allows thousand separatorFILTER_FLAG_ALLOW_SCIENTIFIC − Allows scientific notationReturnThe FILTER_SANITIZE_NUMBER_FLOAT constant does not return anything.ExampleThe following is an example that use FILTER_FLAG_ALLOW_FRACTION flag.OutputThe following is the output.string(8) "3-1+2.56"Let us see another example. Here, FILTER_FLAG_ALLOW_THOUSAND flag is used −ExampleOutputHere is the output.string(8) "1-4+25,6"
Read More