code-rag-bench/online-tutorials huggingface dataset:
Python | Pandas DatetimeIndex.year - GeeksforGeeks

24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas DatetimeIndex.year attribute outputs an Index object containing the value of years present in the Datetime object.
Syntax: DatetimeIndex.year
Return: Index containing years.
Example #1: Use DatetimeIndex.year attribute to find the years present in the DatetimeIndex.
# importing pandas as pdimport pandas as pd  # Create the DatetimeIndex# Here the 'B' represents Business day frequencydidx = pd.DatetimeIndex(start ='2014-08-01 10:00', freq ='B',                             periods = 5, tz ='Asia/Calcutta')  # Print the DatetimeIndexprint(didx)
Output :
Now we want to find all the year values present in the DatetimeIndex object.
# find all the years in the objectdidx.year
Output :As we can see in the output, the function has returned an Index object containing the year value of each entry in the DatetimeIndex object.&n bsp;Example #2: Use DatetimeIndex.year attribute to find the years present in the DatetimeIndex.
# importing pandas as pdimport pandas as pd  # Create the DatetimeIndex# Here the 'AS' represents Year start frequencydidx = pd.DatetimeIndex(start ='2014-08-01 10:00', freq ='AS',                              periods = 5, tz ='Asia/Calcutta')  # Print the DatetimeIndexprint(didx)
Output :
Now we want to find all the year values present in the DatetimeIndex object.
# find all the years in the objectdidx.year
Output :As we can see in the output, the function has returned an Index object containing the year value of each entry in the DatetimeIndex object.
Python pandas-datetimeIndex
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
C library function - strcat()

The C library function char *strcat(char *dest, const char *src) appends the string pointed to by src to the end of the string pointed to by dest.
Following is the declaration for strcat() function.
char *strcat(char *dest, const char *src)
dest − This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string.
dest − This is pointer to the destination array, which should contain a C string, and should be large enough to contain the concatenated resulting string.
src − This is the string to be appended. This should not overlap the destination.
src − This is the string to be appended. This should not overlap the destination.
This function returns a pointer to the resulting string dest.
The following example shows the usage of strcat() function.
#include <stdio.h>
#include <string.h>

int main () {
   char src[50], dest[50];

   strcpy(src,  "This is source");
   strcpy(dest, "This is destination");

   strcat(dest, src);

   printf("Final destination string : |%s|", dest);
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
Final destination string : |This is destinationThis is source|


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Detecting arrow key presses in JavaScript?

To detect the arrow key when it is pressed, use onkeydown in JavaScript.
The button has key code. As you know the left arrow key has the code 37. The up arrow key
has the code 38 and right has the 39 and down has 40.
Following is the code −
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
</body>
<script>
   document.onkeydown = function (event) {
      switch (event.keyCode) {
         case 37:
            console.log("Left key is pressed.");
            break;
         case 38:
            console.log("Up key is pressed.");
            break;
         case 39:
            console.log("Right key is pressed.");
            break;
         case 40:
            console.log("Down key is pressed.");
            break;
      }
   };
</script>
</html>
To run the above program, save the file name anyName.html(index.html). Right click on the file
and select the option “Open with live server” in VS Code editor.
Here, I have pressed the up arrow key. This will produce the following output on console −
How can we write JSON objects to a file in Java?


The JSON is one of the widely used data-interchange formats and is a lightweight and language independent. The json.simple is a lightweight JSON processing library that can be used to write JSON files and it can be used to encode or decode JSON text and fully compliant with JSON specification(RFC4627). In order to read a JSON file, we need to download the json-simple.jar file and set the path to execute it.
import java.io.*;
import java.util.*;
import org.json.simple.*;
import org.json.simple.parser.*;
public class JSONObjectWriterToFileTest {
   public static void main(String[] args) throws IOException {
      JSONObject obj = new JSONObject();
      obj.put("Name", "Adithya");
      obj.put("Course", "MCA");
      JSONArray subjects = new JSONArray();
      subjects.add("Subject1: DBMS");
      subjects.add("Subject2: JAVA");
      subjects.add("Subject3: PYTHON");
      obj.put("Subjects:", subjects);
      try (FileWriter file = new FileWriter("/Users/User/Desktop/course1.json")) {
         file.write(obj.toJSONString());
         System.out.println("JSON Object write to a File successfully");
         System.out.println("JSON Object: " + obj);
      }
   }
}
JSON Object write to a File successfully
JSON Object: {"Subjects:":["Subject1: DBMS","Subject2: JAVA","Subject3: PYTHON"],"Course":"MCA","Name":"Adithya"}
Delete statement in MS SQL Server - GeeksforGeeks

06 Aug, 2020
A database contains many tables that have data stored in order. To delete the rows, the user needs to use a delete statement.
1. To DELETE a single record :
Syntax –
DELETE FROM table_name 
WHERE condition; 
Note –Take care when deleting records from a table. Note that the WHERE clause in the DELETE statement. This WHERE specifies which record(s) need to be deleted. If you exclude the WHERE clause, all records in the table would be deleted.
Example –A table named Student has multiple values inserted into it and we need to delete some value.
The following SQL statement deletes a row from “Student” table which has StudentName as ‘ABC’.
DELETE FROM student 
WHERE StudentName = 'ABC';
Output –
(1 row(s) affected)
To check whether the value is actually deleted, the query is as follows :
select * 
from student;
Output –
2. To DELETE all the records :It is possible to delete all rows from a table without deleting the table. This means that the table structure, attributes, and indexes are going to be intact.
Syntax –
DELETE FROM table_name;
Example –The following SQL statement deletes all rows from “Student” table, without deleting the table.
DELETE FROM student;
Output –
(3 row(s) affected)
To check whether the value is actually deleted, the query is as follows :
select * 
from student;
DBMS-SQL
SQL-Server
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Second Normal Form (2NF)
Introduction of Relational Algebra in DBMS
KDD Process in Data Mining
Types of Functional dependencies in DBMS
Relational Model in DBMS
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
MySQL | Group_CONCAT() Function
How to round off a floating number using Python?

The round() function in Python's library rounds the number to given position. Following are some Examples.
>>> round(11.6912,2) # upto second decimal place
11.69
>>> round(11.6912,1) # upto first place after decimal point
11.7
>>> round(11.6912) # rounded to nearest integer
12
>>> round(11.6912,-1)#rounded to ten's place
10.0
Removing Negatives from Array in JavaScript

Given an array arr of multiple values. For example −
[-3,5,1,3,2,10]
We are required to write a function that removes any negative values in the array. Once the
function finishes its execution the array should be composed of just positive numbers.
We are required to do this without creating a temporary array and only using pop method to
remove any values in the array.
Therefore, let’s write the code for this function −
The code for this will be −
// strip all negatives off the end
while (x.length && x[x.length - 1] < 0) {
   x.pop();
}
for (var i = x.length - 1; i >= 0; i--) {
   if (x[i] < 0) {
      // replace this element with the last element (guaranteed to be
      positive)
      x[i] = x[x.length - 1];
      x.pop();
   }
}
The output in the console will be −
[ 1, 8, 9 ]
How to delete an item or object from the array using ng-click ?

