code-rag-bench/online-tutorials huggingface dataset:
An Uncommon representation of array elements - GeeksforGeeks

09 Nov, 2020
Consider the below program.
int main( ){  int arr[2] = {0,1};  printf("First Element = %d\n",arr[0]);  getchar();  return 0;}
Pretty Simple program.. huh... Output will be 0.
Now if you replace arr[0] with 0[arr], the output would be same. Because compiler converts the array operation in pointers before accessing the array elements.
e.g. arr[0] would be *(arr + 0) and therefore 0[arr] would be *(0 + arr) and you know that both *(arr + 0) and *(0 + arr) are same.YouTubeGeeksforGeeks507K subscribersAn Uncommon representation of array elements | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You'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.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 4:17•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=Uw_TtJQyrwk" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
Please write comments if you find anything incorrect in the above article.
C-Pointers
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Substring in C++
Core Dump (Segmentation fault) in C/C++
rand() and srand() in C/C++
fork() in C
Converting Strings to Numbers in C/C++
std::string class in C++
Enumeration (or enum) in C
Command line arguments in C/C++
Make an image responsive with Bootstrap

To make an image responsive in Bootstrap, add a class .img-responsive to the <img> tag. This class applies max-width: 100%; and height: auto; to the image so that it scales nicely to the parent element.
The following is how you can simply make an image responsive −
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <img src = "https://www.tutorialspoint.com/python/images/python_data_science.jpg" class = "img-responsive" alt = "Online Training">
   </body>
</html>
Python - Next N elements from K value - GeeksforGeeks

11 Oct, 2020
Given a List, get next N values from occurrence of K value in List.
Input : test_list = [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9], N = 1, K = 4 Output : [6, 7, 2] Explanation : All successive elements to 4 are extracted as N = 1.
Input : test_list = [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9], N = 2, K = 7 Output : [8, 4, 2, 1] Explanation : Two elements after each occurrence of 7 are extracted. 
Method #1 : Using list comprehension + slicing 
In this we extract all the indices using list comprehension, and then loop is employed to append the elements and join in as single string from the desired K value occurrences in List.
Python3
# Python3 code to demonstrate working of# Next N elements of K value# Using list comprehension + slicing  # initializing listtest_list = [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9]  # printing original listprint("The original list is : " + str(test_list))  # initializing KK = 4  # initializing NN = 2  # getting indices of Ktemp = [idx for idx in range(len(test_list)) if test_list[idx] == K]  # getting next N elements from K using loopres = []for ele in temp:      # appending slice    res.extend(test_list[ele + 1: ele + N + 1])  # printing resultprint("Constructed Result List : " + str(res))
The original list is : [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9]
Constructed Result List : [6, 7, 7, 2, 2, 3]


Method #2 : Using filter() + lambda + loop
This is similar to above method, difference being filtering of indices is performed using filter() and lambda functions.
Python3
# Python3 code to demonstrate working of# Next N elements of K value# Using filter() + lambda + loop  # initializing listtest_list = [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9]  # printing original listprint("The original list is : " + str(test_list))  # initializing KK = 4  # initializing NN = 2  # getting indices of K# using filter() and lambdatemp = list(filter(lambda ele: test_list[ele] == K, range(len(test_list))))  # getting next N elements from K using loopres = []for ele in temp:      # appending slice    res.extend(test_list[ele + 1: ele + N + 1])  # printing resultprint("Constructed Result List : " + str(res))
The original list is : [3, 4, 6, 7, 8, 4, 7, 2, 1, 8, 4, 2, 3, 9]
Constructed Result List : [6, 7, 7, 2, 2, 3]


Python list-programs
Python
Python Programs
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 ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Check if element exists in list in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Pattern Generation using time() module - GeeksforGeeks

