code-rag-bench/online-tutorials huggingface dataset:
Converting JSON text to JavaScript Object - GeeksforGeeks

19 Feb, 2019
Pre-requisite: JavaScript JSONJSON (JavaScript Object Notation) is a lightweight data-interchange format. As its name suggests, JSON is derived from the JavaScript programming language, but it’s available for use by many languages including Python, Ruby, PHP, and Java and hence, it can be said as language-independent. For humans, it is easy to read and write and for machines, it is easy to parse and generate. It is very useful for storing and exchanging data.
A JSON object is a key-value data format that is typically rendered in curly braces. JSON object consist of curly braces ( { } ) at the either ends and have key-value pairs inside the braces. Each key-value pair inside braces are separated by comma (, ). JSON object looks something like this :
{
    "key":"value",
    "key":"value",
    "key":"value",
}

Example for a JSON object :
{
    "rollno":101",
    "name":"Mayank",
    "age":20,
}

JSON text/object can be converted into Javascript object using the function JSON.parse().
var object1 = JSON.parse('{"rollno":101, "name":"Mayank", "age":20}');
For getting the value of any key from a Javascript object, we can use the values as: object1.rollno
If we pass a invalid JSON text to the function JSON.parse(), it will generate error (no output is displayed when using in tag of HTML).
Examples : Here, in example, the JSON text ‘jsonobj’ have 3 key-value pair. Each of the pairs were able to be accessed by the Javascript object ‘obj’ using dot ( . ). ‘obj’ was a javascript object which was the result of the function JSON.parse().
var jsonobj = ‘{ “name”:”Brendan Eich”, “designerof”:”Javascript”, “bornin”:”1961′′ }’;var obj = JSON.parse(jsonobj);print(“JSON Object/Text : “);print(obj.name + “, who was born in ” + obj.bornin + “, was the designer of ” + obj.designerof);print(“Use of Javascript object : “);print(jsonobj);
<html><body>  <h2>Converting JSON Text into Javascript Object</h2><b>JSON Object :</b><p id="demo"></p><b>Use of Javascript object :</b><p id="demo1"></p>  <script>var jsonobj ='{ "name":"Brendan Eich","designerof":"Javascript","bornin":"1961" }';  // Here we convert JSON to objectvar obj = JSON.parse(jsonobj);  document.getElementById("demo1").innerHTML =                      obj.name + ", who was born in "                     + obj.bornin + ", was the designer of "                     + obj.designerof;document.getElementById("demo").innerHTML =jsonobj;</script></body></html>
JavaScript-Misc
JSON
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
How to append HTML code to a div using JavaScript ?
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Count Elements x and x+1 Present in List in Python

Suppose we have a list of numbers called nums, we have to find the number of elements x
there are such that x + 1 exists as well.
So, if the input is like [2, 3, 3, 4, 8], then the output will be 3
To solve this, we will follow these steps −
s := make a set by inserting elements present in nums
count := 0
for each i in nums, doif i+1 in s, thencount := count + 1
if i+1 in s, thencount := count + 1
count := count + 1
return count
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, nums):
      s = set(nums)
      count = 0
      for i in nums:
         if i+1 in s:
            count += 1
      return count
ob = Solution()
nums = [2, 3, 3, 4, 8]
print(ob.solve(nums))
[2, 3, 3, 4, 8]
3
HTML <optgroup> Tag - GeeksforGeeks

17 Mar, 2022
This tag is used to create a group of the same category options in a drop-down list. The <optgroup> tag is required when there is a long list of the item exists.Syntax:
<optgroup>
      <option>..</option>
        .
        .
</optgroup>
Attributes:
label: It is used to specify the label for an optgroup.
disabled: It is used to disable the option-group in a list.
Example 1: 
html
<!DOCTYPE html><html> <body>    <h1>GeeksforGeeks</h1>    <h2>HTML optgroup Tag</h2>    <select>        <!-- optgroup tag starts -->            <optgroup label="Programming Languages">                <option value="C">C</option>                <option value="C++">C++</option>                <option value="Java">Java</option>            </optgroup>            <optgroup label="Scripting Language">                <option value="JavaScript">JavaScript</option>                <option value="PHP">PHP</option>                <option value="Shell">Shell</option>            </optgroup>        <!-- optgroup tag ends     -->        </select></body> </html>
Output:  
Example 2: 
html
<!DOCTYPE html><html> <body>    <h1>GeeksforGeeks</h1>    <h2>HTML optgroup Tag</h2>    <select>        <!-- optgroup tag starts -->            <optgroup label="Programming Languages">                <option value="C">C</option>                <option value="C++">C++</option>                <option value="Java">Java</option>            </optgroup>            <optgroup label="Scripting Language" disabled>                <option value="JavaScript">JavaScript</option>                <option value="PHP">PHP</option>                <option value="Shell">Shell</option>            </optgroup>        <!-- optgroup tag ends -->        </select></body> </html>
Output:  
Supported Browser: 
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
Akanksha_Rai
ghoshsuman0129
HTML-Tags
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
How to reset or clear a form using JavaScript?