10 Jun, 2020
The task is to delete the item from the list when the button is clicked. This all should be done by using ng-click. This is done by using the splice() method. The syntax for the method is given below.
Syntax for splice() function:
array.splice(indexno, noofitems(n), item-1, item-2, ..., item-n)

Example for splice() function:
const topics = ['Array', 'String', 'Vector'];let removed=topics.splice(1, 1);
Output:
['Array', 'Vector']

The keywords in syntax are explained here:
indexno: This is required quantity. Definition is integer that specifies at what position to add/remove items.If it is negative means to specify the position from the end of the array.
noofitems(n): This is optional quantity. This indicates a number of items to be removed. If it is set to 0, no items will be removed.
item-1, ...item-n:This is also optional quantity. This indicates new item(s) to be added to the array
Example: Let us focus on example more. Here we will try to prove the delete operation via example. Here student names are given who have an account on GeeksForGeeks. We will try to delete one of the names from the array of student_names.
<!DOCTYPE html>  <html>     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">     </script>  <body style = "text-align:center;">              <h1 style = "color:green;" >          GeeksForGeeks      </h1>  <script>  var app = angular.module("studentNames", []); </script>  <div ng-app="studentNames"      ng-init="names= ['Madhavi', 'Shivay', 'Priya']">  <ul>    <li ng-repeat="x in names track by $index">{{x}}      <span ng-click="names.splice($index, 1)">      <strong>x</strong</span>    </li>  </ul>  <input ng-model="addItem">  <button ng-click="names.push(addItem)">Add</button></div>  <p>Click the small x given in front  of name to remove an item from the name list.</p>  </body></html>
Output:Before Click:
After click:
AngularJS-Directives
AngularJS-Function
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program to Print a New Line in C#

World
Stay
Safe

C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Half adder and full adder

21 Jun, 2022
1. Half Adder : Half Adder is a combinational logic circuit which is designed by connecting one EX-OR gate and one AND gate. The half adder circuit has two inputs: A and B, which add two input digits and generates a carry and a sum.  
The output obtained from the EX-OR gate is the sum of the two numbers while that obtained by AND gate is the carry. There will be no forwarding of carry addition because there is no logic gate to process that. Thus, this is called the Half Adder circuit. 
Logical Expression :
Sum = A XOR B
Carry = A AND B 
Truth Table :
  
2. Full Adder: Full Adder is the circuit that consists of two EX-OR gates, two AND gates, and one OR gate. Full Adder is the adder that adds three inputs and produces two outputs which consist of two EX-OR gates, two AND gates, and one OR gate. The first two inputs are A and B and the third input is an input carry as C-IN. The output carry is designated as C-OUT and the normal output is designated as S which is SUM.
  