08 Jun, 2020
This article aims to print patterns using the time() module in python.Examples:
Input :5Output :5 patterns using time with 5 rows
Input :4Output :5 patterns using time with 4 rows, but for diamond if youwill enter even number of rows, it will automatically do (row+1)
Code : Python program to generate patterns
# Print triangles by giving the number of stars:  # For Diamond, an odd number of stars will give a better result,# If the number is even then for diamond pattern,# it will automatically do (row + 1):  import time  n = 5  print("----------Right Angled Triangle Type 1----------")  def right_angle_triangle1(n):          for i in range(1, n + 1):        for j in range(i):            time.sleep(0.05)            print("*", end ="")        print()       right_angle_triangle1(n)  print()  print("----------Right Angled Triangle Type 2----------")  def right_angle_triangle2(n):          for i in range(1, n + 1):        for j in range(n-i):            time.sleep(0.05)            print(" ", end ="")        for k in range(i):            time.sleep(0.05)            print("*", end ="")        print()right_angle_triangle2(n)  print()  print("----------Equilateral Triangle----------")  def equilateral_triangle(n):          for i in range(1, n + 1):        for j in range(n-i):            time.sleep(0.05)            print(" ", end ="")        for k in range(2 * i-1):            time.sleep(0.05)            print("*", end ="")        print()equilateral_triangle(n)  print()  print("----------Square----------")  def square(n):          for i in range(1, n + 1):        for j in range(1, n + 1):            time.sleep(0.05)            print("*", end ="")        print()square(n)  print()  print("----------Diamond----------")  def diamond(n):          cell = n//2 + 1    for i in range(1, cell + 1):         for j in range(cell-i):                 time.sleep(0.05)            print(" ", end ="")        for k in range(2 * i-1):            time.sleep(0.05)            print("*", end ="")        print()      for i in range(cell-1, 0, -1):        for j in range(cell-i):            time.sleep(0.05)            print(" ", end ="")                      for k in range(2 * i-1):            time.sleep(0.05)            print("*", end ="")        print()diamond(n)
Output :
----------Right Angled Triangle Type 1----------
*
**
***
****
*****

----------Right Angled Triangle Type 2----------
    *
   **
  ***
 ****
*****

----------Equilateral Triangle----------
    *
   ***
  *****
 *******
*********

----------Square----------
*****
*****
*****
*****
*****

----------Diamond----------
  *
 ***
*****
 ***
  *

nidhi_biet
pattern-printing
Articles
Python
Python Programs
pattern-printing
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GTest Framework
HQL | Introduction
Asymptotic Notations and how to calculate them
How to use gotoxy() in codeblocks?
Dockerizing a simple Django app
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Read JSON file using Python
Tryit Editor v3.6 - Show React

import ReactDOM from "react-dom/client";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Layout from "./pages/Layout";
import Home from "./pages/Home";
import Blogs from "./pages/Blogs";
import Contact from "./pages/Contact";
import NoPage from "./pages/NoPage";