Reset or clear a form using JavaScript, with the reset() method. The reset method sets the values of all elements in a form like clicking the reset button. 
You can try to run the following code to reset a form using JavaScript −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Reset HTML form</title>
   </head>
   <body>
      <form id="newForm">
         Student Name<br><input type="text" name="sname"><br>
         Student Subject<br><input type="password" name="ssubject"><br>
         <input type="button" onclick="newFunction()" value="Reset">
      </form>
      <script>
         function newFunction() {
            document.getElementById("newForm").reset();
         }
      </script>
   </body>
</html>
CSS | cubic-bezier() Function - GeeksforGeeks

04 Jan, 2022
The cubic-bezier() function is an inbuilt function in CSS which is used to defines a Cubic Bezier curve. A Bezier curve is a mathematically defined curve used in two-dimensional graphic applications like adobe illustrator, inkscape etc. The curve is defined by four points: the initial position and the terminating position i.e P0 and P3 respectively (which are called “anchors”) and two separate middle points i.e P1 and P2(which are called “handles”) in our example. Bezier curves are frequently used in computer graphics, animation, modeling etc.Syntax:  
cubic-bezier( x1, y1, x2, y2 )
Parameters: This function accepts four parameter which is mandatory. It contains a numeric value and the value of x1 and x2 lies between 0 to 1.Below program illustrates the cubic-bezier() function in CSS:Program:  
html
<!DOCTYPE html><html>    <head>        <title>cubic-bezier function</title>        <style>            .geeks {                width: 150px;                height: 80px;                background: green;                transition: width 5s;                transition-timing-function: cubic-bezier(0.3, 0.7, 1.0, 0.1);            }                         div:hover {                width:300px;            }            .gfg {                font-size:40px;                font-weight:bold;                color:green;                text-align:center;            }            h1 {                text-align:center;            }        </style>    </head>    <body>        <div class = "gfg">GeeksforGeeks</div>        <h1>The cubic-bezier() Function</h1>        <div class = "geeks"></div>    </body></html>
Output:  
Supported Browser:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ysachin2314
clintra
CSS-Functions
Functions
CSS
HTML
Web Technologies
Functions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Java labelled for loop

Following program is using labeled for loops.
Live Demo
public class Tester {
   public static void main(String args[]) {
     
      first:
         for (int i = 0; i < 3; i++) {
            for (int j = 0; j< 3; j++){
               if(i == 1){
                  continue first;
               }      
               System.out.print(" [i = " + i + ", j = " + j + "] ");
            }
         }
     
         System.out.println();

      second:
         for (int i = 0; i < 3; i++) {
            for (int j = 0; j< 3; j++){
               if(i == 1){
                  break second;
               }
 
               System.out.print(" [i = " + i + ", j = " + j + "] ");
            }
         }
   }
}
first is the label for first outermost for loop and continue first cause the loop to skip print statement if i = 1;
second is the label for second outermost for loop and continue second cause the loop to break the loop.
GATE | GATE CS 2011 | Question 32 - GeeksforGeeks

28 Jun, 2021
Consider a database table T containing two columns X and Y each of type integer. After the creation of the table, one record (X=1, Y=1) is inserted in the table.
Let MX and My denote the respective maximum values of X and Y among all records in the table at any point in time. Using MX and MY, new records are inserted in the table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion, values of MX and MY change. What will be the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;

(A) 127(B) 255(C) 129(D) 257Answer: (A)Explanation: See Question 4 of https://www.geeksforgeeks.org/database-management-systems-set-4/
And question 30 of http://clweb.csa.iisc.ernet.in/rahulsharma/gate2011key.htmlQuiz of this Question
GATE-CS-2011
GATE-GATE CS 2011
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | GATE-CS-2007 | Question 64
How to Sort a String in Java alphabetically in Java?