The equation obtained by the EX-OR gate is the sum of the binary digits. While the output obtained by AND gate is the carry obtained by addition. 
Truth Table:
  
Logical Expression :
SUM = (A XOR B) XOR Cin = (A ⊕ B) ⊕ Cin
CARRY-OUT = A AND B OR Cin(A XOR B) = A.B + Cin(A ⊕ B) 
krishshewani7
annieahujaweb2020
Difference Between
Digital Electronics & Logic Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Create list of numbers with given range

20 Nov, 2019
Given two numbers r1 and r2 (which defines the range), write a Python program to create a list with the given range (inclusive).
Examples:
Input : r1 = -1, r2 = 1
Output : [-1, 0, 1]

Input : r1 = 5, r2 = 9
Output : [5, 6, 7, 8, 9]

Let’s discuss a few approaches to do this task.
Approach #1 : Naive Approach
A naive method to create list within a given range is to first create an empty list and append successor of each integer in every iteration of for loop.
# Python3 Program to Create list # with integers within given range   def createList(r1, r2):      # Testing if range r1 and r2     # are equal    if (r1 == r2):        return r1      else:          # Create empty list        res = []          # loop to append successors to         # list until r2 is reached.        while(r1 < r2+1 ):                          res.append(r1)            r1 += 1        return res      # Driver Coder1, r2 = -1, 1print(createList(r1, r2))
[-1, 0, 1]

 Approach #2 : List comprehension
We can also use list comprehension for the purpose. Just iterate ‘item’ in a for loop from r1 to r2 and return all ‘item’ as list. This will be a simple one liner code.
# Python3 Program to Create list # with integers within given range   def createList(r1, r2):    return [item for item in range(r1, r2+1)]      # Driver Coder1, r2 = -1, 1print(createList(r1, r2))
[-1, 0, 1]

 Approach #3 : using Python range()
Python comes with a direct function range() which creates a sequence of numbers from start to stop values and print each item in the sequence. We use range() with r1 and r2 and then convert the sequence into list.
# Python3 Program to Create list # with integers within given range   def createList(r1, r2):    return list(range(r1, r2+1))      # Driver Coder1, r2 = -1, 1print(createList(r1, r2))
[-1, 0, 1]

 Approach #4 : Using numpy.arange()
Python numpy.arange() returns a list with evenly spaced elements as per the interval. Here we set the interval as 1 according to our need to get the desired output.
# Python3 Program to Create list # with integers within given range import numpy as npdef createList(r1, r2):    return np.arange(r1, r2+1, 1)      # Driver Coder1, r2 = -1, 1print(createList(r1, r2))
[-1  0  1]

ManasChhabra2
Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enumerate() in Python
Read a file line by line in Python
Different ways to create Pandas Dataframe
How to Install PIP on Windows ?
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Ruby | String chars() Method

17 Dec, 2019
chars is a String class method in Ruby which is used to return an array of characters in str.
Syntax: str.chars
Parameters: Here, str is the given string
Returns: An array of the characters.
Example 1:
# Ruby program to demonstrate # the chars method        # Taking a string and # using the method puts "Ruby String".chars() puts "Methods".chars() 
Output:
R
u
b
y
 
S
t
r
i
n
g
M
e
t
h
o
d
s

Example 2:
# Ruby program to demonstrate # the chars method        # Taking a string and # using the method puts "GFG".chars() puts "G4G".chars() 
Output:
G
F
G
G
4
G

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Can we sort a list with Lambda in Java?

Yes, we can sort a list with Lambda. Let us first create a String List:
List<String> list = Arrays.asList("LCD","Laptop", "Mobile", "Device", "LED", "Tablet");
Now, sort using Lambda, wherein we will be using compareTo():
Collections.sort(list, (String str1, String str2) -> str2.compareTo(str1));
The following is an example to sort a list with Lambda in Java:
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Demo {
   public static void main(String... args) {  
      List<String> list = Arrays.asList("LCD","Laptop", "Mobile", "Device", "LED", "Tablet");
      System.out.println("List = "+list);
      Collections.sort(list, (String str1, String str2) -> str2.compareTo(str1));
      System.out.println("Sorted List = "+list);
   }
}
List = [LCD, Laptop, Mobile, Device, LED, Tablet]
Sorted List = [Tablet, Mobile, Laptop, LED, LCD, Device]
What are named parameters in C#?

Named parameters provides us the relaxation to remember or to look up the order of parameters in the parameter lists of called methods. The parameter for each argument can be specified by parameter name.
NamedParameterFunction(firstName: "Hello", lastName: "World")
Using named parameters in C#, we can put any parameter in any sequence as long as the name is there. The right parameter value based on their names will be mapped to the right variable. The parameters name must match with the method definition parameter names. Named arguments also improve the readability of our code by identifying what each argument represents.
 Live Demo
