code-rag-bench/online-tutorials huggingface dataset:
Difference Between Structure and Union

In this post, we will understand the difference between structure and union.
The ‘struct’ keyword is used to define a structure.
The ‘struct’ keyword is used to define a structure.
Every member in the structure is provided with a unique memory location.
Every member in the structure is provided with a unique memory location.
When the value of one data member is changed, it doesn’t affect other data members in structure.
When the value of one data member is changed, it doesn’t affect other data members in structure.
It helps initialize multiple members at once.
It helps initialize multiple members at once.
Total size of the structure is equivalent to the sum of the size of every data member.
Total size of the structure is equivalent to the sum of the size of every data member.
It is used to store various data types.
It is used to store various data types.
It takes memory for every member which is present within the structure.
It takes memory for every member which is present within the structure.
A member can be retrieved at a time.
A member can be retrieved at a time.
It supports flexible arrays.
It supports flexible arrays.
Following is the syntax of Structure Definition −
struct [structure tag] {
   member definition;
   member definition;
   ...
   member definition;
} [one or more structure variables];
The ‘union’ keyword is used to define a union.
The ‘union’ keyword is used to define a union.
A memory location is shared by all of its data members.
A memory location is shared by all of its data members.
Changing the value of one data member will affect/change the value of other data members as well.
Changing the value of one data member will affect/change the value of other data members as well.
It allows the user to initialize the first member of union only.
It allows the user to initialize the first member of union only.
Total size of the union is equivalent to the size of the largest data member in the union.
Total size of the union is equivalent to the size of the largest data member in the union.
It is used to store one of the multiple data types available.
It is used to store one of the multiple data types available.
It takes memory for a member that has the highest size.
It takes memory for a member that has the highest size.
Only one member can be accessed at a time.
Only one member can be accessed at a time.
It doesn’t support flexible arrays.
It doesn’t support flexible arrays.
Following is the syntax of Union Definition −
union [union tag] {
   member definition;
   member definition;
   ...
   member definition;
} [one or more union variables];
\href - Tex Command