The toCharArray() method of this class converts the String to a character array and returns it. To sort a string value alphabetically −
Get the required string.
Get the required string.
Convert the given string to a character array using the toCharArray() method.
Convert the given string to a character array using the toCharArray() method.
Sort the obtained array using the sort() method of the Arrays class.
Sort the obtained array using the sort() method of the Arrays class.
Convert the sorted array to String by passing it to the constructor of the String array.
Convert the sorted array to String by passing it to the constructor of the String array.
 Live Demo
import java.util.Arrays;
import java.util.Scanner;
public class SortingString {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a string value: ");
      String str = sc.nextLine();
      char charArray[] = str.toCharArray();
      Arrays.sort(charArray);
      System.out.println(new String(charArray));
   }
}
Enter a string value:
Tutorialspoint
Taiilnooprsttu
To sort the array manually −
Get the required string.
Get the required string.
Convert the given string to a character array using the toCharArray() method.
Convert the given string to a character array using the toCharArray() method.
Compare the first two elements of the array.
Compare the first two elements of the array.
If the first element is greater than the second swap them.
If the first element is greater than the second swap them.
Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.
Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.
Repeat this till the end of the array.
Repeat this till the end of the array.
 Live Demo
import java.util.Arrays;
import java.util.Scanner;
public class SortingString {
   public static void main(String args[]) {
      int temp, size;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a string value: ");
      String str = sc.nextLine();
      char charArray[] = str.toCharArray();
      size = charArray.length;
      for(int i = 0; i < size; i++ ) {
         for(int j = i+1; j < size; j++) {
            if(charArray[i]>charArray[j]) {
               temp = charArray[i];
               charArray[i] = charArray[j];
               charArray[j] = (char) temp;
            }
         }
      }
      System.out.println("Third largest element is: "+Arrays.toString(charArray));
   }
}
Enter a string value:
Tutorialspoint
Third largest element is: [T, a, i, i, l, n, o, o, p, r, s, t, t, u]
MySQL IF() to display custom YES or NO messages