using System;
namespace DemoApplication{
   class Demo{
      static void Main(string[] args){
         NamedParameterFunction("James", "Bond");
         NamedParameterFunction(firstName:"Mark", lastName:"Wood");
         NamedParameterFunction(lastName: "Federer", firstName: "Roger");
         Console.ReadLine();
      }
      public static void NamedParameterFunction(string firstName, string lastName){
         Console.WriteLine($"FullName: {firstName} {lastName}");
      }
   }
}
The output of the above code is
FullName: James Bond
FullName: Mark Wood
FullName: Roger Federer
In the above code NamedParameterFunction(lastName: "Federer", firstName: "Roger") even though parameters are not passed in order since we are using named parameters, the parameters are mapped based on the name. So we are getting the output "Roger Federer" which is as expected.
Find all combinations that add upto given number using C++

Suppose we have a positive number n. We have to find all combinations of positive numbers, that adds up to that number. Here we want only combinations, not the permutations. For the value n = 4, there will be [1, 1, 1, 1], [1, 1, 2], [2, 2], [1, 3], [4]
We will solve this using recursion. We have an array to store combinations, and we will fill that array using recursive approach. Each combination will be stored in increasing order of elements.
#include<iostream>
using namespace std;
void getCombination(int arr[], int index, int num, int decrement) {
   if (decrement < 0)
      return;
   if (decrement == 0){
      for (int i = 0; i < index; i++)
         cout << arr[i] << " ";
         cout << endl;
         return;
   }
   int prev;
   if(index == 0)
   prev = 1;
   else
      prev = arr[index-1];
   for (int k = prev; k <= num ; k++) {
      arr[index] = k;
      getCombination(arr, index + 1, num, decrement - k);
   }
}
void findCombinations(int n) {
   int arr[n];
   getCombination(arr, 0, n, n);
}
int main() {
   int n = 4;
   findCombinations(n);
}
1 1 1 1
1 1 2
1 3
2 2
4
Convert BST to Max Heap in C++

In this tutorial, we will be discussing a program to convert a binary search tree to a max heap.
For this we will be provided with a binary search tree. Our task is to convert the given binary search tree into a max heap such that following the condition of the binary search tree when elements are compared with themselves.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
//node structure of BST
struct Node {
   int data;
   Node *left, *right;
};
//node creation
struct Node* getNode(int data) {
   struct Node* newNode = new Node;
   newNode->data = data;
   newNode->left = newNode->right = NULL;
   return newNode;
}
//performing post order traversal
void postorderTraversal(Node*);
//moving in a sorted manner using inorder traversal
void inorderTraversal(Node* root, vector<int>& arr) {
   if (root == NULL)
      return;
   inorderTraversal(root->left, arr);
   arr.push_back(root->data);
   inorderTraversal(root->right, arr);
}
void convert_BSTHeap(Node* root, vector<int> arr, int* i){
   if (root == NULL)
      return;
   convert_BSTHeap(root->left, arr, i);
   convert_BSTHeap(root->right, arr, i);
   //copying data from array to node
   root->data = arr[++*i];
}
//converting to max heap
void convert_maxheap(Node* root) {
   vector<int> arr;
   int i = -1;
   inorderTraversal(root, arr);
   convert_BSTHeap(root, arr, &i);
}
//printing post order traversal
void postorderTraversal(Node* root) {
   if (!root)
      return;
   postorderTraversal(root->left);
   postorderTraversal(root->right);
   cout << root->data << " ";
}
int main() {
   struct Node* root = getNode(4);
   root->left = getNode(2);
   root->right = getNode(6);
   root->left->left = getNode(1);
   root->left->right = getNode(3);
   root->right->left = getNode(5);
   root->right->right = getNode(7);
   convert_maxheap(root);
   cout << "Postorder Traversal:" << endl;
   postorderTraversal(root);
   return 0;
}
Postorder Traversal:
1 2 3 4 5 6 7
How to add empty border to JPanel in Java?

To add empty border, use the createEmtyBorder() method. Let us first create a new JLabel −
JLabel label;

label = new JLabel("Label with empty border!");
Now, set empty border using the setBorder() method −
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
The following is an example to add empty border to JPanel −
package my;
import javax.swing.BorderFactory;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class SwingDemo {
   public static void main(String[] args) throws Exception {
      JFrame frame = new JFrame("Demo");
      JLabel label;
      label = new JLabel("Label with empty border!");
      label.setFont(new Font("Verdana", Font.PLAIN, 16));
      label.setVerticalAlignment(JLabel.BOTTOM);
      label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
      frame.add(label);
      frame.setSize(550,350);
      frame.setVisible(true);
   }
}
Batch Script - String Interpolation

String interpolation is a way to construct a new String value from a mix of constants, variables, literals, and expressions by including their values inside a string literal.
In DOS scripting, the string interpolation can be done using the set command and lining up the numeric defined variables or any other literals in one line when using the set command.
The following example shows how a string interpolation can be done with numeric values as well.
@echo off 
SET a = Hello 
SET b = World 
SET /A d = 50 
SET c=%a% and %b% %d%
echo %c%
The above command produces the following output.
Hello and World 50

 Print
 Add Notes
 Bookmark this page