export default function App() {
  return (
    <BrowserRouter>
      <Routes>
        <Route path="/" element={<Layout />}>
          <Route index element={<Home />} />
          <Route path="blogs" element={<Blogs />} />
          <Route path="contact" element={<Contact />} />
          <Route path="*" element={<NoPage />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);




<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport"
      content="width=device-width, initial-scale=1" />
A data structure for n elements and O(1) operations - GeeksforGeeks

08 May, 2017
Propose a data structure for the following:The data structure would hold elements from 0 to n-1. There is no order on the elements (no ascending/descending order requirement)
The complexity of the operations should be as follows:* Insertion of an element – O(1)* Deletion of an element – O(1)* Finding an element – O(1)
We strongly recommend to minimize the browser and try this yourself first.
A boolean array works here. Array will have value ‘true’ at ith index if i is present, and ‘false’ if absent.
Initialization:We create an array of size n and initialize all elements as absent.
void initialize(int n){  bool A[n];  for (int i = 0; i<n; i++)    A[i] = {0}; // or A[n] = {false};}
Insertion of an element:
void insert(unsigned i){   /* set the value at index i to true */   A[i] = 1; // Or A[i] = true;}
Deletion of an element:
void delete(unsigned i){  /* make the value at index i to 0 */  A[i] = 0;  // Or A[i] = false;}
Finding an element:
// Returns true if 'i' is present, else falsebool find(unsigned i){    return A[i];}
As an exercise, change the data structure so that it holds values from 1 to n instead of 0 to n-1.
This article is contributed by Sachin. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Arrays
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Window Sliding Technique
Trapping Rain Water
Building Heap from Array
Reversal algorithm for array rotation
Program to find sum of elements in a given array
Move all negative numbers to beginning and positive to end with constant extra space
Find duplicates in O(n) time and O(1) extra space | Set 1
Count pairs with given sum
Next Greater Element
Remove duplicates from sorted array
How to catch OverflowError Exception in Python?

When an arithmetic operation exceeds the limits of the variable type, an OverflowError is raised. Long integers allocate more space as values grow, so they end up raising MemoryError. Floating point exception handling is not standardized, however. Regular integers are converted to long values as needed.
Given code is rewritten to catch exception as follows
i=1
try:
f = 3.0**i
for i in range(100):
print i, f
f = f ** 2
except OverflowError as err:
print 'Overflowed after ', f, err
We get following OverflowError as output as follows
C:/Users/TutorialsPoint1/~scratch_1.py
Floating point values:
0 3.0
1 9.0
2 81.0
3 6561.0
4 43046721.0
5 1.85302018885e+15
6 3.43368382029e+30
7 1.17901845777e+61
8 1.39008452377e+122
9 1.93233498323e+244
Overflowed after 1.93233498323e+244 (34, 'Result too large')
Convert HTML table to array in JavaScript?

Get data from tag using find() and store that data into array using push(). Let’s say the following is our table −
<table id="details">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr><td>John</td><td>23</td>
<tr><td>David</td><td>26</td>
</tbody>
</table>
Let’s fetch the data from <td> and store in an array. Following is the complete code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<style>
   .notShown {
      display: none;
   }
</style>
<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>
</head>
<body>
<table id="details">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr><td>John</td><td>23</td>
<tr><td>David</td><td>26</td>
</tbody>
</table>
<script>
   var convertedIntoArray = [];
   $("table#details tr").each(function() {
      var rowDataArray = [];
      var actualData = $(this).find('td');
      if (actualData.length > 0) {
         actualData.each(function() {
            rowDataArray.push($(this).text());
         });
         convertedIntoArray.push(rowDataArray);
      }
   });
   console.log(convertedIntoArray);
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
Files Class writeString() Method in Java with Examples - GeeksforGeeks

05 Feb, 2021
The writeString() method of File Class in Java is used to write contents to the specified file.
Syntax:
Files.writeString(path, string, options)
Parameters: 
path – File path with data type as Path
string – a specified string which will enter in the file with return type String.
options – Different options to enter the string in the file. Like append the string to the file, overwrite everything in the file with the current string, etc
Return Value: This method does not return any value.
Below are two overloaded forms of the writeString() method.
public static Path writeString​(Path path, CharSequence csq, OpenOption... options) throws IOException
public static Path writeString​(Path path, CharSequence csq, Charset cs, OpenOption... options) throws IOException
UTF-8 charset is used to write the content to file in the first method.
The second method does the same using the specified charset.
How the file is opened is specified in Options.
Below is the implementation of the problem statement:
Java
// Implementation of writeString() method in Javaimport java.io.IOException;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;import java.nio.file.StandardOpenOption;  public class GFG {    public static void main(String[] args)    {        // Initializing file Path with some conditions        Path filePath            = Paths.get("/home/mayur/", "temp", "gfg.txt");          try {            // Write content to file            Files.writeString(filePath, "Hello from GFG !!",                              StandardOpenOption.APPEND);              // Verify file content            String content = Files.readString(filePath);              System.out.println(content);        }        catch (IOException e) {            e.printStackTrace();        }    }}
Output:
Hello from GFG ! !
output File
Java-File Class
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Different ways of Reading a text file in Java
Constructors in Java
Stream In Java
Generics in Java
Exceptions in Java
Convert a String to Character array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Using SAP ABAP, how can I read content of CSV files in a directory to an internal table?

There are many functions that can be used to read csv however many are broken and read part of content. You need to go through each file and then process the file content. I would prefer to perform this manually.
You can use the READ DATASET to read data from a file on the application server. Below is the syntax:
READ DATASET <dsn> INTO <f> [LENGTH <len>].
Below is SAP documentation link that you can use to know more about reading data from files:
SAP Documentation
Incase you are using binary mode, you can use LENGTH to find the length of data transferred to <f>. The value of variable length is set by system in <len> as below:
DATA FNAME(60) VALUE 'file'.
DATA: TEXT1(10) VALUE 'helloworld',
      TEXT3(5),
      LENG TYPE I.
OPEN DATASET FNAME FOR OUTPUT IN BINARY MODE.
TRANSFER TEXT1 TO FNAME.
CLOSE DATASET FNAME.
OPEN DATASET FNAME FOR INPUT IN BINARY MODE.
DO.
  READ DATASET FNAME INTO TEXT2 LENGTH LENG.
  WRITE: / SY-SUBRC, TEXT2, LENG.
  IF SY-SUBRC <> 0.
    EXIT.
  ENDIF.
ENDDO.
CLOSE DATASET FNAME.
Fade in tab with Bootstrap

Use the .in class in Bootstrap to fade in the tab.
You can try to run the following code to fade in tab −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h2>Tutorials Website</h2>
         <p>The following is our learning content:</p>
         <ul class = "nav nav-tabs">
            <li class="active"><a data-toggle = "tab" href = "#home">Home</a></li>
            <li><a data-toggle = "tab" href = "#two">About</a></li>
            <li><a data-toggle = "tab" href = "#three">Product</a></li>
         </ul>
         <div class = "tab-content">
            <div id = "home" class="tab-pane in active">
               <h2>Home</h2>
               <p>This is demo text!</p>
            </div>
            <div id = "two" class="tab-pane fade">
               <h2>About</h2>
               <p>This is demo text!</p>
            </div>
            <div id = "three" class="tab-pane fade">
               <h2>Product</h2>
               <p>This is demo text!</p>
            </div>
         </div>
      </div>
   </body>
</html>
DateTime.AddMonths() Method in C# - GeeksforGeeks

18 Jan, 2019
This method is used to return a new DateTime that adds the specified number of months to the value of this instance.
Syntax:
public DateTime AddMonths (int months);
Here, months is the number of months. The months parameter can be negative or positive.
Return Value: This method returns an object whose value is the sum of the date and time represented by this instance and months.
Exception: This method will throw ArgumentOutOfRangeException if the resulting DateTime is less than MinValue or greater than MaxValue or months is less than -120, 000 or greater than 120, 000.
Below programs illustrate the use of the above-discussed method:
Example 1:
// C# program to demonstrate the// DateTime.AddMonths(Int32) Methodusing System;  class GFG {  // Main Methodpublic static void Main(){      // Creating a DateTime object    DateTime d1 = new DateTime(2018, 4, 17);      for (int i = 0; i <= 10; i++)    {          // using the method        Console.WriteLine(d1.AddMonths(i).ToString("d"));              }          Console.WriteLine("In Leap Years:");          // Creating a DateTime object    // by taking a leap year    // It is 31st March 2016    DateTime d2 = new DateTime(2016, 03, 31);          // taking a month value    int m = 1;          // using the method    // Result will be 30 April 2016    Console.WriteLine(d2.AddMonths(m).ToString("d"));            }}
Output:
04/17/2018
05/17/2018
06/17/2018
07/17/2018
08/17/2018
09/17/2018
10/17/2018
11/17/2018
12/17/2018
01/17/2019
02/17/2019
In Leap Years:
04/30/2016

Example 2:
// C# program to demonstrate the// DateTime.AddMonths(Int32) Methodusing System;  class GFG {  // Main Methodpublic static void Main(){      // Creating a DateTime object    // taking MaxValue    DateTime d1 = DateTime.MaxValue;      // taking a month MaxValue    int m = 12005;      // using the method will     // give an runtime error    // as months parameter is    // greater than 12000    Console.WriteLine(d1.AddMonths(m).ToString("d"));}}
Runtime Error:
Unhandled Exception:System.ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.Parameter name: months
Note:
This method does not change the value of this DateTime object. Instead, it returns a new DateTime object whose value is the result of this operation.
This calculates the resulting month and year, taking into account leap years and the number of days in a month, then adjusts the day part of the resulting DateTime object.
The time-of-day part of the resulting DateTime object remains the same as this instance.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.addmonths?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | Method Overriding
C# | Class and Object
Difference between Ref and Out keywords in C#
C# | Constructors
Introduction to .NET Framework
Extension Method in C#
C# | Abstract Classes
C# | Delegates
C# | Data Types
How to implement an instance method of an arbitrary object using method reference in Java?

A method reference is a new feature in Java 8, which is related to Lambda Expression. It can allow us to reference constructors or methods without executing them. The method references and lambda expressions are similar in that they both require a target type that consists of a compatible functional interface.
Class :: instanceMethodName
import java.util.*;
import java.util.function.*;

public class ArbitraryObjectMethodRefTest {
   public static void main(String[] args) {
      List<Person> persons = new ArrayList<Person>();
      persons.add(new Person("Raja", 30));
      persons.add(new Person("Jai", 25));
      persons.add(new Person("Adithya", 20));
      persons.add(new Person("Surya", 35));
      persons.add(new Person("Ravi", 32));
      List ages = ArbitraryObjectMethodRefTest.listAllAges(persons, Person :: getAge);
      System.out.println("Printing out all ages: \n" + ages);
   }
   private static List listAllAges(List person, Function<Person, Integer> f) {
      List result = new ArrayList();
      person.forEach(x -> result.add(f.apply((Person)x)));
      return result;
   }
   private static class Person {
      private final String name;
      private final int age;
      public Person(String name, int age) {
         this.name = name;
         this.age = age;
      }
      public String getName() {
         return name;
      }
      public int getAge() {
         return age;
      }
   }
}
Printing out all ages:
[30, 25, 20, 35, 32]
Composite Design Pattern in C++

Composite pattern is used where we need to treat a group of objects in similar way as a single object. Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchy. This type of design pattern comes under structural pattern as this pattern creates a tree structure of group of objects.
This pattern creates a class that contains group of its own objects. This class provides ways to modify its group of same objects.
We are demonstrating use of composite pattern via following example in which we will show employees hierarchy of an organization.
Here we can see the composite and leaf both classes are implementing the component. The important part is the composite class, this is also containing the component objects shown by the composition relationship.
#include <iostream>
#include <vector>
using namespace std;
class PageObject {
   public:
      virtual void addItem(PageObject a) { }
      virtual void removeItem() { }
      virtual void deleteItem(PageObject a) { }
};
class Page : public PageObject {
   public:
      void addItem(PageObject a) {
      cout << "Item added into the page" << endl;
   }
   void removeItem() {
      cout << "Item Removed from page" << endl;
   }
   void deleteItem(PageObject a) {
      cout << "Item Deleted from Page" << endl;
   }
};
class Copy : public PageObject {
   vector<PageObject> copyPages;
   public:
      void AddElement(PageObject a) {
         copyPages.push_back(a);
      }
      void addItem(PageObject a) {
         cout << "Item added to the copy" << endl;
      }
      void removeItem() {
         cout << "Item removed from the copy" << endl;
      }
      void deleteItem(PageObject a) {
         cout << "Item deleted from the copy";
      }
};
int main() {
   Page p1;
   Page p2;
   Copy myCopy;
   myCopy.AddElement(p1);
   myCopy.AddElement(p2);
   myCopy.addItem(p1);
   p1.addItem(p2);
   myCopy.removeItem();
   p2.removeItem();
}
Item added to the copy
Item added into the page
Item removed from the copy
Item Removed from page
Angular 10 formatNumber() Method - GeeksforGeeks

02 Jun, 2021
In this article, we are going to see what is formatNumber in Angular 10 and how to use it.
formatNumber is used to format a number based on our requirement in decimal form.
Syntax:
formatNumber(value, locale, digitsInfo)
Parameters:
value: The number to format.
locale: A locale code for the locale format.
digitsInfo: Decimal representation options.
 
Return Value:
string: the formatted text string.
NgModule: Module used by formatNumber is:
CommonModule
Approach: 
Create the Angular app to be used.
In app.module.ts import LOCALE_ID because we need locale to be imported for using get formatNumber.import { LOCALE_ID, NgModule } from '@angular/core';
import { LOCALE_ID, NgModule } from '@angular/core';
In app.component.ts import formatNumber and LOCALE_ID
inject LOCALE_ID as a public variable.
In app.component.html show the local variable using string interpolation
Serve the angular app using ng serve to see the output.
Example 1:
app.component.ts
import {  formatNumber }  from '@angular/common';  import {Component,  Inject,  LOCALE_ID }  from '@angular/core';  @Component({selector: 'app-root',templateUrl: './app.component.html'})export class AppComponent {curr = formatNumber(1000,this.locale,          '7.1-5');constructor(  @Inject(LOCALE_ID) public locale: string,){}}
app.component.html
<h1>  GeeksforGeeks</h1>  <p>Locale Number is : {{curr}}</p>
Output:
Example 2:
app.component.ts
import {  formatNumber }  from '@angular/common';  import {Component,  Inject,  LOCALE_ID }  from '@angular/core';  @Component({selector: 'app-root',templateUrl: './app.component.html'})export class AppComponent {curr = formatNumber(100,this.locale,          '2.1-5');constructor(  @Inject(LOCALE_ID) public locale: string,){}}
app.component.html
<h1>  GeeksforGeeks</h1>  <p>Locale Number is : {{curr}}</p>
Output:
Example 3:
app.component.ts
import {  formatNumber }  from '@angular/common';  import {Component,  Inject,  LOCALE_ID }  from '@angular/core';  @Component({selector: 'app-root',templateUrl: './app.component.html'})export class AppComponent {curr = formatNumber(3234,this.locale,          '3.1-4');constructor(  @Inject(LOCALE_ID) public locale: string,){}}
app.component.html
<h1>  GeeksforGeeks</h1>  <p>Locale Number is : {{curr}}</p>
Output:
Reference: https://angular.io/api/common/formatNumber
Angular10
AngularJS-Directives
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Angular Libraries For Web Developers
How to use <mat-chip-list> and <mat-chip> in Angular Material ?
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular 10 (blur) Event
Angular PrimeNG Dropdown Component
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Deep Q-Learning - GeeksforGeeks

18 Jun, 2019
Prerequisites: Q-Learning
The process of Q-Learning creates an exact matrix for the working agent which it can “refer to” to maximize its reward in the long run. Although this approach is not wrong in itself, this is only practical for very small environments and quickly loses it’s feasibility when the number of states and actions in the environment increases.
The solution for the above problem comes from the realization that the values in the matrix only have relative importance ie the values only have importance with respect to the other values. Thus, this thinking leads us to Deep Q-Learning which uses a deep neural network to approximate the values. This approximation of values does not hurt as long as the relative importance is preserved.
The basic working step for Deep Q-Learning is that the initial state is fed into the neural network and it returns the Q-value of all possible actions as on output.
The difference between Q-Learning and Deep Q-Learning can be illustrated as follows:-
Pseudo Code:
Initialize  for all pairs (s,a)
s = initial state
k = 0
while(convergence is not achieved)
{
    simulate action a and reach state s'
    if(s' is a terminal state)
    {
        target = R(s,a,s')
    }
    else
    {
        target = R(s,a,s') + 
    }
    
    s = s'
}

Observe that in the equation target = R(s,a,s’) + , the term is a variable term. Therefore in this process, the target for the neural network is variable unlike other typical Deep Learning processes where the target is stationary.
This problem is overcome by having two neural networks instead of one. One neural network is used to adjust the parameters of the network and the other is used for computing the target and which has the same architecture as the first network but has frozen parameters. After an x number of iterations in the primary network, the parameters are copied to the target network.
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decision Tree
Python | Decision tree implementation
Search Algorithms in AI
Decision Tree Introduction with example
ML | Underfitting and Overfitting
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
C++ Program for Common Divisors of Two Numbers - GeeksforGeeks

04 Dec, 2018
Given two integer numbers, the task is to find the count of all common divisors of given numbers.
Input : a = 12, b = 24
Output: 6
// all common divisors are 1, 2, 3, 
// 4, 6 and 12

Input : a = 3, b = 17
Output: 1
// all common divisors are 1

Input : a = 20, b = 36
Output: 3
// all common divisors are 1, 2, 4

// C++ implementation of program#include <bits/stdc++.h>using namespace std;  // Function to calculate gcd of two numbersint gcd(int a, int b){    if (a == 0)        return b;    return gcd(b % a, a);}  // Function to calculate all common divisors// of two given numbers// a, b --> input integer numbersint commDiv(int a, int b){    // find gcd of a, b    int n = gcd(a, b);      // Count divisors of n.    int result = 0;    for (int i = 1; i <= sqrt(n); i++) {        // if 'i' is factor of n        if (n % i == 0) {            // check if divisors are equal            if (n / i == i)                result += 1;            else                result += 2;        }    }    return result;}  // Driver program to run the caseint main(){    int a = 12, b = 24;    cout << commDiv(a, b);    return 0;}
6

Please refer complete article on Common Divisors of Two Numbers for more details!
divisors
GCD-LCM
C++ Programs
Mathematical
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Passing a function as a parameter in C++
Program to implement Singly Linked List in C++ using class
Const keyword in C++
cout in C++
Dynamic _Cast in C++
Program for Fibonacci numbers
Write a program to print all permutations of a given string
C++ Data Types
Set in C++ Standard Template Library (STL)
Coin Change | DP-7
Teradata - Views

Views are database objects that are built by the query. Views can be built using a single table or multiple tables by way of join. Their definition is stored permanently in data dictionary but they don't store copy of the data. Data for the view is built dynamically.
A view may contain a subset of rows of the table or a subset of columns of the table.
Views are created using CREATE VIEW statement.
Following is the syntax for creating a view.
CREATE/REPLACE VIEW <viewname> 
AS  
<select query>; 

Consider the following Employee table.
The following example creates a view on Employee table.
CREATE VIEW Employee_View 
AS 
SELECT 
EmployeeNo, 
FirstName, 
LastName, 
FROM  
Employee;
You can use regular SELECT statement to retrieve data from Views.
The following example retrieves the records from Employee_View;
SELECT EmployeeNo, FirstName, LastName FROM Employee_View;
When the above query is executed, it produces the following output.
*** Query completed. 5 rows found. 3 columns returned. 
*** Total elapsed time was 1 second.  
 EmployeeNo            FirstName                       LastName 
-----------  ------------------------------  --------------------------- 
    101                  Mike                           James 
    104                  Alex                           Stuart 
    102                  Robert                         Williams 
    105                  Robert                         James 
    103                  Peter                          Paul 

An existing view can be modified using REPLACE VIEW statement.
Following is the syntax to modify a view.
REPLACE VIEW <viewname> 
AS  
<select query>;

The following example modifies the view Employee_View for adding additional columns.
REPLACE VIEW Employee_View 
AS 
SELECT 
EmployeeNo, 
FirstName, 
BirthDate,
JoinedDate 
DepartmentNo 
FROM  
Employee; 
An existing view can be dropped using DROP VIEW statement.
Following is the syntax of DROP VIEW.
DROP VIEW <viewname>; 

Following is an example to drop the view Employee_View.
DROP VIEW Employee_View; 
Views provide additional level of security by restricting the rows or columns of a table.
Views provide additional level of security by restricting the rows or columns of a table.
Users can be given access only to views instead of base tables.
Users can be given access only to views instead of base tables.
Simplifies the use of multiple tables by pre-joining them using Views.
Simplifies the use of multiple tables by pre-joining them using Views.
 Print
 Add Notes
 Bookmark this page
Swift - Break Statement

The break statement in C programming language has the following two usages −
When a break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
When a break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.
It can be used to terminate a case in switch statement (covered in the next chapter).
It can be used to terminate a case in switch statement (covered in the next chapter).
If you are using nested loops (i.e., one loop inside another loop), then the break statement will stop the execution of the innermost loop and start executing the next line of the code after the block.
The syntax for a break statement in Swift 4 is as follows −
break

var index = 10

repeat {
   index = index + 1
   if( index == 15 ){
      break
   }
   print( "Value of index is \(index)")
} while index < 20
When the above code is compiled and executed, it produces the following result −
Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14


    38 Lectures 
     1 hours 

 Ashish Sharma

    13 Lectures 
     2 hours 

 Three Millennials

    7 Lectures 
     1 hours 

 Three Millennials

    22 Lectures 
     1 hours 

 Frahaan Hussain

    12 Lectures 
     39 mins

 Devasena Rajendran

    40 Lectures 
     2.5 hours 

 Grant Klimaytys
 Print
 Add Notes
 Bookmark this page
How will you keep the CURSOR open after firing COMMIT in a COBOL-DB2 program?

Whenever we issue a COMMIT statement, all the open cursors will get closed. This is a very common case when we have to frequently use the commit statement after a UPDATE while working with a cursor. In this case we can use the “WITH HOLD” clause during the cursor declaration.
The “WITH HOLD” clause will keep the cursor open even after firing the COMMIT statement. We can give the “WITH HOLD” clause in the following way.
EXEC SQL
      DECLARE ORDER_CUR CURSOR WITH HOLD FOR
         SELECT ORDER_ID, TRANSACTION_ID FROM ORDERS
            WHERE ORDER_DATE = ‘2020-07-28’
END-EXEC
Tryit Editor v3.7

HTML Input attributes
Tryit: The autocomplete attribute
How to merge arrays and preserve the keys in PHP ? - GeeksforGeeks

07 Jul, 2020
Arrays in PHP are created using array() function. Arrays are variable that can hold more than one values at a time. There are three types of arrays:
Indexed ArraysAssociative ArraysMultidimensional Arrays
Indexed Arrays
Associative Arrays
Multidimensional Arrays
Each and every value in an array has a name or identity attached to it used to access that element called keys.
To merge the two arrays array_merge() function works fine but it does not preserve the keys. Instead array_replace() function helps to merge two arrays while preserving their key.
Program 1: This example using array_replace() function to merge two arrays and preserve the keys.
<?php  // Create first associative array$array1 = array(    1 => 'Welcome',    2 => 'To');  // Create second associative array$array2 = array(    3 => 'Geeks',    4 => 'For',    5 => 'Geeks');  // Use array_replace() function to// merge the two array while// preserving the keysprint_r(array_replace($array1, $array2));?>
Array
(
    [1] => Welcome
    [2] => To
    [3] => Geeks
    [4] => For
    [5] => Geeks
)

Program 1: This example using array_replace_recursive() function to merge two arrays and preserve the keys.
<?php  // Create first associative array$array1 = array(    1 => 'Welcome',    2 => 'To');  // Create second associative array$array2 = array(    3 => 'Geeks',    4 => 'For',    5 => 'Geeks');  // Use array_replace() function to// merge the two array while// preserving the keysprint_r(array_replace_recursive($array1, $array2));?>
Array
(
    [1] => Welcome
    [2] => To
    [3] => Geeks
    [4] => For
    [5] => Geeks
)

PHP-Misc
Picked
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
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 ?
How to check whether an array is empty using PHP?
How to receive JSON POST with PHP ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
C program to input an array from a sequence of space-separated integers - GeeksforGeeks

15 Jul, 2021
Given a string S consisting of space-separated integers, the task is to write a C program to take the integers as input from the string S and store them in an array arr[].
Examples:
Input: S = “1 2 3 4”Output: {1, 2, 3, 4}
Input: S = “32 12”Output: {32, 12}
Approach: The idea is to solve the given problem is to use getchar() function to check if a ‘\n’ (newline) occurs is found while taking input and then stop the input. Follow the step below to solve the given problem:
Initialize a variable, say count, which is used to store the index of the array element.
Initialize an array arr[] of size 106 to store the elements into the array.
Iterate using a do-while loop until newLine occurs and perform the following steps:Store the current value at index count as scanf(“%d “, &arr[count]); and increment the value of count.If the next character is not endline, then continue. Otherwise, break out of the loop.
Store the current value at index count as scanf(“%d “, &arr[count]); and increment the value of count.
If the next character is not endline, then continue. Otherwise, break out of the loop.
After completing the above steps, print the elements stored in the array.
Below is the implementation of the above approach:
C
// C program for the above approach#include <stdio.h> // Driver Codeint main(){    // Stores the index where the    // element is to be inserted    int count = 0;     // Initialize an array    int a[1000000];     // Perform a do-while loop    do {         // Take input at position count        // and increment count        scanf("%d", &a[count++]);         // If '\n' (newline) has occurred        // or the whole array is filled,        // then exit the loop         // Otherwise, continue    } while (getchar() != '\n' && count < 100);     // Resize the array size to count    a[count];     // Print the array elements    for (int i = 0; i < count; i++) {        printf("%d, ", a[i]);    }     return 0;}
Output:
akshaysingh98088
arorakashish0911
c-input-output
Arrays
C Programs
Strings
Technical Scripter
Arrays
Strings
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Window Sliding Technique
Trapping Rain Water
Reversal algorithm for array rotation
Building Heap from Array
Move all negative numbers to beginning and positive to end with constant extra space
Strings in C
Arrow operator -> in C/C++ with Examples
UDP Server-Client implementation in C
C Program to read contents of Whole File
Header files in C/C++ and its uses
Find all pairs that sum to a target value in JavaScript

We are required to write a JavaScript function that takes in an array of numbers as the first argument and a target sum number as the second argument.
The function should return an array of all those pair of numbers from the array that add up to the target sum specified by the second argument.
We will use a map object to check for the pairs and push the desired pairs to a new array.
The code for this will be −
const arr = [7, 0, -4, 5, 2, 3];
const allTwoSum = (arr, target) => {
   const map = {};
   const results = [];
   for (let i = 0; i < arr.length; i++) {
      if (map[arr[i]]) {
         results.push([target − arr[i], arr[i]]);
         continue;
      };
      map[target − arr[i]] = true;
   };
   return results;
};
console.log(allTwoSum(arr, 5));
And the output in the console will be −
[ [ 0, 5 ], [ 2, 3 ] ]
What is a copy constructor in C#?

Copy Constructor creates an object by copying variables from another object.
Let us see an example −
using System;
namespace Demo {
   class Student {
      private string name;
      private int rank;

      public Student(Student s) {
         name = s.name;
         rank = s.rank;
      }

      public Student(string name, int rank) {
         this.name = name;
         this.rank = rank;
      }

      public string Display {
         get {
            return " Student " + name +" got Rank "+ rank.ToString();
         }
      }
   }

   class StudentInfo {
      static void Main() {
         Student s1 = new Student("Jack", 2);

         // copy constructor
         Student s2 = new Student(s1);

         // display
         Console.WriteLine(s2.Display);
         Console.ReadLine();
      }
   }
}
Above we saw, firstly we declared a copy constructor −
public Student(Student s)
Then a new object is created for the Student class −
Student s1 = new Student("Jack", 2);
Now, the s1 object is copied to a new object s2 −
Student s2 = new Student(s1);
This is what we call copy constructor.
MySQL Tryit Editor v1.0

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers
ON Orders.CustomerID=Customers.CustomerID;
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
GATE | GATE CS 2019 | Question 49 - GeeksforGeeks

02 Dec, 2019
Consider the following statements:
I. The smallest element in a max-heap is always at a leaf node.
II. The second largest element in a max-heap is always a child of the root node.
III. A max-heap can be constructed from a binary search tree in Θ(n) time.
IV. A binary search tree can be constructed from a max-heap in Θ(n) time.
Which of the above statements is/are TRUE?(A) II, III and IV(B) I, II and III(C) I, III and IV(D) I, II and IVAnswer: (B)Explanation: Statement (I) is correct. In a max heap, the smallest element is always present at a leaf node. So we need to check for all leaf nodes for the minimum value. Worst case complexity will be O(n)
         12
        /  \
      /      \
    8         7
   / \        / \
 /     \    /     \
2      3   4       5 
Statement (II) is also correct, otherwise it will not satisfy max-heap property.
Statement (III) is also correct, as build-heap always takes Θ(n) time, (Refer: Convert BST to Max Heap).
Statement (IV) is false, because construction of binary search tree from max-heap will take O(nlogn) time.
So, option (B) is correct.
Quiz of this Question
nitesh5375
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90