Let us first create a table −
mysql> create table DemoTable1850
     (
     OrderStatus varchar(20)
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1850 values('Yes');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1850 values('No');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1850 values('Yes');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1850 values('Yes');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1850;
This will produce the following output −
+-------------+
| OrderStatus |
+-------------+
| Yes         |
| No          |
| Yes         |
| Yes         |
+-------------+
4 rows in set (0.00 sec)
Here is the query to implement IF() to display custom messages:
mysql> select if(OrderStatus='Yes','Order has been placed','Failed') as Status from DemoTable1850;
This will produce the following output −
+-----------------------+
| Status                |
+-----------------------+
| Order has been placed |
| Failed                |
| Order has been placed |
| Order has been placed |
+-----------------------+
4 rows in set (0.00 sec)
Removing item from array in MongoDB?

To remove item from array, use $pull in MongoDB. Let us create a collection with documents −
> db.demo224.insertOne({"ListOfTechnology":["Spring","Hibernate","Java"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3ee6d103d395bdc2134733")
}
> db.demo224.insertOne({"ListOfTechnology":["Groovy"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3ee6ec03d395bdc2134734")
}
Display all documents from a collection with the help of find() method −
> db.demo224.find();
This will produce the following output −
{ "_id" : ObjectId("5e3ee6d103d395bdc2134733"), "ListOfTechnology" : [ "Spring", "Hibernate", "Java" ] }
{ "_id" : ObjectId("5e3ee6ec03d395bdc2134734"), "ListOfTechnology" : [ "Groovy" ] }
Following is the query to remove item from array in MongoDB −
>db.demo224.update({_id:ObjectId("5e3ee6d103d395bdc2134733")},{$pull:{"ListOfTechnology":"Java"}});
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo224.find();
This will produce the following output −
{ "_id" : ObjectId("5e3ee6d103d395bdc2134733"), "ListOfTechnology" : [ "Spring", "Hibernate" ] }
{ "_id" : ObjectId("5e3ee6ec03d395bdc2134734"), "ListOfTechnology" : [ "Groovy" ] }
Get an element from a Stack in Java without removing it

The method java.util.Stack.peek() can be used to get an element from a Stack in Java without removing it. This method requires no parameters and it returns the element at the top of the stack. If the stack is empty, then the EmptyStackException is thrown.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.Stack;
public class Demo {
   public static void main (String args[]) {
      Stack stack = new Stack();
      stack.push("Amy");
      stack.push("John");
      stack.push("Mary");
      stack.push("Peter");
      stack.push("Susan");
      System.out.println("The stack elements are: " + stack);
      System.out.println("The element at the top of the stack is: " + stack.peek());
   }
}
The stack elements are: [Amy, John, Mary, Peter, Susan]
The element at the top of the stack is: Susan
Now let us understand the above program.
The Stack is created. Then Stack.push() method is used to add the elements to the stack. The stack is displayed and then the Stack.peek() method is used to return the element at the top of the stack and print it. A code snippet which demonstrates this is as follows −
Stack stack = new Stack();
stack.push("Amy");
stack.push("John");
stack.push("Mary");
stack.push("Peter");
stack.push("Susan");
System.out.println("The stack elements are: " + stack);
System.out.println("The element at the top of the stack is: " + stack.peek());
Pointer Arithmetic in C/C++

Pointer arithmetic is used to implement arithmetic operations like addition subtraction, increment etc. in C language. There are four pointer arithmetic such as addition, subtraction, increment and decrement. In 32-bit machine, it increments or decrement the value by 2 and it will add or subtract 2* number. In 64-bit machine, it increments or decrement the value by 4 and it will add or subtract 4* number.
Here is an example of pointer arithmetic in C language,
 Live Demo
#include<stdio.h>
int main() {
   int val = 28;
   int *pt;
   pt = &val;
   printf("Address of pointer : %u\n",pt);
   pt = pt + 5;
   printf("Addition to pointer : %u\n",pt);
   pt = pt - 5;
   printf("Subtraction from pointer : %u\n",pt);
   pt = pt + 1;
   printf("Increment to pointer : %u\n",pt);
   pt = pt - 1;
   printf("Decrement to pointer : %u\n",pt);
   return 0;
}
Address of pointer : 3938439860
Addition to pointer : 3938439880
Subtraction from pointer : 3938439860
Increment to pointer : 3938439864
Decrement to pointer : 3938439860
In the above program, the arithmetic operations (addition, subtraction etc.) are applied to the pointer variable *pt.
int *pt;
pt = &val;
printf("Address of pointer : %u\n",pt);
pt = pt + 5;
printf("Addition to pointer : %u\n",pt);
pt = pt - 5;
printf("Subtraction from pointer : %u\n",pt);
pt = pt + 1;
printf("Increment to pointer : %u\n",pt);
pt = pt - 1;
printf("Decrement to pointer : %u\n",pt);
What are undeclared and undefined variables in JavaScript? - GeeksforGeeks

26 Nov, 2019
Undefined: It occurs when a variable has been declared but has not been assigned with any value. Undefined is not a keyword.
Undeclared: It occurs when we try to access any variable that is not initialized or declared earlier using var or const keyword. If we use ‘typeof’ operator to get the value of an undeclared variable, we will face the runtime error with return value as “undefined”. The scope of the undeclared variables is always global.
For example:
Undefined:var geek;
undefined
console.log(geek) 

var geek;
undefined
console.log(geek) 

Undeclared://ReferenceError: myVariable is not defined
console.log(myVariable) 

//ReferenceError: myVariable is not defined
console.log(myVariable) 

Example 1: This example illustrate a situation where an undeclared variable is used.<script>function GFG(){//'use strict' verifies that no undeclared // variable is present in our code   'use strict';    x = "GeeksForGeeks";}   GFG(); //accessing the above function</script>Output:ReferenceError: x is not defined
<script>function GFG(){//'use strict' verifies that no undeclared // variable is present in our code   'use strict';    x = "GeeksForGeeks";}   GFG(); //accessing the above function</script>
Output:
ReferenceError: x is not defined
Example 2: This example checks whether a given variable is undefined or not.<!DOCTYPE html><html>  <body>    <style>        h1 {            color: green;        }    </style>      <h1>UNDEFINED OR NOT.</h1>      <button onclick="checkVar()">      Try it  </button>      <p id="gfg"></p>      <script>        function checkVar() {            if (typeof variable === "undefined") {                   string = "Variable is undefined";            } else {                   string = "Variable is defined";            }            document.getElementById("gfg").innerHTML =               string;        }    </script>  </body>  </html>Output:
<!DOCTYPE html><html>  <body>    <style>        h1 {            color: green;        }    </style>      <h1>UNDEFINED OR NOT.</h1>      <button onclick="checkVar()">      Try it  </button>      <p id="gfg"></p>      <script>        function checkVar() {            if (typeof variable === "undefined") {                   string = "Variable is undefined";            } else {                   string = "Variable is defined";            }            document.getElementById("gfg").innerHTML =               string;        }    </script>  </body>  </html>
Output:
shubham_singh
JavaScript-Misc
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
C# Program to Find the Index of Even Numbers using LINQ - GeeksforGeeks

28 Nov, 2021
Given an array, now our task is to find the index value of the even numbers present in the given array using LINQ. LINQ is known as Language Integrated Query and was introduced in .NET 3.5. It gives the power to .NET languages to generate queries to retrieve data from the data source. So to do this task we use the select() and where() methods of LINQ.
Example:
Input  : { 2, 3, 4, 5, 11 }
Output : Index:0 - Number: 2
         Index:2 - Number: 4
         
Input  : { 2, 3, 4, 5, 6, 23, 31 }
Output : Index:0 - Number: 2
         Index:2 - Number: 4
         Index:4 - Number: 6
Approach:
1. Create a list of integer type and add elements to it.
2. Get the index of the numbers present in the list.
var indexdata = data.Select((val, indexvalue) => new
                    { 
                        Data = val, 
                        IndexPosition = indexvalue
                    }).Where(n => n.Data % 2 == 0).Select(
                    result => new 
                    { 
                        Number = result.Data,
                        IndexPosition = result.IndexPosition 
                    });
3. Display the index and numbers.
foreach (var i in indexdata)
{
    Console.WriteLine("Index:" + i.IndexPosition + 
                      " - Number: " + i.Number);
}
Example:
C#
// C# program to find the index value of// the even numbers using LINQusing System;using System.Collections.Generic;using System.Linq;  class GfG{      static void Main(string[] args){          // Creating a list of integer type    List<int> data = new List<int>();          // Add elements to the list    data.Add(2);    data.Add(3);    data.Add(4);    data.Add(5);    data.Add(6);    data.Add(12);    data.Add(11);      // Get the index of numbers    var indexdata = data.Select((val, indexvalue) => new                    {                         Data = val,                         IndexPosition = indexvalue                    }).Where(n => n.Data % 2 == 0).Select(                    result => new                     {                         Number = result.Data,                        IndexPosition = result.IndexPosition                     });                          // Display the index and numbers    // of the even numbers from the array    foreach(var i in indexdata)    {        Console.WriteLine("Index Value:" + i.IndexPosition +                           " - Even Number: " + i.Number);    }}}
Output:
Index Value:0 - Even Number: 2
Index Value:2 - Even Number: 4
Index Value:4 - Even Number: 6
Index Value:5 - Even Number: 12
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Convert String to Character Array in C#
Socket Programming in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Program to find absolute value of a given number
Find all distinct subsets of a given set in C++

Here we will see how to display all distinct subsets of a given set. So if the set is {1, 2, 3}, then the subsets will be {}, {1}, {2}, {3}, {1, 2}, {2, 3}, {1, 3}, {1, 2, 3}. The set of all subsets is called power set. The power set has 2n elements.
We will loop through 0 to 2n (excluding), in each iteration we will check whether the ith bit in the current counter is set, then print ith element.
#include<iostream>
#include<cmath>
using namespace std;
void showPowerSet(char *set, int set_length) {
   unsigned int size = pow(2, set_length);
   for(int counter = 0; counter < size; counter++) {
      cout << "{";
      for(int j = 0; j < size; j++) {
         if(counter & (1<<j))
            cout << set[j] << " ";
         }
         cout << "}" << endl;
      }
   }
   int main() {
   char set[] = {'a','b','c'};
   showPowerSet(set, 3);
}
{}
{a }
{b }
{a b }
{c }
{a c }
{b c }
{a b c }
Java Program to check if the String contains only certain characters

The following is our string.
String str = "pqrst";
In the above string, we want to search for the following set of characters.
// set of characters to be searched
char[] chSearch = {'p', 'q', r'};
For this, loop through the length of the string and check every character in the string “str”. If the matching character from “chSearch” is found in the string, then it would be a success.
The following is an example.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = "pqrst";
      // characters to be searched
      char[] chSearch = {'p', 'q', 'r'};
      for (int i = 0; i < str.length(); i++) {
         char ch = str.charAt(i);
         for (int j = 0; j < chSearch.length; j++) {
            if (chSearch[j] == ch) {
               System.out.println("Character "+chSearch[j]+" found in string "+str);
            }
         }
      }
   }
}
Character p found in string pqrst
Character q found in string pqrst
Character r found in string pqrst
HTML | <body> vlink Attribute - GeeksforGeeks

23 Mar, 2022
The HTML <body> vlink Attribute is used to specify a color of a visited link in a Document.
Note : The HTML <body> vlink attribute is not supported by HTML5. Instead of using this attribute we can use CSS :visited pseudo-class selector.
Syntax:
<body vlink="color_name | hex_number | rgb_number">
Attribute Values:
color_name: It specifies the name of the color of the visited link.
hex_number: It specifies the color of the visited link in terms of hex code.
rgb_number: It specifies the color of the visited link in terms of rgb value
Example:
html
<!DOCTYPE html><html>  <head>    <title>        HTML body vlink Attribute    </title></head>  <!-- body tag starts here --><body vlink="red">    <center>        <h1>GeeksforGeeks</h1>        <h2>HTML <body> vlink Attribute</h2>                  <p>Click on a Below link</p>                  <a href="#">            It is a Computer Science portal For Geeks        </a>        <br>                  <p><a href="#">GeeksForGeeks</a></p>    </center></body><!-- body tag ends here -->  </html>
Output:
Supported Browsers: The browser supported by <body> vlink Attributeare listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
chhabradhanvi
HTML-Attributes
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Making a div vertically scrollable using CSS
How to Upload Image into Database and Display it using PHP ?
Build a Survey Form using HTML and CSS
CSS | Text Formatting
How to align content of a div to the bottom using CSS ?
Express.js express.Router() Function
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to set the default value for an HTML <select> element ?
Top 10 Angular Libraries For Web Developers
Number of times a string appears in another JavaScript

We are required to write a JavaScript function that takes in two strings and returns the count of the number of times the str1 appears in the str2.
The code for this will be −
const main = 'This is the is main is string';
const sub = 'is';
const countAppearances = (main, sub) => {
   const regex = new RegExp(sub, "g");
   let count = 0;
   main.replace(regex, (a, b) => {
      count++;
   });
   return count;
};
console.log(countAppearances(main, sub));
The output in the console −
4
How to Setup Julia Path to Environment Variable?

27 Feb, 2020
Environment variables basically define the behavior of the environment. They can affect the processes ongoing or the programs that are executed in the environment. The region from which this variable can be accessed or over which it is defined is termed as the scope of the variable.
In Julia, setting up the environment variable is very important because it enables Julia command-line to be started from anywhere in the system. Setting up Julia Environment can be done by following a few simple steps.
Step 1: Download Julia for Windows from the official site julialang.org and follow the instructions on How to install Julia on Windows? Step 2: After the installation is done, we need to set up the environment variable.Go to Control Panel -> System and Security -> SystemUnder Advanced System Setting option click on Environment Variables as shown below:
 Step 3: Now, we have to alter the “Path” variable under System variables so that it also contains the path to the Julia environment. Select the “Path” variable and click on the Edit button as shown below: Step 4: We will see a list of different paths, click on the New button and then add the path where Julia is installed. Step 5: Click on OK, Save the settings and it is done !! Now to check whether the installation is done correctly, open command prompt and type julia. It will start Julia command-line if installed correctly.
In Linux, there are several ways to install Julia. But we will refer to the simplest and easy way to install Julia using the terminal. Go through How to install Julia on Linux? and follow the instructions. Generally, the Path variable is automatically set in Linux at the time of installation, but it can also be set manually by following steps:
Go to Application -> Accessories -> Terminal
For setting up Environment Variable, type the following command in the Terminal with the use of Installation path:export JULIA=/snap/bin/julia
export JULIA=/snap/bin/julia
 
For setting up the Environment Value, type the following command in the Terminal with the use of Installation path:export PATH = $PATH:/snap/bin/
export PATH = $PATH:/snap/bin/
 
It is done!! Now to check whether the installation is done correctly, open Terminal and type julia. It will open the Julia command-line if the setup is done correctly.
Julia-Basics
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP end() Function

30 Nov, 2021
In this article, we will see how to get the last element in an array using the end() function in PHP, along with understanding their implementation through the examples.
The end() function is an inbuilt function in PHP and is used to find the last element of the given array. The end() function changes the internal pointer of an array to point to the last element and returns the value of the last element.
Syntax:
end($array)
Parameters: This function accepts a single parameter $array. It is the array of which the last element we want to find. 
Return Value: It returns the value of the last element of the array on success, otherwise returns FALSE on failure when the array is empty.
Consider the following example.
Input: array('Ram', 'Shita', 'Geeta')
Output: Geeta
Explanation: Here, the input array contain many elements
but output is Geeta i.e, last element of the array 
as the end() function returns the last element of an array.
Example 1: The below example illustrate the end() function in PHP.
PHP
<?php     // Input array  $arr = array('Ram', 'Shita', 'Geeta');   // end function print the last  // element of the array.  echo end($arr);?>
Output:
Geeta
Example 2: This example illustrates retrieving the last element from an array.
PHP
<?php   // Input array  $arr = array('1', '3', 'P');   // end function print the last  // element of the array.  echo end($arr)."\n";   // end() updates the internal pointer  // to point to last element as the  // current() function will now also  // return last element  echo current($arr);?>
Output:
P
P
Reference: http://php.net/manual/en/function.end.php
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
bhaskargeeksforgeeks
PHP-array
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to get parameters from a URL string in PHP?
How to receive JSON POST with PHP ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How to count number of instances of a class in Python?

29 Dec, 2020
Instances of a class mean the objects created for a particular class. A single class can have multiple objects of it. Here, we will find the count of the number of instances of a class in Python.
Approach:
Whenever an object is created, the constructor of that particular class is called.
Constructor is a function whose name is the same as that of class name and it doesn’t have any return type. A constructor is used to initialize the variables of a class.
Whenever a constructor is called which means a new object is created, we just have to increment a counter that will keep track of the no. of objects that particular class has. 
Below is the implementation:
Python3
# codeclass geeks:        # this is used to print the number    # of instances of a class    counter = 0      # constructor of geeks class    def __init__(self):                # increment        geeks.counter += 1    # object or instance of geeks classg1 = geeks()g2 = geeks()g3 = geeks()print(geeks.counter)
Output:
3
Picked
Python Oops-programs
Python-OOP
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
BigDecimal intValue() Method in Java

04 Dec, 2018
The java.math.BigDecimal.intValue() is an in-built function which converts this BigDecimal to an integer value. This function discards any fractional part of this BigDecimal. If the result of the conversion is too big to be represented as an integer value, the function returns only the lower-order 32 bits.
Syntax:
public int intValue()
Parameters: This function accepts no parameters.
Return Value: This function returns the integer value of this BigDecimal.
Examples:
Input : 19878124.176
Output : 19878124

Input : "721111"
Output : 721111

Below programs illustrate the java.math.BigDecimal.intValue() method:
Program 1:
// Java program to illustrate// intValue() methodimport java.math.*;import java.io.*;  class GFG {    public static void main(String[] args)    {        // Creating 2 BigDecimal Objects        BigDecimal b1, b2;        // Assigning values to b1, b2        b1 = new BigDecimal("19878124.176");        b2 = new BigDecimal("721111");        // Displaying their respective Integer Values        System.out.println("The Integer Value of " + b1 + " is "                                                 + b1.intValue());        System.out.println("The Integer Value of " + b2 + " is "                                                + b2.intValue());    }}
Output:
The Integer Value of 19878124.176 is 19878124
The Integer Value of 721111 is 721111

Note: Information regarding the overall magnitude and precision of large this BigDecimal values might be lost during the course of conversion by this function. As a consequence, a result with the opposite sign might be returned.
Program 2: This program illustrates a scenario when the function returns a result with the opposite sign.
// Java program to illustrate// intValue() methodimport java.math.*;import java.io.*;  class GFG {    public static void main(String[] args)    {        // Creating 2 BigDecimal Objects        BigDecimal b1, b2;        // Assigning values to b1, b2        b1 = new BigDecimal("1987812417600");        b2 = new BigDecimal("3567128439701");        // Displaying their respective Integer Values        System.out.println("The Integer Value of " + b1 + " is " + b1.intValue());        System.out.println("The Integer Value of " + b2 + " is " + b2.intValue());    }}
Output:
The Integer Value of 1987812417600 is -757440448
The Integer Value of 3567128439701 is -1989383275

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#intValue()
Java-BigDecimal
Java-Functions
java-math
Java-math-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
NO Quality Assurance (noqa) in Python

17 Dec, 2020
Well if you are someone who has just started with Python then you would most likely be not aware of this feature. Even if you are an experienced programmer then you might not be aware of this nifty little feature. This is going to be a short and simple but very useful article. So, what exactly is noqa. NOQA stands for NO Quality Assurance. 
What this typically means is that if you have any warning in your IDE, then if you add a comment as # noqa at the end of the line then the warning will be ignored by the IDE. This thing might seem very trivial but it can be extremely useful in a production environment where there are certain configurations set at the project level, which prevents a developer from pushing code to VCS which has warnings.
Obviously, Sometimes the IDE fails to understand certain coding styles, like if you do an import in the __init__.py of a package and you never use it in the same file. The only reason why you imported that was so that it is accessible by any other developer who will be consuming your package.
First, We will be creating a python package called demo_noqa. The directory should contain two files, __init__.py, and check.py. Your directory structure should look something like this.
Directory structure
Now, go to check.py and simply create a function called printf(). You can use the below code sample.
Python3
def printf():    print("*\n**\n")
Now, go to __init__.py and simply import printf it from check.py. You can look into the below code sample
Python3
from .check import printf
Now, just save the file. You will see that you will get a warning saying printf imported but never used. Here, below is the example
Warning example
Notice the while line below printf. This is a warning. Now, if you simply add # noqa at the end of the line, the warning will be suppressed. Here, below is an example of the same.
Suppressed warning
Notice that the bulb icon is gone and the white line too. This is how noqa is used. You might find it very trivial if you are a beginner but trust me, once you get into the real world jobs and you will start to work on the production level codes, you will end up using noqa quite frequently.
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
How to run a method every 10 seconds in Android?

This example demonstrates how do I run a method every 10 seconds in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="center"
   android:orientation="vertical"
   tools:context=".MainActivity">
<TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Hello World!" />
</LinearLayout>
Step 3 −Add the following code to src/MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
   Handler handler = new Handler();
   Runnable runnable;
   int delay = 10000;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
   @Override
   protected void onResume() {
      handler.postDelayed(runnable = new Runnable() {
         public void run() {
            handler.postDelayed(runnable, delay);
            Toast.makeText(MainActivity.this, "This method is run every 10 seconds",
            Toast.LENGTH_SHORT).show();
         }
      }, delay);
      super.onResume();
   }
   @Override
   protected void onPause() {
      handler.removeCallbacks(runnable); //stop handler when activity not visible super.onPause();
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>

Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click the Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
What is the difference between System.out.println() and System.out.print() in Java?

The println() terminates the current line by writing the line separator string. The print() method just prints the given content.
Live Demo
public class Sample {
   public static void main(String args[]) {
      System.out.println("Hello");
      System.out.println("how are you");
      System.out.print("Hello");
      System.out.print("how are you");
   }
}
Hello
how are you
Hellohow are you
How to add integer values to a C# list?

To add integer values to a list in C#, use the Add() method.
Firstly, declare an integer list in C# −
List<int> list1 = new List<int>();
Now add integer values −
list1.Add(900);
list1.Add(400);
list1.Add(300);
Let us see the complete code −
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Demo {
   public class Program {
      public static void Main(String[] args) {
         List<int> list1 = new List<int>();
         list1.Add(900);
         list1.Add(400);
         list1.Add(300);
         Console.WriteLine(list1.Count);
      }
   }
}
memmove() function in C/C++

The function memmove() is used to move the whole memory block from one position to another. One is source and another is destination pointed by the pointer. This is declared in “string.h” header file in C language.
Here is the syntax of memmove() in C language,
void *memmove(void *dest_str, const void *src_str, size_t number)
Here,
dest_str − Pointer to the destination array.
src_str − Pointer to the source array.
number − The number of bytes to be copied from source to destination.
Here is an example of memmove() in C language,
 Live Demo
#include <stdio.h>
#include <string.h>
int main () {
   char a[] = "Firststring";
   const char b[] = "Secondstring";
   memmove(a, b, 9);
   printf("New arrays : %s\t%s", a, b);
   return 0;
}
New arrays : SecondstrngSecondstring
In the above program, two char type arrays are initialized and memmove() function is copying the source string ‘b’ to the destination string ‘a’.
char a[] = "Firststring";
const char b[] = "Secondstring";
memmove(a, b, 9);