Scala short ==(x: Int): Boolean - GeeksforGeeks

14 Jan, 2020
Short, a 16-bit signed integer (equivalent to Java’s short primitive type) is a subtype of scala.AnyVal. The ==(x: Int) method is utilized to return true if this value is equal to x, false otherwise.
Method Definition: def ==(x: Int): Boolean
Return Type: It returns true if this value is equal to x, otherwise false.
Example #1:
// Scala program of Short ==(x: Int) // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Applying Short ==(x: Int) function         val result = (99.toShort).==(99:Int)                  // Displays output         println(result)           } } 
Output:
true
Example #2:
// Scala program of Short ==(x: Int) // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Applying Short ==(x: Int) function         val result = (102.toShort).==(101:Int)                  // Displays output         println(result)           } } 
Output:
false
Scala
scala-short
Python
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
For Loop in Scala
Scala | flatMap Method
Scala Lists
Class and Object in Scala
Scala | map() method
What are the member variables of a class in C#?

A class is a blueprint that has member variables and functions in C#. This describes the behavior of an object.
Let us see the syntax of a class to learn what are member variables −
<access specifier> class class_name {
   // member variables
   <access specifier> <data type> variable1;
   <access specifier> <data type> variable2;
   ...
   <access specifier> <data type> variableN;
   // member methods
   <access specifier> <return type> method1(parameter_list) {
      // method body
   }
   <access specifier> <return type> method2(parameter_list) {
      // method body
   }
   ...
   <access specifier> <return type> methodN(parameter_list) {
      // method body
   }
}
Member variables are the attributes of an object (from design perspective) and they are kept private to implement encapsulation. These variables can only be accessed using the public member functions.
Below length and width are member variables because a new instance/ of this variable will get created for each new instance of Rectangle class.
 Live Demo
using System;

namespace RectangleApplication {
   class Rectangle {
      //member variables
      private double length;
      private double width;

      public void Acceptdetails() {
         length = 10;
         width = 14;
      }

      public double GetArea() {
         return length * width;
      }

      public void Display() {
         Console.WriteLine("Length: {0}", length);
         Console.WriteLine("Width: {0}", width);
         Console.WriteLine("Area: {0}", GetArea());
      }

   } //end class Rectangle

   class ExecuteRectangle {
      static void Main(string[] args) {
         Rectangle r = new Rectangle();
         r.Acceptdetails();
         r.Display();
         Console.ReadLine();
      }
   }
}
Length: 10
Width: 14
Area: 140
C++ Library - <ostream>

It is an output stream objects can write sequences of characters and represent other kinds of data. Specific members are provided to perform these output operations.
Below is definition of std::ostream.
typedef basic_ostream<char> ostream;
charT − Character type.
charT − Character type.
traits − Character traits class that defines essential properties of the characters used by stream objects.
traits − Character traits class that defines essential properties of the characters used by stream objects.
 Print
 Add Notes
 Bookmark this page
How to merge table columns in HTML?

To merge table columns in HTML use the colspan attribute in <td> tag. With this, merge cells with each other. For example, if your table is having 4 rows and 4 columns, then with colspan attribute, you can easily merge 2 or even 3 of the table cells.
You can try to run the following code to merge table column in HTML. Firstly, we will see how to create a table in HTML with 3 rows and 3 columns
<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
            width: 100px;
            height: 50px;
         }
      </style>
   </head>

   <body>
      <h1>Heading</h1>
      <table>
         <tr>
            <th></th>
            <th></th>
            <th></th>
         </tr>
         <tr>
            <td></td>
            <td></td>
            <td></td>
         </tr>
         <tr>
            <td></td>
            <td></td>
            <td></td>
         </tr>
      </table>
   </body>
</html>
Let’s merge columns using the colspan attribute. The first 2 columns will merge
<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
            width: 100px;
            height: 50px;
         }
      </style>
   </head>
   <body>
      <h1>Heading</h1>
      <table>
         <tr>
            <th></th>
            <th></th>
            <th></th>
         </tr>
         <tr>
            <td colspan="2"></td>
            <td></td>
         </tr>
         <tr>
            <td></td>
            <td></td>
            <td></td>
         </tr>
      </table>
   </body>
</html>
HTML DOM getElementsByTagName() method

The HTML DOM getElementsByTagName() method is used for getting the collection of all the elements in the document having a given tag name. It returns all the given elements as a NodeList object. You can access any element in the returned object using the index number.
The HTMLcollection returned stays sync with the DOM tree without calling the getElementsByTagName() method again and again after removing or adding some elements.
Following is the syntax for the getElementsByTagName() method −
element.getElementsByTagName(tagname)
Here, tagname is a mandatory parameter value indicating the child elements tagname that we want to get.
Let us look at an example for the getElementsByTagName() method −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script>
   function changePara() {
      var p = document.getElementsByTagName("P");
      p[0].innerHTML = "This text has been changed";
      p[1].style.color = "red";
      p[1].style.backgroundColor = "yellow";
   }