\href - Used to make a math object into a link.
{ \href{ <url> } #1 }
\href command is used to make a math object into a link where the argument (#1) is the clickable area.

\href{http://www.tutorialspoint.com}{M^{A^{T^H}}}

MATH



\href{http://www.tutorialspoint.com}{M^{A^{T^H}}}

MATH


\href{http://www.tutorialspoint.com}{M^{A^{T^H}}}

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Using underscore in Numeric Literals in Java

Followig is the code showing how to use underscore in numeric literals in Java −
 Live Demo
public class Demo{
   public static void main (String[] args) throws java.lang.Exception{
      int my_num_1 = 6_78_00_120;
      System.out.println("The number is : " + my_num_1);
      long my_num_2 = 2_00_11_001;
      System.out.println("The number is : " + my_num_2);
      float my_num_3 = 4.01_981F;
      System.out.println("The number is : " + my_num_3);
      double my_num_4 = 12.89_46_061;
      System.out.println("The number is : " + my_num_4);
   }
}
The number is : 67800120
The number is : 20011001
The number is : 4.01981
The number is : 12.8946061
A class named Demo contains the main function which uses various formats of integer, long, floating point values and double values to display data with the help of underscotres. This is assigned to a variable each, that is printed on the console.
MomentJS - Humanize

This method displays the date in human readable format.
moment.duration().humanize();

var a = moment.duration(24, "hours").humanize();
In case you need suffix such as ago or in to the output, add true to humanize as follows
var a = moment.duration(24, "hours").humanize(true);
var a = moment.duration(-1, "days").humanize(true);
 Print
 Add Notes
 Bookmark this page
How to check if a string is a valid keyword in Java?

To check if a string is a valid keyword in Java, the code is as follows −
 Live Demo
import java.util.*;
public class Demo{
   static boolean valid_identifier(String my_str, int n){
      if (!((my_str.charAt(0) >= 'a' && my_str.charAt(0) <= 'z')
         || (my_str.charAt(0)>= 'A' && my_str.charAt(1) <= 'Z')
         || my_str.charAt(0) == '_'))
         return false;
      for (int i = 1; i < my_str.length(); i++){
         if (!((my_str.charAt(i) >= 'a' && my_str.charAt(i) <= 'z')
            || (my_str.charAt(i) >= 'A' && my_str.charAt(i) <= 'Z')
            || (my_str.charAt(i) >= '0' && my_str.charAt(i) <= '9')
            || my_str.charAt(i) == '_'))
         return false;
      }
      return true;
   }
   public static void main(String args[]){
      String my_str = "Hi_there!3";
      int n = my_str.length();
      if (valid_identifier(my_str, n))
         System.out.println("It is valid");
      else
         System.out.println("It is invalid");
   }
}
It is invalid
A class named Demo contains a function named ‘valid_identifier’ that returns Boolean output. It takes a string and an integer, checks to see if the string contains characters between ‘a’ to ‘z’ or ‘A’ to ‘Z’ or an underscore character, otherwise returns false. It iterates through the length of the string, and checks for the validity of the string and sees if it contains integers between ‘0’ and ‘9’ too. Otherwise, it returns false. In the main function, the string is defined, and the length of the string is assigned to a variable. The function is called by passing the string and the string length. This displays the relevant message.
How to save the contents of a Textbox in Tkinter?

To save the contents of a Textbox in Tkinter, we can take the following steps −
Create an instance of tkinter frame.
Create an instance of tkinter frame.
Set the size of the frame using win.geometry method.
Set the size of the frame using win.geometry method.
Define a user-defined method "open_text" to open a text file in "read" mode. Read the contents of the text file and save it in a variable called "content". Then, use the "insert" method to insert the contentin a Textbox.
Define a user-defined method "open_text" to open a text file in "read" mode. Read the contents of the text file and save it in a variable called "content". Then, use the "insert" method to insert the contentin a Textbox.
Next, define another user-defined method called "save_text" and in it, use the "write" method to save the contents of the textbox in the text file.
Next, define another user-defined method called "save_text" and in it, use the "write" method to save the contents of the textbox in the text file.
Create a text widget using the Text method with specified height and width.
Create a text widget using the Text method with specified height and width.
Create a button to call the open_text method.
Create a button to call the open_text method.
Create a button to call the open_text method.
Create a button to call the open_text method.
Finally, run the mainloop of the application window.
Finally, run the mainloop of the application window.
# Import tkinter library
from tkinter import *

# Create an instance of tkinter window
win = Tk()
win.geometry("700x250")

def open_text():
   text_file = open("test.txt", "r")
   content = text_file.read()
   my_text_box.insert(END, content)
   text_file.close()

def save_text():
   text_file = open("test.txt", "w")
   text_file.write(my_text_box.get(1.0, END))
   text_file.close()

# Creating a text box widget
my_text_box = Text(win, height=10, width=40)
my_text_box.pack()

open_btn = Button(win, text="Open Text File", command=open_text)
open_btn.pack()

# Create a button to save the text
save = Button(win, text="Save File", command=save_text)
save.pack()

win.mainloop()
When you execute the code, it will show the following screen −
Now, click the "Open Text File" button to open the text file "test.txt". It will display the contents of the file in the Textbox.
Next, type a new line inside the Textbox and click "Save File" to save the contents in "test.txt".
Python - Bubble Charts

Bubble charts display data as a cluster of circles. The required data to create bubble chart needs to have the xy coordinates, size of the bubble and the colour of the bubbles. The colours can be supplied by the 
library itself.
Bubble chart can be created using the DataFrame.plot.scatter() methods.
import matplotlib.pyplot as plt
import numpy as np
 
# create data
x = np.random.rand(40)
y = np.random.rand(40)
z = np.random.rand(40)
colors = np.random.rand(40) 
# use the scatter function
plt.scatter(x, y, s=z*1000,c=colors)
plt.show()
 
Its output is as follows −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to compare two string arrays, case insensitive and independent about ordering JavaScript, ES6

We are required to write a function, say isEqual() that takes in two strings as argument and
checks if they both contains the same characters independent of their order and case.
For example −
const first = 'Aavsg';
const second = 'VSAAg';
isEqual(first, second); //true
In this method we convert the strings into arrays, make use of the Array.prototype.sort() method,
convert them back into strings and check for equality.
The code for this will be −
const first = 'Aavsg';
const second = 'VSAAg';
const stringSort = function(){
   return this.split("").sort().join("");
}
String.prototype.sort = stringSort;
const isEqual = (first, second) => first.toLowerCase().sort() ===
second.toLowerCase().sort();
console.log(isEqual(first, second));
In this method we iterate over both the strings at the same time, store the character frequencies in a
map with values like this −
-1, if it appears in the first string,
+1, if it appears in the second string,
At last, if all the keys add up 0, we conclude that that the strings are same otherwise not.
The code for this will be −
const first = 'Aavsg';
const second = 'VSAAg';
const isEqual = (first, second) => {
   if(first.length !== second.length){
      return false;
   }
   first = first.toLowerCase();
   second = second.toLowerCase();
   const map = {};
   for(ind in first){
      if(map[first[ind]]){
         map[first[ind]]++;
      }else{
         map[first[ind]] = 1;
      }
      if(map[second[ind]]){
         map[second[ind]]--;
      }else{
         map[second[ind]] = -1;
      }
   };
   return Object.values(map).reduce((acc, val) => val === 0 && acc, true);
};
console.log(isEqual(first, second));
The output in the console for both will be −
true
How to prevent MySQL double insert (duplicate entry)?

To prevent duplicate entry, add constraint UNIQUE. Let us first create a table −
mysql> create table DemoTable
(
   Id int,
   Name varchar(100)
);
Query OK, 0 rows affected (0.79 sec)
Here is the query to prevent MySQL double insert using UNIQUE −
mysql> alter table DemoTable add constraint id_NameUnKey UNIQUE(Id,Name);
Query OK, 0 rows affected (0.82 sec)
Records: 0 Duplicates: 0 Warnings: 0
Insert records in the table using insert command. When we will try to the same record again, then the “Duplicate entry” error will be visible −
mysql> insert into DemoTable values(11,'John');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values(12,'John');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable values(11,'John');
ERROR 1062 (23000): Duplicate entry '11-John' for key 'id_NameUnKey'
Display records from the table using select command −
mysql> select *from DemoTable;
This will produce the following output −
+------+------+
| Id   | Name |
+------+------+
| 11   | John |
| 12   | John |
+------+------+
2 rows in set (0.00 sec)
Set small modal in Bootstrap

Use the .modal-sm class in Bootstrap to set small modal with less width.
You can try to run the following code to implement the .modal-sm class −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link rel = "stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Examination</h2>
         <button type = "button" class = "btn btn-lg" data-toggle = "modal" data-target = "#new">Result</button>
         <div class = "modal fade" id = "new" role = "dialog">
            <div class = "modal-dialog modal-sm">
               <div class = "modal-content">
                  <div class = "modal-header">
                     <button type = "button" class = "close" data-dismiss = "modal">×</button>
                     <h4 class = "modal-title">Warning</h4>
                  </div>
                  <div class = "modal-body">
                     <p>If JavaScript isn't enabled in your web browser, then you may not be able to see the result.</p>
                  </div>
                  <div class = "modal-footer">
                     <button type = "button" class = "btn btn-primary" data-dismiss = "modal">Close</button>
                  </div>
               </div>
            </div>
         </div>
      </div>
   </body>
</html>
MySQL NULL Values - IS NULL and IS NOT NULL

A field with a NULL value is a field with no value.
If a field in a table is optional, it is possible to insert a new record or 
update a record without adding a value to this field. Then, the field will be 
saved with a NULL value.
Note: A NULL value is different from a zero value or a field that 
contains spaces. A field with a NULL value is one that has been left blank 
during record creation!
It is not possible to test for NULL values with comparison operators, such as 
=, <, or <>.
We will have to use the IS NULL and 
IS NOT NULL operators instead.
Below is a selection from the "Customers" table in the Northwind sample 
database:
The IS NULL operator is used to test for empty values (NULL values).
The following SQL lists all customers with a NULL value in the "Address" field:
Tip: Always use IS NULL to look for NULL values.
The IS NOT NULL operator is used to test for non-empty values (NOT NULL 
values).
The following SQL lists all customers with a value in the "Address" field:
Select all records from the Customers where 
the PostalCode column is empty.
SELECT * FROM Customers
WHERE   ;

Start the 
Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Epoch time in Perl

You can use the time() function in Perl to get epoch time, i.e., the numbers of seconds that have elapsed since a given date, in Unix is January 1, 1970.
 Live Demo
#!/usr/local/bin/perl
$epoc = time();
print "Number of seconds since Jan 1, 1970 - $epoc\n";
When the above code is executed, it produces the following result −
Number of seconds since Jan 1, 1970 - 1361022130
You can convert a given number of seconds into date and time string as follows −
 Live Demo
#!/usr/local/bin/perl
$datestring = localtime();
print "Current date and time $datestring\n";
$epoc = time();
$epoc = $epoc - 24 * 60 * 60;    # one day before of current date.
$datestring = localtime($epoc);
print "Yesterday's date and time $datestring\n";
When the above code is executed, it produces the following result −
Current date and time Tue Jun 5 05:54:43 2018
Yesterday's date and time Mon Jun 4 05:54:43 2018
Can we have generic constructors in Java?

Generics is a concept in Java where you can enable a class, interface and, method, accept all (reference) types as parameters. In other words it is the concept which enables the users to choose the reference type that a method, constructor of a class accepts, dynamically. By defining a class as generic you are making it type-safe i.e. it can act up on any datatype.
To define a generic class you need to specify the type parameter you are using in the angle brackets “<>” after the class name and you can treat this as datatype of the instance variable an proceed with the code.
Example − Generic class
class Student<T>{
   T age;
   Student(T age){
      this.age = age;
   }
   public void display() {
      System.out.println("Value of age: "+this.age);
   }
}
Usage − While instantiating the generic class you need to specify the object name after the class within the angular brackets. Thus, choose the type of the type parameter dynamically and pass the required object as a parameter.
public class GenericsExample {
   public static void main(String args[]) {
      Student<Float> std1 = new Student<Float>(25.5f);
      std1.display();
      Student<String> std2 = new Student<String>("25");
      std2.display();
      Student<Integer> std3 = new Student<Integer>(25);
      std3.display();
   }
}
Example generic methods
Similar to generic classes you can also define generic methods in Java. These methods use their own type parameters. Just like local variables, the scope of the type parameters of the methods lies within the method.
While defining generic methods you need to specify the type parameter in the angular brackets and use it as a local variable.
 Live Demo
public class GenericMethod {
   <T>void sampleMethod(T[] array) {
      for(int i=0; i<array.length; i++) {
         System.out.println(array[i]);
      }
   }
   public static void main(String args[]) {
      GenericMethod obj = new GenericMethod();
      Integer intArray[] = {45, 26, 89, 96};
      obj.sampleMethod(intArray);
      String stringArray[] = {"Krishna", "Raju", "Seema", "Geeta"};
      obj.sampleMethod(stringArray);
   }
}
45
26
89
96
Krishna
Raju
Seema
Geeta
Constructors are similar to methods and just like generic methods we can also have generic constructors in Java though the class is non-generic.
Since the method does not have return type for generic constructors the type parameter should be placed after the public keyword and before its (class) name.
Once you define a generic constructor you can invoke (instantiate the class using that particular constructor) it by passing any type (object) as parameter.
Following Java program demonstrates the usage of generic constructors in Java.
 Live Demo
class Employee{
   String data;
   public <T> Employee(T data){
      this.data = data.toString();
   }
   public void dsplay() {
      System.out.println("value: "+this.data);
   }
}
public class GenericConstructor {
   public static void main(String args[]) {
      Employee emp1 = new Employee("Raju");
      emp1.dsplay();
      Employee emp2 = new Employee(12548);
      emp2.dsplay();
   }
}
value: Raju
value: 12548
C program to count Positive and Negative numbers in an Array - GeeksforGeeks

22 Apr, 2020
Given an array arr of integers of size N, the task is to find the count of positive numbers and negative numbers in the array
Examples:
Input: arr[] = {2, -1, 5, 6, 0, -3}Output:Positive elements = 3Negative elements = 2There are 3 positive, 2 negative, and 1 zero.
Input: arr[] = {4, 0, -2, -9, -7, 1}Output:Positive elements = 2Negative elements = 3There are 2 positive, 3 negative, and 1 zero.
Approach:
Traverse the elements in the array one by one.For each element, check if the element is less than 0. If it is, then increment the count of negative elements.For each element, check if the element is greater than 0. If it is, then increment the count of positive elements.Print the count of negative and positive elements.
Traverse the elements in the array one by one.
For each element, check if the element is less than 0. If it is, then increment the count of negative elements.
For each element, check if the element is greater than 0. If it is, then increment the count of positive elements.
Print the count of negative and positive elements.
Below is the implementation of the above approach:
// C program to find the count of positive// and negative integers in an array  #include <stdio.h>  // Function to find the count of// positive integers in an arrayint countPositiveNumbers(int* arr, int n){    int pos_count = 0;    int i;    for (i = 0; i < n; i++) {        if (arr[i] > 0)            pos_count++;    }    return pos_count;}  // Function to find the count of// negative integers in an arrayint countNegativeNumbers(int* arr, int n){    int neg_count = 0;    int i;    for (i = 0; i < n; i++) {        if (arr[i] < 0)            neg_count++;    }    return neg_count;}  // Function to print the arrayvoid printArray(int* arr, int n){    int i;      printf("Array: ");    for (i = 0; i < n; i++) {        printf("%d ", arr[i]);    }    printf("\n");}  // Driver programint main(){    int arr[] = { 2, -1, 5, 6, 0, -3 };    int n;    n = sizeof(arr) / sizeof(arr[0]);      printArray(arr, n);      printf("Count of Positive elements = %d\n",           countPositiveNumbers(arr, n));    printf("Count of Negative elements = %d\n",           countNegativeNumbers(arr, n));      return 0;}
Array: 2 -1 5 6 0 -3 
Count of Positive elements = 3
Count of Negative elements = 2

Arrays
C Programs
School Programming
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Stack Data Structure (Introduction and Program)
Top 50 Array Coding Problems for Interviews
Introduction to Arrays
Multidimensional Arrays in Java
Linear Search
Strings in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
UDP Server-Client implementation in C
Header files in C/C++ and its uses
Deleting a Label in Python Tkinter

Tkinter label widgets are used to display text and images in the application. We can also configure the properties of Label widget that are created by default in a tkinter application.
If we want to delete a label that is defined in a tkinter application, then we have to use the destroy() method.
In this example, we will create a Button that will allow the user to delete the label from the widget.
# Import the required libraries
from tkinter import *
from tkinter import ttk
from PIL import Image, ImageTk

# Create an instance of tkinter frame or window
win = Tk()

# Set the size of the window
win.geometry("700x350")

def on_click():
   label.after(1000, label.destroy())

# Create a Label widget
label = Label(win, text=" Deleting a Label in Python Tkinter", font=('Helvetica 15'))
label.pack(pady=20)

# Add a Button to Show/Hide Canvas Items
ttk.Button(win, text="Delete", command=on_click).pack()

win.mainloop()
If we run the above code, it will display a window with a label widget and a Button.
Now, click the button to delete the Label from the window.
How to sort an ArrayList in Ascending Order in Java - GeeksforGeeks

11 Dec, 2018
Given an unsorted ArrayList, the task is to sort this ArrayList in ascending order in Java.
Examples:
Input: Unsorted ArrayList: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal]Output: Sorted ArrayList: [A computer portal, For, ForGeeks, Geeks, GeeksForGeeks]
Input: Unsorted ArrayList: [Geeks, For, ForGeeks]Output: Sorted ArrayList: [For, ForGeeks, Geeks]
Approach: An ArrayList can be Sorted by using the sort() method of the Collections Class in Java. This sort() method takes the collection to be sorted as the parameter and returns a Collection sorted in the Ascending Order by default.
Syntax:
Collections.sort(ArrayList);
Below is the implementation of the above approach:
// Java program to demonstrate// How to sort ArrayList in ascending order  import java.util.*;  public class GFG {    public static void main(String args[])    {          // Get the ArrayList        ArrayList<String>            list = new ArrayList<String>();          // Populate the ArrayList        list.add("Geeks");        list.add("For");        list.add("ForGeeks");        list.add("GeeksForGeeks");        list.add("A computer portal");          // Print the unsorted ArrayList        System.out.println("Unsorted ArrayList: "                           + list);          // Sorting ArrayList in ascending Order        // using Collection.sort() method        Collections.sort(list);          // Print the sorted ArrayList        System.out.println("Sorted ArrayList "                           + "in Ascending order : "                           + list);    }}
Unsorted ArrayList: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal]
Sorted ArrayList in Ascending order : [A computer portal, For, ForGeeks, Geeks, GeeksForGeeks]

Java - util package
Java-ArrayList
Java-Collections
Java-List-Programs
Sorting Quiz
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Initialize an ArrayList in Java
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
ArrayList in Java
How to iterate any Map in Java
Multidimensional Arrays in Java
Stack Class in Java
Stream In Java
Singleton Class in Java
How can I remove everything inside of a <div> using jQuery?

To remove everything inside a div element, use the remove() method. You can try to run the following code to remove everything inside a <div> element −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $(".btn").click(function(){
        $("div#demo").remove();
    });
     
  });
</script>
</head>
<body>

<button class="btn">Hide the elements inside div</button>

<div id="demo">
<p>Inside div- This is demo text.</p>
<p>Inside div- This is demo text.</p>
</div>
<span>
<p>Inside span- This is demo text.</p>
<p>Inside span- This is demo text.</p>
</span>
</body>
</html>
C# | Math.Exp() Method - GeeksforGeeks

01 Feb, 2019
In C#, Exp() is a Math class method which is used to return the e raised to the specified power. Here e is a mathematical constant whose value is approximately 2.71828. Exp() is the inverse of Log().
Syntax:
public static double Exp (double num);
Parameter:
num: It is the required number of type System.Double which specifies a power.
Return Type: It returns a number e raised to the power num of type System.Double.
Note:
If num is equal to NaN then the return value will be NaN.
If num is equal to PositiveInfinity then the return value will be Infinity.
If num is equal to NegativeInfinity then the return value will be 0.
Example 1:
// C# Program to illustrate the// Math.Exp(Double) Methodusing System;   class Geeks {       // Main Method    public static void Main()    {           // using the method        Console.WriteLine(Math.Exp(10.0));        Console.WriteLine(Math.Exp(15.57));        Console.WriteLine(Math.Exp(529.548));        Console.WriteLine(Math.Exp(0.00));    }}
22026.4657948067
5780495.71030692
9.54496417945595E+229
1

Example 2:
// C# Program to illustrate the// Math.Exp(Double) Method by // taking NaN, PositiveInfinity// and NegativeInfinity]using System;   class Geeks {       // Main Method    public static void Main()    {           // Taking NaN        Console.WriteLine(Math.Exp(Double.NaN));                  // Taking PositiveInfinity        Console.WriteLine(Math.Exp(Double.PositiveInfinity));                  // Taking NegativeInfinity        Console.WriteLine(Math.Exp(Double.NegativeInfinity));    }}
NaN
Infinity
0

Reference: https://docs.microsoft.com/en-us/dotnet/api/system.math.exp?view=netcore-2.1
CSharp-Math
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Method Overriding
Destructors in C#
Difference between Ref and Out keywords in C#
C# | Delegates
C# | String.IndexOf( ) Method | Set - 1
C# | Constructors
Extension Method in C#
Introduction to .NET Framework
C# | Class and Object
DAX Date & Time - TODAY function

Returns the current date.
TODAY () 

No parameters for this function.
Current date in datetime format.
DAX TODAY function is useful when you need to have the current date displayed on a workbook, regardless of when you open the workbook. It is also useful for calculating intervals.
DAX functions - TODAY and NOW both return the current date. However,
TODAY returns the time as 12:00:00 always.
NOW returns the time precisely.
= YEAR (TODAY () – [JoiningDate]) – 1900 returns the number of years of service for each employee.

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
SymPy - Installation

SymPy has one important prerequisite library named mpmath. It is a Python library for real and complex floating-point arithmetic with arbitrary precision. However, Python's package installer PIP installs it automatically when SymPy is installed as follows −
pip install sympy

Other Python distributions such as Anaconda, Enthought Canopy, etc., may have SymPy already bundled in it. To verify, you can type the following in the Python prompt −
>>> import sympy
>>> sympy.__version__

And you get the below output as the current version of sympy −
'1.5.1'
Source code of SymPy package is available at https://github.com/sympy/sympy.
 Print
 Add Notes
 Bookmark this page
\Bigg - Tex Command

\Bigg - Used to obtain various-sized delimiters.
{ \Bigg }
\Bigg commands are used to obtain various-sized delimiters.

\Bigg[ 

[


\Bigg[ 

[


\bigg[ 

[


\Big[ 

[


\Big[ 

[


[ 

[



\Bigg[ 

[


\Bigg[ 
\Bigg[ 

[


\Bigg[ 
\bigg[ 

[


\bigg[ 
\Big[ 

[


\Big[ 
\Big[ 

[


\Big[ 
[ 

[


[ 

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
PHP | DateTime diff() Function

10 Oct, 2019
The DateTime::diff() function is an inbuilt function in PHP which is used to return the difference between two given DateTime objects.
Syntax:
Object oriented style:DateInterval DateTime::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )orDateInterval DateTimeImmutable::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )orDateInterval DateTimeInterface::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )
DateInterval DateTime::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )
or
DateInterval DateTimeImmutable::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )
or
DateInterval DateTimeInterface::diff( DateTimeInterface $datetime2,
                                  bool $absolute = FALSE )
Procedural style:DateInterval date_diff( DateTimeInterface $datetime1,
                  DateTimeInterface $datetime2, bool $absolute = FALSE )
DateInterval date_diff( DateTimeInterface $datetime1,
                  DateTimeInterface $datetime2, bool $absolute = FALSE )
Parameters: This function uses two parameters as mentioned above and described below:
$datetime: This parameter holds the date to compare with first date.
$absolute: This parameter forced the interval to be positive.
Return Value: This function return the difference between two given DateTime objects.
Below programs illustrate the DateTime::diff() function in PHP:
Program 1:
<?php  // Initialising the two datetime objects$datetime1 = new DateTime('2019-9-10');$datetime2 = new DateTime('2019-9-15');  // Calling the diff() function on above// two DateTime objects$difference = $datetime1->diff($datetime2);  // Getting the difference between two// given DateTime objectsecho $difference->format('%R%a days');?>
+5 days

Program 2:
<?php  // Initialising the two datetime objects$datetime1 = new DateTime('2019-8-10');$datetime2 = new DateTime('2019-9-10');  // Calling the diff() function on above// two DateTime objects$difference = $datetime1->diff($datetime2);  // Getting the difference between two// given DateTime objectsecho $difference->format('%R%a days');?>
+31 days

Reference: https://www.php.net/manual/en/datetime.diff.php
PHP-date-time
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
PHP | Converting string to Date and DateTime
How to receive JSON POST with PHP ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
C# | Check if the Hashtable contains a specific Key

01 Feb, 2019
The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. The key is used to access the items in the collection. Hashtable.ContainsKey(Object) Method is used to check whether the Hashtable contains a specific key or not.
Syntax:
public virtual bool ContainsKey(object key);

Parameter:
key: The key of type System.Object to locate in the Hashtable.
Return Type: It return true if the Hashtable contains an element with the specified key otherwise, false. The return type of this method is System.Boolean.
Exception: This method can give ArgumentNullException if the key is null.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to check if the HashTable// contains a specific keyusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a Hashtable        Hashtable myTable = new Hashtable();          // Adding elements in Hashtable        myTable.Add("g", "geeks");        myTable.Add("c", "c++");        myTable.Add("d", "data structures");        myTable.Add("q", "quiz");          // check if the HashTable contains        // the required key or not.        if (myTable.ContainsKey("c"))            Console.WriteLine("myTable contains the key");        else            Console.WriteLine("myTable doesn't contain the key");    }}
myTable contains the key

Example 2:
// C# code to check if the HashTable// contains a specific keyusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a Hashtable        Hashtable myTable = new Hashtable();          // Adding elements in Hashtable        myTable.Add("India", "Country");        myTable.Add("Chandigarh", "City");        myTable.Add("Mars", "Planet");        myTable.Add("China", "Country");          // check if the HashTable contains        // the required key or not.        if (myTable.ContainsKey("Earth"))            Console.WriteLine("myTable contains the key");        else            Console.WriteLine("myTable doesn't contain the key");    }}
myTable doesn't contain the key

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.hashtable.containskey?view=netframework-4.7.2
CSharp-Collections-Hashtable
CSharp-Collections-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE CS 2019 | Question 11

16 Aug, 2021
A certain processor uses a fully associative cache of size 16 kB, The cache block size is 16 bytes. Assume that the main memory is byte addressable and uses a 32-bit address. How many bits are required for the Tag and the Index fields respectively in the addresses generated by the processor?
(A) 24 bits and 0 bits(B) 28 bits and 4 bits(C) 24 bits and 4 bits(D) 28 bits and 0 bitsAnswer: (D)Explanation: Given cache block size is 16 bytes, so block or word offset is 4 bits. Fully associative cache of size 16 kB, so line offset should be,
= cache size / block size
= 16 kB / 16 B
= 1 k 
= 1024
= 10 bits Line or Index Offset 
Tag bit size would be,
= processor address size - (line offset + word offset)
= 32 - 10 - 4
= 18 bits tag size 
Since, there no option matches, but if we assume that Line Offset is a part of Tag bits, therefore,
Tag bits = 18+10 = 28 bits
Line or Index offset = 0 bits (since fully associative cache memory),
Word or block offset = 4 bits 
Alternative way:We know in fully associative mapping,
Line size = block size = frame size 
Number of bits in tag can be founded using given below formula
Number of Tag bits 
= Total number of bits in Physical Address - no of bits in Block offset 
Here number of bits in block offset is not given. It can be found using
ceil(log2 Cache block size) = ceil(log2 16) = 4 
So,
Number of Tag bits = 32-4 = 28 
No index bits is there in fully associative mapping,hence Index bits = 0
So, option (D) is correct.
Questions on Cache Mapping Techniques with Ashish Verma | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.5K subscribersQuestions on Cache Mapping Techniques with Ashish Verma | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.More videosMore videosYou're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0022:43 / 58:01•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=lz3J33WzNOo" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
VeenaSreekumarNair
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 40
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE-CS-2016 (Set 1) | Question 45
How to Change FTP Port in Linux?

24 Feb, 2021
Files are either uploaded or downloaded to the FTP server. The files are moved from a personal computer to the server when you upload files. The files are moved from the cloud to your personal computer when the files are downloaded. In order to transfer files through FTP, TCP/IP (Transmission Control Protocol/Internet Protocol), or the language used by the internet to execute commands, is used.
To adjust the default Linux port of the Proftpd operation, first, open the Proftpd main configuration file for editing with your favorite text editor by issuing the command below.
Step 1: First open Proftpd main configuration file for editing.
$ nano /etc/proftpd/proftpd.conf
Open config file
Step 2: Find the following line port number.
Port 21
Find Port
Step 3: And change the FTP default port 21 to a custom port, for example, 210.
Change the port
Step 4: Save and close the file. To take effect the changes, restart the proftpd service using the below command
$ systemctl restart proftpd
Restart Proftpd service
Step 5: Check the table of local network sockets with the netstat or ss command.
$ netstat -tlpn| grep nginx
OR
$ ss -tlpn| grep nginx
Check port
Now your FTP port should be changed.
Picked
Technical Scripter 2020
How To
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Install and Use NVM on Windows?
How to Install Python Packages for AWS Lambda Layers?
How to Install Git in VS Code?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
MATLAB - The switch Statement

A switch block conditionally executes one set of statements from several choices. Each choice is covered by a case statement.
An evaluated switch_expression is a scalar or string.
An evaluated case_expression is a scalar, a string or a cell array of scalars or strings.
The switch block tests each case until one of the cases is true. A case is true when −
For numbers, eq(case_expression,switch_expression).
For numbers, eq(case_expression,switch_expression).
For strings, strcmp(case_expression,switch_expression).
For strings, strcmp(case_expression,switch_expression).
For objects that support the eq(case_expression,switch_expression).
For objects that support the eq(case_expression,switch_expression).
For a cell array case_expression, at least one of the elements of the cell array matches switch_expression, as defined above for numbers, strings and objects.
For a cell array case_expression, at least one of the elements of the cell array matches switch_expression, as defined above for numbers, strings and objects.
When a case is true, MATLAB executes the corresponding statements and then exits the switch block.
The otherwise block is optional and executes only when no case is true.
The syntax of switch statement in MATLAB is −
switch <switch_expression>
   case <case_expression>
      <statements>
   case <case_expression>
      <statements>
      ...
      ...
   otherwise
      <statements>
end

Create a script file and type the following code in it −
grade = 'B';
   switch(grade)
   case 'A' 
      fprintf('Excellent!\n' );
   case 'B' 
      fprintf('Well done\n' );
   case 'C' 
      fprintf('Well done\n' );
   case 'D'
      fprintf('You passed\n' );
   case 'F' 
      fprintf('Better try again\n' );
   otherwise
      fprintf('Invalid grade\n' );
   end
When you run the file, it displays −
Java String Class strip() Method With Examples

02 Feb, 2021
Java String Class strip() method returns a string that provides a string with all leading and trailing white spaces removed. This method is similar to the String.trim() method. There are basically 3 methods by which we can remove white spaces in a different manner.
strip() Method: It returns a string, with all leading and trailing white space removed
Syntax:
String strippedString = string.strip()
stripLeading() Method: It returns a string, with all leading white space removed.
Syntax:
String leadingStripString = string.stripLeading()
stripTrailing() Method: It returns a string, with all trailing white space removed.
Syntax:
String trailedStripString = string.stripTrailing()
Example:
Java
// Java Program to demonstrate the use of the strip()// method,stripLeading() method,stripTrailing() method  public class GFG {    public static void main(String[] args)    {        String str            = "        Geeks For Geeks Internship    !   ";          // removing leading and        // trailing white spaces        System.out.println(str.strip());          // removing leading white spaces        System.out.println(str.stripLeading());          // removing trailing white spaces        System.out.println(str.stripTrailing());    }}
Output:
Geeks For Geeks Internship    !
Geeks For Geeks Internship    !   
        Geeks For Geeks Internship    !
Java-Strings
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
Factory method design pattern in Java
Java Program to Remove Duplicate Elements From the Array
GATE | GATE-CS-2001 | Question 27

28 Jun, 2021
Consider the following statements:
S1: There exists infinite sets A, B, C such that 
    A ∩ (B ∪ C) is finite.
S2: There exists two irrational numbers x and y such
    that (x+y) is rational.
Which of the following is true about S1 and S2?(A) Only S1 is correct(B) Only S2 is correct(C) Both S1 and S2 are correct(D) None of S1 and S2 is correctAnswer: (C)Explanation: S1: A ∩ (B ∪ C)Here S1 is finite where A, B, C are infiniteWe’ll prove this by taking an example.Let A = {Set of all even numbers} = {2, 4, 6, 8, 10...}Let B = {Set of all odd numbers} = {1, 3, 5, 7...........}Let C = {Set of all prime numbers} = {2, 3, 5, 7, 11, 13......}B U C = {1, 2, 3, 5, 7, 9, 11, 13......}A ∩ (B ∪ C)Willbe equals to: {2} which is finite.I.e. using A, B, C as infinite sets the statement S1 is finite.So, statement S1 is correct.S2: There exists two irrational numbers x, y such that (x+y) is rationalTo prove this statement as correct, we take an example.Let X = 2-Sqrt (3), Y = 2+Sqrt (3) => X, Y are irrationalX+Y = 2+Sqrt (3) + 2-Sqrt (3) = 2+2 = 4So, statement S2 is also correct.Answer is Option C
Both Statements S1, S2 are correct.
 
This solution is contributed by Anil Saikrishna Devarasetty.Quiz of this Question
GATE-CS-2001
GATE-GATE-CS-2001
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE-CS-2004 | Question 31
GATE | GATE CS 1996 | Question 63