</script>
</head>
<body>
<h1>getElementsByTagName() example</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</p>
<button onclick="changePara()">CHANGE</button>
</body>
</html>
This will produce the following output −
On clicking the CHANGE button −
In the above example −
We have created two paragraphs that have no attributes associated with them −
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua</p>

<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat</p>
We have then created a button CHANGE that will execute the changePara() on being clicked by the user −
<button onclick="changePara()">CHANGE</button>
The changePara() method gets both the <p> elements as nodeListObject using the getElementsByTagName() method upon the document object and assigns it to variable p. Using the index numbers we change the text for the first paragraph and apply some styling to the second paragraph −
function changePara() {
   var p = document.getElementsByClassName("PARA1");
   p[0].innerHTML = "This text has been changed";
   p[1].style.color = "red";
   p[1].style.backgroundColor = "yellow";
}
What is the Mutex class in C#?

The Mutex class in C# is a synchronization primitive that can also be used for interprocess synchronization.
Let us see how to create a new Mutex.
private static Mutex m = new Mutex();
Let us now see how to initialize a new instance of the Mutex class with a Boolean value.
private static Mutex m = new Mutex(true);
Now let us see how to initialize a new instance of the Mutex class with a Boolean value and the name of the Mutex.
 Live Demo
using System;
using System.Threading;

public class Demo {
   public static void Main() {
      Mutex mt = new Mutex(false, "NewMutex");
      Console.WriteLine("Waiting for the Mutex.");
      mt.WaitOne();
      Console.WriteLine("Owner of the mutex. " + "ENTER is to be pressed to release the mutexand          exit.");
      Console.ReadLine();
      mt.ReleaseMutex();
   }
}
Waiting for the Mutex.
Owner of the mutex. ENTER is to be pressed to release the mutex and exit.
Xamarin - Permissions

In Android, by default, no application has permissions to perform any operations that would have an effect on the user or the operating system. In order for an App to perform a task, it must declare the permissions. The App cannot perform the task until the permission are granted by the Android system. This mechanism of permissions stops applications from doing as they wish without the user’s consent.
Permissions are to be recorded in AndroidManifest.xml file. To add permissions, we double-click on properties, then go to Android ManRequired permissions will appear. Check the appropriate permissions you wish to add.
Camera − It provides permission to access the device’s camera.
<uses-permission android:name="android.permission.CAMERA" />

Internet − It provides access to network resources.
<uses-permission android:name="android.permission.INTERNET" /> 

ReadContacts − It provides access to read the contacts on your device.
<uses-permission android:name="android.permission.READ_CONTACTS" /> 

ReadExternalStorage − It provides access to read and store data on an external storage.
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 

Calendars − It allows an app access to the calendar on the user device and events. This permission can be dangerous, as it grants an app the ability to send emails to guests without the owner’s awareness. The syntax for adding this permission is as shown below −
<uses-permission android:name="android.permission-group.CALENADAR" /> 

SMS − An app with this permission has the ability to use the devices messaging services. It includes reading, writing, and editing SMS and MMS messages. Its syntax is as shown below.
<uses-permission android:name="android.permission-group.SMS" />

Location − An app with this permission can access the device’s location using the GPS network.
<uses-permission android:name="android.permission-group.LOCATION" /> 

Bluetooth − An app with this permission can exchange data files with other Bluetooth enabled devices wirelessly.
<uses-permission android:name="android.permission.BLUETOOTH" />

 Print
 Add Notes
 Bookmark this page
C# Program to Print the Current Assembly Name Using GetExecutingAssembly() Method - GeeksforGeeks

16 Nov, 2021
In C#, GetExecutingAssembly() method is the method of Assembly class. This method returns the assembly that contains the code that is currently executing. To use this method we have to use System.Reflection in our program.
Syntax:
public static System.Reflection.Assembly GetExecutingAssembly ();
It will return the current program assembly, version, culture, and PublicKeyToken. 
Example 1:
C#
// C# program to display the current assembly name using System;using System.Reflection;  class GFG{      static void Main(string[] args){    Console.WriteLine("Current assembly contains:");        // Get the executing assembly    // Using GetExecutingAssembly() method    Console.WriteLine(Assembly.GetExecutingAssembly());}}
Output:
Current assembly contains:
main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Example 2:
C#
// C# program to display the current assembly name using System;using System.Reflection;  class GFG{      static void Main(string[] args){          // Get the executing assembly     // with FullName property    // FullName property is use     // to print the name of the assembly    Console.WriteLine(Assembly.GetExecutingAssembly().FullName);}}
Output:
main, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Program to calculate Electricity Bill
Linked List Implementation in C#
C# | How to insert an element in an Array?
HashSet in C# with Examples
Lambda Expressions in C#
Convert String to Character Array in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Socket Programming in C#
Program to find absolute value of a given number
How to declare Java array with array size dynamically?

To declare array size dynamically read the required integer value from the user using Scanner class and create an array using the given value:
import java.util.Arrays;
import java.util.Scanner;

public class PopulatingAnArray {
   public static void main(String args[]) {
      System.out.println("Enter the required size of the array :: ");
      Scanner s = new Scanner(System.in);
      int size = s.nextInt();
      int myArray[] = new int [size];
      System.out.println("Enter the elements of the array one by one ");
     
      for(int i = 0; i<size; i++) {
         myArray[i] = s.nextInt();
     }
     System.out.println("Contents of the array are: "+Arrays.toString(myArray));
   }
}
Enter the required size of the array ::
5
Enter the elements of the array one by one
78
96
45
23
45
Contents of the array are: [78, 96, 45, 23, 45]
How to input multiple values from user in one line in Python?

To read multiple variables in language C, we write something like −
//Read three variable in one line
scanf(“%d %d %d”, &x, &y, &z)
Currently python does not have an equivalent to scanf(). However, python provides regular expressions which are more powerful and verbose than scanf() format strings. In Python, to provide multiple values from user, we can use −
input() method: where the user can enter multiple values in one line, like −
>>> x, y, z = input(), input(), input()
40
30
10
>>> x
'40'
>>> y
'30'
>>> z
'10'
From above output, you can see, we are able to give values to three variables in one line.
To avoid using multiple input() methods(depends on how many values we are passing), we can use the list comprehension or map() function.
>>> x,y,z = [int(x) for x in input().split()]
9 12 15
>>> x
9
>>> y
12
>>> z
15
In above line of code, i have typecast the input values to integers. In case you don’t want that & your inputs are of mixed type, you can simply type −
>>> x,y,z = [x for x in input().split()]
40 10 "hello"
Another way to pass multiple values from user is to use map function.
>>> x,y,z = map(int, input().split())
40 54 90
>>> x
40
>>> y
54
>>> z
90
Count occurrences of a substring recursively in Java

Given two strings str_1 and str_2. The goal is to count the number of occurrences of substring str2 in string str1 using a recursive process.
A recursive function is the one which has its own call inside it’s definition.
If str1 is “I know that you know that i know” str2=”know”
Count of occurences is − 3
Let us understand with examples.
For Example
str1 = "TPisTPareTPamTP", str2 = "TP";
Count of occurrences of a substring recursively are: 4
The substring TP occurs 4 times in str1.
str1 = "HiHOwAReyouHiHi" str2 = "Hi"
Count of occurrences of a substring recursively are: 3
The substring Hi occurs 3 times in str1.
Approach used in the below program is as follows −
In this approach we will search for occurrence of str2 in str1 using contains() method in java. It will return true if str2 exists in str1. In case true, remove that first occurrence from str1 by replacing it with “” using replaceFirst() method in java and add 1 to return value to increase count.
Take two strings as str1 and str2.
Take two strings as str1 and str2.
Recursive Method subsrting_rec(String str, String sub) takes string str and its substring sub and returns the count of occurrences of sub in str.
Recursive Method subsrting_rec(String str, String sub) takes string str and its substring sub and returns the count of occurrences of sub in str.
Check whether str.contains(sub) is true. ( str has sub )
Check whether str.contains(sub) is true. ( str has sub )
If true then replace the first occurrence of sub with “” using str.replaceFirst(sub,””).
If true then replace the first occurrence of sub with “” using str.replaceFirst(sub,””).
Do this inside a recursive call to subsrting_rec(String str, String sub).
Do this inside a recursive call to subsrting_rec(String str, String sub).
At the end of all recursions the sum of all return values is count.
At the end of all recursions the sum of all return values is count.
Print the result.
Print the result.
 Live Demo
public class recursive{
   public static void main(String args[]){
      String str1 = "TPisTPareTPamTP", str2 = "TP";
      System.out.println("Count of occurrences of a substring recursively are: "+subsrting_rec(str1, str2));
   }
   static int subsrting_rec(String str, String sub){
      if (str.contains(sub)){
         return 1 + subsrting_rec(str.replaceFirst(sub, ""), sub);
      }
      return 0;
   }
}
If we run the above code it will generate the following output −
Count of occurrences of a substring recursively are: 4
Comprehensions in Python

We can create new sequences using a given python sequence. This is called comprehension. It basically a way of writing a concise code block to generate a sequence which can be a list, dictionary, set or a generator by using another sequence. It may involve multiple steps of conversion between different types of sequences.
In this method, we create a new list by manipulating the values of an existing list. In the below example we take a list and create a new list by adding 3 to each element of the given list.
given_list = [x for x in range(5)]
print(given_list)

new_list = [var+3 for var in given_list]

print(new_list)
Running the above code gives us the following result −
[0, 1, 2, 3, 4]
[3, 4, 5, 6, 7]
Similar to the above we can take in a list and create a dictionary from it.
given_list = [x for x in range(5)]
print(given_list)

#new_list = [var+3 for var in given_list]
new_dict = {var:var + 3 for var in given_list }

print(new_dict)
Running the above code gives us the following result −
[0, 1, 2, 3, 4]
{0: 3, 1: 4, 2: 5, 3: 6, 4: 7}
We can also take in two lists and create a new dictionary out of it.
list1 = [x for x in range(5)]
list2 = ['Mon','Tue','Wed','Thu','Fri']
print(list1)
print(list2)

new_dict ={key:value for (key, value) in zip(list1, list2)}

print(new_dict)
Running the above code gives us the following result −
[0, 1, 2, 3, 4]
['Mon', 'Tue', 'Wed', 'Thu', 'Fri']
{0: 'Mon', 1: 'Tue', 2: 'Wed', 3: 'Thu', 4: 'Fri'}
We can take a similar approach as above and create new set from existing set or list. In the below example we create a new set by adding 3 to the elements of the existing set.
given_set = {x for x in range(5)}
print(given_set)

new_set = {var+3 for var in given_set}

print(new_set)
Running the above code gives us the following result −
{0, 1, 2, 3, 4}
{3, 4, 5, 6, 7}
New generators can be created from the existing list. These generators are memory efficient as they allocate memory as the items are generated instead of allocating it at the beginning.
given_list = [x for x in range(5)]
print(given_list)

new_set = (var+3 for var in given_list)

for var1 in new_set:
   print(var1, end=" ")
Running the above code gives us the following result −
[0, 1, 2, 3, 4]
3 4 5 6 7
How to get max(id) of row data in MySQL?

To get max(id), use MAX() method in MySQL. Following is the syntax −
select MAX(yourColumnName) AS anyAliasName from yourTableName;
Let us first create a table −
mysql> create table DemoTable710 (Id int);
Query OK, 0 rows affected (0.53 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable710 values(1001);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable710 values(2001);
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable710 values(1998);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable710 values(1789);
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable710 values(1678);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable710 values(9087);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable710 values(1908);
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable710;
This will produce the following output -
+------+
| Id   |
+------+
| 1001 |
| 2001 |
| 1998 |
| 1789 |
| 1678 |
| 9087 |
| 1908 |
+------+
7 rows in set (0.00 sec)
Following is the query to get max(id) of row data in MySQL −
mysql> select MAX(Id) AS Max_Id from DemoTable710;
This will produce the following output -
+--------+
| Max_Id |
+--------+
| 9087   |
+--------+
1 row in set (0.00 sec)
Different ways to traverse an Array in Java?

In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.
You can access the elements of an array using name and position as −
System.out.println(myArray[3]);
//Which is 1457
In Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −
int myArray[] = new int[7];
myArray[0] = 1254;
myArray[1] = 1458;
myArray[2] = 5687;
myArray[3] = 1457;
myArray[4] = 4554;
myArray[5] = 5445;
myArray[6] = 7524;
Or, you can directly assign values with in flower braces separating them with commas (,) as −
int myArray = { 1254, 1458, 5687, 1457, 4554, 5445, 7524};
You can traverse through an array using for loop or forEach loop.
Using the for loop − Instead on printing element by element, you can iterate the index using for loop starting from 0 to length of the array (ArrayName.length) and access elements at each index.
public class IteratingArray {
   public static void main(String args[]) {
      //Creating an array
      int myArray[] = new int[7];
      //Populating the array
      myArray[0] = 1254;
      myArray[1] = 1458;
      myArray[2] = 5687;
      myArray[3] = 1457;
      myArray[4] = 4554;
      myArray[5] = 5445;
      myArray[6] = 7524;
      //Printing Contents using for loop
      System.out.println("Contents of the array: ");
      for(int i=0; i<myArray.length; i++) {
         System.out.println(myArray[i]);
      }
   }
}
Contents of the array:
1254
1458
5687
1457
4554
5445
7524
Using the for each loop − Since JDK 1.5, Java introduced a new for loop known as foreach loop or enhanced for loop, which enables you to traverse the complete array sequentially without using an index variable. You can traverse through the array with less effort using this.
import java.util.Arrays;
public class IteratingArray {
   public static void main(String args[]) {
      //Creating an array
      int myArray[] = new int[7];
      //Populating the array
      myArray[0] = 1254;
      myArray[1] = 1458;
      myArray[2] = 5687;
      myArray[3] = 1457;
      myArray[4] = 4554;
      myArray[5] = 5445;
      myArray[6] = 7524;
      //Printing Contents using for each loop
      System.out.println("Contents of the array: ");
      for (int element: myArray) {
         System.out.println(element);
      }
   }
}
Contents of the array:
[1254, 1458, 5687, 1457, 4554, 5445, 7524]