code-rag-bench/online-tutorials huggingface dataset:
How to Set Color of Progress Bar using HTML and CSS ?

06 Sep, 2020
The progress bar is an important element on the web, the progress bar can be used for downloading, marks obtained, skill measuring unit, etc. To create a progress bar we can use HTML and CSS. 
The progress bar is used to represent the progress of a task. It is also defined how much work is done and how much is left to download a thing. It is not used to represent the disk space or relevant query.
Example 1: In this example, we will set the color of progress bar.
HTML
<!DOCTYPE html><html>  <head>    <title>        How to Set Background Color of        Progress Bar using HTML and CSS?    </title>    <style>              /* For Firefox */        progress::-moz-progress-bar {            background: green;        }          /* For Chrome or Safari */        progress::-webkit-progress-value {            background: green;        }          /* For IE10 */        progress {            background: green;        }    </style></head>  <body>    <h1 style="color:green;">        GeeksforGeeks    </h1>      <h4>        Set Background Color of Progress        Bar using HTML and CSS    </h4>      <progress value="40" max="100"></progress></body>  </html>
Output:
Example 2: In this example, we will set the color and background color of progress bar.
HTML
<!DOCTYPE html><html>  <head>    <title>        How to Set Background Color of        Progress Bar using HTML and CSS?    </title>    <style>          /* For Chrome or Safari */        progress::-webkit-progress-bar {            background-color: #eeeeee;        }          progress::-webkit-progress-value {            background-color: #039603 !important;        }            /* For Firefox */        progress {            background-color: #eee;        }          progress::-moz-progress-bar {            background-color: #039603 !important;        }          /* For IE10 */        progress {            background-color: #eee;        }          progress {            background-color: #039603;        }    </style></head>  <body>    <h1 style="color:green;">        GeeksforGeeks    </h1>      <h4>        Set Background Color of Progress        Bar using HTML and CSS?    </h4>      <progress value="40" max="100"></progress></body>  </html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Form validation using jQuery
Design a web page using HTML and CSS
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Design a Tribute Page using HTML & CSS
Subtract minutes from current time using Calendar.add() method in Java

Import the following package for Calendar class in Java.
import java.util.Calendar;
Firstly, create a Calendar object and display the current date and time.
Calendar calendar = Calendar.getInstance();
System.out.println("Current Date and Time = " + calendar.getTime());
Now, let us decrement the minutes using the calendar.add() method and Calendar.MINUTE constant. Set a negative value since you want to decrease the minutes.
calendar.add(Calendar.MINUTE, -15);
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) {
      Calendar calendar = Calendar.getInstance();
      System.out.println("Current Date = " + calendar.getTime());
      // Subtract 15 minutes from current date
      calendar.add(Calendar.MINUTE, -15);
      System.out.println("Updated Date = " + calendar.getTime());
   }
}
Current Date = Thu Nov 22 16:26:19 UTC 2018
Updated Date = Thu Nov 22 16:11:19 UTC 2018
K’th Non-repeating Character in Python using List Comprehension and OrderedDict

In this article, we will learn about K’th Non-repeating Character in Python using List Comprehension and OrderedDict. To do so we take the help of inbuilt constructs available in Python.
1. First, we form a dictionary data from the input.
2. Now we count the frequency of each character.
3. Now we extract the list of all keys whose value equals 1.
4. Finally, we return k-1 character.
from collections import OrderedDict
import itertools
def kthRepeating(inp,k):
   # returns a dictionary data
   dict=OrderedDict.fromkeys(inp,0)
      # frequency of each character
   for ch in inp:
      dict[ch]+=1
   # now extract list of all keys whose value is 1
   nonRepeatDict = [key for (key,value) in dict.items() if value==1]
   # returns (k-1)th character
   if len(nonRepeatDict) < k:
      return 'no ouput.'
   else:
      return nonRepeatDict[k-1]
# Driver function
if __name__ == "__main__":
   inp = "tutorialspoint"
   k = 3
   print (kthRepeating(inp, k))
a
In this article, we found the K’th Non-repeating Character in Python using List Comprehension and OrderedDict.
How to convert DateTime to a number in MySQL?

To convert the date time to a number in MySQL, the syntax is as follows −
SELECT UNIX_TIMESTAMP(yourColumnName) as anyVariableName FROM yourTableName;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table DateTimeToNumberDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT,
   -> releasedDate datetime,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.46 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> insert into DateTimeToNumberDemo(releasedDate) values(now());
Query OK, 1 row affected (0.19 sec)

mysql> insert into DateTimeToNumberDemo(releasedDate) values(curdate());
Query OK, 1 row affected (0.24 sec)

mysql> insert into
DateTimeToNumberDemo(releasedDate) values('1978-01-19');
Query OK, 1 row affected (0.55 sec)

mysql> insert into DateTimeToNumberDemo(releasedDate) values('2016-09-13');
Query OK, 1 row affected (0.46 sec)

mysql> insert into DateTimeToNumberDemo(releasedDate) values('2017-11-12');
Query OK, 1 row affected (0.22 sec)

mysql> insert into DateTimeToNumberDemo(releasedDate) values('2018-12-09');
Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement. The query is as follows −
mysql> select *from DateTimeToNumberDemo;
The following is the output −
+----+---------------------+
| Id | releasedDate       |
+----+---------------------+
| 1 | 2019-01-12 21:20:57 |
| 2 | 2019-01-12 00:00:00 |
| 3 | 1978-01-19 00:00:00 |
| 4 | 2016-09-13 00:00:00 |
| 5 | 2017-11-12 00:00:00 |
| 6 | 2018-12-09 00:00:00 |
+----+---------------------+
6 rows in set (0.00 sec)
The following is the query to convert date time to a number −
mysql> select unix_timestamp(releasedDate) as DateToNumber from DateTimeToNumberDemo;
The following is the output −
+--------------+
| DateToNumber |
+--------------+
| 1547308257   |
| 1547231400   |
| 253996200    |
| 1473705000   |
| 1510425000   |
| 1544293800   |
+--------------+
6 rows in set (0.00 sec)
Longest Bitonic Subsequence

A sequence is said to be bitonic if it is first increasing and then decreasing. In this problem, an array of all positive integers is given. We have to find a subsequence which is increasing first and then decreasing.
To solve this problem, we will define two subsequences, they are the Longest Increasing Subsequence and the Longest Decreasing Subsequence. The LIS array will hold the length of increasing subsequence ending with array[i]. The LDS array will store the length of decreasing subsequence starting from array[i]. Using these two arrays, we can get the length of longest bitonic subsequence.
Input:
A sequence of numbers. {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
Output:
The longest bitonic subsequence length. Here it is 7.
longBitonicSub(array, size)
Input: The array, the size of an array.
Output − Max length of longest bitonic subsequence.
Begin
   define incSubSeq of size same as the array size
   initially fill all entries to 1 for incSubSeq

   for i := 1 to size -1, do
      for j := 0 to i-1, do
         if array[i] > array[j] and incSubSeq[i] < incSubSum[j] + 1, then incSubSum[i] := incSubSum[j] + 1
      done
   done

   define decSubSeq of size same as the array size.
   initially fill all entries to 1 for incSubSeq

   for i := size - 2 down to 0, do
      for j := size - 1 down to i+1, do
         if array[i] > array[j] and decSubSeq[i] < decSubSum[j] + 1, then decSubSeq [i] := decSubSeq [j] + 1
      done
   done

   max := incSubSeq[0] + decSubSeq[0] – 1
   for i := 1 to size, do
      if incSubSeq[i] + decSubSeq[i] – 1 > max, then max := incSubSeq[i] + decSubSeq[i] – 1
   done

   return max
End
#include<iostream>
using namespace std;

int longBitonicSub( int arr[], int size ) {
   int *increasingSubSeq = new int[size];          //create increasing sub sequence array
   for (int i = 0; i < size; i++)
      increasingSubSeq[i] = 1;              //set all values to 1

   for (int i = 1; i < size; i++)           //compute values from left ot right
      for (int j = 0; j < i; j++)
         if (arr[i] > arr[j] && increasingSubSeq[i] < increasingSubSeq[j] + 1)
            increasingSubSeq[i] = increasingSubSeq[j] + 1;

   int *decreasingSubSeq = new int [size];       //create decreasing sub sequence array
   for (int i = 0; i < size; i++)
      decreasingSubSeq[i] = 1;              //set all values to 1

   for (int i = size-2; i >= 0; i--)          //compute values from left ot right
      for (int j = size-1; j > i; j--)
         if (arr[i] > arr[j] && decreasingSubSeq[i] < decreasingSubSeq[j] + 1)
            decreasingSubSeq[i] = decreasingSubSeq[j] + 1;

   int max = increasingSubSeq[0] + decreasingSubSeq[0] - 1;
   for (int i = 1; i < size; i++) //find max length
      if (increasingSubSeq[i] + decreasingSubSeq[i] - 1 > max)
         max = increasingSubSeq[i] + decreasingSubSeq[i] - 1;
   return max;
}

int main() {
   int arr[] = {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
   int n = 16;
   cout << "Length of longest bitonic subsequence is " << longBitonicSub(arr, n);
}
Length of longest bitonic subsequence is 7
Dice Roll Simulation in C++

Suppose a die simulator generates a random number from 1 to 6 for each roll. We want to introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Consider we have an array of integers rollMax and an integer n, we have to return the number of distinct sequences that can be obtained with exact n rolls. The two sequences are considered different if at least one element differs from each other. So if n is 2, then rollMax = [1,1,2,2,2,3], then the output will be 34. So there will be 2 rolls on die, if there is no constraints, on the die there are 6*6 = 36 possible combinations, in this case the numbers 1 and 2 appears at most once consecutively, so sequences (1,1) and (2,2) cannot occur. so the final answer will be 36 – 2 = 34.
To solve this, we will follow these steps −
create one method called dfs(), this will take dieLeft, last, currLen, array r and matrix dp
if dieLeft = 0, then return 1
if dp[dieLeft][last][currLen] is not -1, then return dp[dieLeft, last, currLen]
counter := 0
for i in range 0 to 6if i = last and r[i] = currLen, then skip the next part and go for next iterationcounter := dfs(dieLeft – 1, i, currLen + 1 when i = last, otherwise 1, r, dp)
if i = last and r[i] = currLen, then skip the next part and go for next iteration
counter := dfs(dieLeft – 1, i, currLen + 1 when i = last, otherwise 1, r, dp)
dp[dieLeft, last, currLen] := counter
return dp[dieLeft, last, currLeft]
the main method will be like −
create one 3D array called dp of order (n + 1) x 6 x 16, and fill this with -1
return dfs(n, 0, 0, rollMax, dp)
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
class Solution {
   public:
   int dfs(int dieLeft, int last, int currLen, vector <int> &r,vector < vector < vector <int> > > &dp){
      if(dieLeft == 0){
         return 1;
      }
      if(dp[dieLeft][last][currLen]!=-1)return dp[dieLeft][last][currLen];
      int counter = 0;
      for(int i =0;i<6;i++){
         if(i==last && r[i] == currLen)continue;
         counter = (counter%mod + (dfs(dieLeft-1,i,i==last?currLen+1:1,r,dp))%mod)%mod;
      }
      dp[dieLeft][last][currLen] = counter%mod;
      return dp[dieLeft][last][currLen]%mod;
   }
   int dieSimulator(int n, vector<int>& rollMax) {
      vector < vector < vector <int> > > dp(n+1, vector < vector <int> > (6, vector <int>(16, -1)));
      return dfs(n,0,0,rollMax, dp)%mod;
   }
};
main(){
   vector<int> v = {1,1,2,2,2,3};
   Solution ob;
   cout << (ob.dieSimulator(2,v));
}
2
[1,1,2,2,2,3]
34
Exception handling and object destruction | Set 1 - GeeksforGeeks

24 Jan, 2022
Predict the output of following C++ program. 
CPP
#include <iostream>using namespace std; class Test {public:  Test() { cout << "Constructing an object of Test " << endl; }  ~Test() { cout << "Destructing an object of Test "  << endl; }}; int main() {  try {    Test t1;    throw 10;  } catch(int i) {    cout << "Caught " << i << endl;  }}
Output:  
  Constructing an object of Test
  Destructing an object of Test
  Caught 10
When an exception is thrown, destructors of the objects (whose scope ends with the try block) is automatically called before the catch block gets executed. That is why the above program prints “Destructing an object of Test” before “Caught 10”.What happens when an exception is thrown from a constructor? Consider the following program.  
CPP
#include <iostream>using namespace std; class Test1 {public:  Test1() { cout << "Constructing an Object of Test1" << endl; }  ~Test1() { cout << "Destructing an Object of Test1" << endl; }}; class Test2 {public:  // Following constructor throws an integer exception  Test2() { cout << "Constructing an Object of Test2" << endl;            throw 20; }  ~Test2() { cout << "Destructing an Object of Test2" << endl; }}; int main() {  try {    Test1 t1;  // Constructed and destructed    Test2 t2;  // Partially constructed    Test1 t3;  // t3 is not constructed as this statement never gets executed  } catch(int i) {    cout << "Caught " << i << endl;  }}
Output:  
  Constructing an Object of Test1
  Constructing an Object of Test2
  Destructing an Object of Test1
  Caught 20
Destructors are only called for the completely constructed objects. When constructor of an object throws an exception, destructor for that object is not called. As an exercise, predict the output of following program. 
CPP
#include <iostream>using namespace std; class Test {  static int count;  int id;public:  Test() {    count++;    id = count;    cout << "Constructing object number " << id << endl;    if(id == 4)       throw 4;  }  ~Test() { cout << "Destructing object number " << id << endl; }}; int Test::count = 0; int main() {  try {    Test array[5];  } catch(int i) {    cout << "Caught " << i << endl;  }}
We will be covering more of this topic in a separate post. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
simmytarika5
sumitgumber28
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
std::sort() in C++ STL
rand() and srand() in C/C++
Enumeration (or enum) in C
fgets() and gets() in C language
How to dynamically allocate a 2D array in C?
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Virtual Function in C++
Iterators in C++ STL
getline (string) in C++
CICS - REWRITE

REWRITE command is used to modify a record that is already present in a file. Prior to this command, the record must be read with a READ UPDATE command. The parameters are same as described before. The syntax for the Rewrite command is as follows −
EXEC CICS REWRITE
   FILE (name)
   FROM (data-area) 
   LENGTH (data-value)
END-EXEC.

The following example shows how to write a record in 'FL001' file where Studentid is the primary key. A new record with 101 student id will be written in the file −
IDENTIFICATION DIVISION.                                         
PROGRAM-ID. HELLO.                                               
DATA DIVISION. 
WORKING-STORAGE SECTION.
01 WS-STD-REC-LEN    PIC S9(4) COMP.
01 WS-STD-KEY-LEN    PIC S9(4) COMP.
01 WS-STD-REC-KEY    PIC 9(3).
01 WS-STD-REC        PIC X(70).
PROCEDURE DIVISION.
MOVE +70           TO WS-STD-REC-LEN.
MOVE ‘101’         TO WS-STD-REC-KEY.
MOVE 3             TO WS-STD-KEY-LEN.
EXEC CICS READ
   FILE ('FL001')
   INTO (WS-STD-REC)
   LENGTH (WS-STD-REC-LEN)
   RIDFLD (WS-STD-REC-KEY)
   KEYLENGTH (WS-STD-KEY-LEN)
   UPDATE
END-EXEC.
MOVE '100Mohtahim M TutorialsPnt' TO WS-STD-REC.
EXEC CICS REWRITE
   FILE ('FL001')
   FROM (WS-STD-REC)
   LENGTH (WS-STD-REC-LEN)
END-EXEC.
The following table lists the exceptions that arise during a REWRITE statement −
NOTOPEN
File is not open.
LENGERR
Mismatch between the length specified in command and actual length of the record.
NOTAUTH
If the user does not have enough permissions to use the file.
INVREQ
Rewrite without prior READ with UPDATE.
NOSPACE
There is not enough space in the dataset.
 Print
 Add Notes
 Bookmark this page
How to get the values of a particular row in a table in Selenium with python?

We can get the values of a particular row in a table in Selenium. The rows
of a table are represented by <tr> tag in html code. The data in each row is enclosed
with the <td> tag in html. Thus a <td> tag’s parent is always a <tr> tag.
The logic is get all the rows, we shall use the locator xpath and then use find_elements_by_xpath method. The list of rows will be returned. Next we need to compute the size of the list with the help of len method.
The <td> is not normally present in the first row of the table. In place of <td>, there
is the <th> tag.
driver.find_elements_by_xpath("//table/tbody/tr[2]/td")
The html code snippet of a table header is as described below −
Coding Implementation to get the second row data.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then
#invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/plsql/plsql_basic_syntax.htm")
#to refresh the browser
driver.refresh()
# identifying the from row2 having <td> tag
rwdata = driver.find_elements_by_xpath("//table/tbody/tr[2]/td")
# len method is used to get the size of that list
print(len(rwdata))
for r in rwdata:
   print(r.text)
#to close the browser
driver.close()
Clear a Hashtable in C#

Clear a Hashtable, using the Clear() method in C#.
The following is our Hashtable −
Hashtable h = new Hashtable();
h.Add(1, "Amit");
h.Add(2, "Sachin");
h.Add(3, "Rahul");
Use the clear method.
h.Clear();
If you will now try to display the Hashtable, nothing would get display since the Hashtable is empty.
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main() {
      Hashtable h = new Hashtable();
      h.Add(1, "Amit");
      h.Add(2, "Sachin");
      h.Add(3, "Rahul");
      Console.WriteLine("Keys and Values list:");
      foreach (var key in h.Keys ) {
         Console.WriteLine("Key = {0}, Value = {1}",key , h[key]);
      }
      // clear all key value pairs
      Console.WriteLine("The Hashtable key and Value Pairs are empty now...");
      h.Clear();
      foreach (var key in h.Keys ) {
         Console.WriteLine("Key = {0}, Value = {1}",key , h[key]);
      }
   }
}
Keys and Values list:
Key = 3, Value = Rahul
Key = 2, Value = Sachin
Key = 1, Value = Amit
The Hashtable key and Value Pairs are empty now...
Python - String with most unique characters - GeeksforGeeks

06 Mar, 2020
Sometimes, while working with python strings, we can have a problem in which we desire to extract particular list which has most number of unique characters. This kind of problem can have application in competitive programming and web development domain. Lets discuss certain ways in which this task can be performed.
Method #1 : Using max() + dictionary comprehensionThe combination of above functionalities can be used to perform this task. In this, we firstly collect the frequency of each character using dictionary and then employ max() to compute the string with most unique characters.
# Python3 code to demonstrate # String with most unique characters# using max() + dictionary comprehension  # Initializing listtest_list = ['gfg', 'is', 'best', 'for', 'geeksc']  # printing original listprint("The original list is : " + str(test_list))  # String with most unique characters# using max() + dictionary comprehensiontemp =  {idx : len(set(idx)) for idx in test_list}res = max(temp, key = temp.get)  # printing result print ("The string with most unique characters is : " + str(res))
The original list is : ['gfg', 'is', 'best', 'for', 'geeksc']
The string with most unique characters is : geeksc

 
Method #2 : Using max() + key + lambdaThe combination of above methods can be used to perform this task. In this, we perform this task in similar way as above, just the difference is instead of using comprehension we use lambda function to extend logic to each string for computation.
# Python3 code to demonstrate # String with most unique characters# using max() + key + lambda  # Initializing listtest_list = ['gfg', 'is', 'best', 'for', 'geeksc']  # printing original listprint("The original list is : " + str(test_list))  # String with most unique characters# using max() + key + lambdares = max(test_list, key = lambda sub: len(set(sub)), default = None)  # printing result print ("The string with most unique characters is : " + str(res))
The original list is : ['gfg', 'is', 'best', 'for', 'geeksc']
The string with most unique characters is : geeksc

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
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?
How to set vertical gap between elements in a GridLayout with Java?

Use the setVgap() method to set the vertical gap between elements in a GridLayout. Let’s say we have a GridLaypout −
GridLayout layout = new GridLayout(3,3);
Set the horizontal gap −
layout.setVgap(30);
The following is an example −
package my;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame("Sections");
      JPanel panel = new JPanel();
      panel.setBackground(Color.blue);
      GridLayout layout = new GridLayout(3,3);
      layout.setVgap(30);
      panel.setLayout(layout);
      panel.add(new JButton("Overview"));
      panel.add(new JButton("Samples"));
      panel.add(new JButton("Tutorials"));
      panel.add(new JButton("Support"));
      panel.add(new JButton("InterviewQA"));
      panel.add(new JButton("Tools"));
      panel.add(new JButton("Editors"));
      frame.add(panel);
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      frame.setSize(500, 300);
      frame.setVisible(true);
   }
}
Boolean Algebraic Theorems - GeeksforGeeks

01 Apr, 2021
Boolean algebraic theorems are the theorems that are used to change the form of a boolean expression. Sometimes these theorems are used to minimize the terms of the expression, and sometimes they are used just to transfer the expression from one form to another. 
There are boolean algebraic theorems in digital logic: 
1. De Morgan’s Theorem : DE Morgan’s Theorem represents two of the most important rules of boolean algebra. 
(i). (A . B)' = A' + B' 
Thus, the complement of the product of variables is equal to the sum of their individual complements.  
(ii). (A + B)' = A' . B' 
Thus, the complement of the sum of variables is equal to the product of their individual complements. 
The above two laws can be extended for n variables as 
(A1 . A2 . A3 ... An)' = A1' + A2' + ... + An'

And

(A1 + A2 + ... + An)' = A1' . A2' . A3' ... An' 
2. Transposition Theorem : It states that: 
AB + A'C = (A + C) (A' + B)
Proof: 
RHS 
= (A + C) (A' + B)
= AA' + A'C + AB + CB
= 0 + A'C + AB + BC
= A'C + AB + BC(A + A')
= AB + ABC + A'C + A'BC
= AB + A'C
= LHS 
3. Redundancy Theorem : This theorem is used to eliminate the redundant terms. A variable is associated with some variable and its complement is associated with some other variable and the next term is formed by the left over variables, then the term becomes redundant. 
Example: 
AB + BC' + AC = AC + BC' 
Proof: 
LHS 
= AB + BC' + AC
= AB(C + C') + BC'(A + A') + AC(B + B')
= ABC + ABC' + ABC' + A'BC' + ABC + AB'c
= ABC + ABC' + A'BC' + AB'C
= AC(B + B') + BC'(A + A')
= AC + BC'
= RHS 
4. Duality Theorem : Dual expression is equivalent to write a negative logic of the given boolean relation. For this, 
Change each OR sign by and AND sign and vice-versa. Complement any 0 or 1 appearing in the expression. Keep literals as it is.  
Change each OR sign by and AND sign and vice-versa. 
Complement any 0 or 1 appearing in the expression. 
Keep literals as it is.  
Example: 
Dual of A(B+C) = A+(B.C) = (A+B)(A+C)
5. Complementary Theorem : For obtaining complement expression, 
Change each OR sign by AND sign and vice-versa. Complement any 0 or 1 appearing in the expression. Complement the individual literals.  
Change each OR sign by AND sign and vice-versa. 
Complement any 0 or 1 appearing in the expression. 
Complement the individual literals.  
Example: 
Complement of A(B+C) = A'+(B'.C') = (A'+B')(A'+C')
sk944795
Digital Electronics & Logic Design
Engineering Mathematics
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to memory and memory units
Analog to Digital Conversion
Introduction of Sequential Circuits
Latches in Digital Logic
Restoring Division Algorithm For Unsigned Integer
Inequalities in LaTeX
Relationship between number of nodes and height of binary tree
Activation Functions
Mathematics | Walks, Trails, Paths, Cycles and Circuits in Graph
Arrow Symbols in LaTeX
Difference between hardware serial and software serial in Arduino

A hardware serial, as the name suggests, denotes that a dedicated piece of hardware (UART) enables Serial communication. In Arduino Uno, for instance, pins 0 and 1 have UART support,and they are connected to the USB via a USB-to-UART converter. That facilitates communication between your computer/laptop and the Arduino. While Arduino Uno has a single Hardware Serial, other boards like Mega have multiple. They are accessed using Serial,
Serial1, Serial2, and so on.
You can have a look at an example of using Multiple Hardware Serials by going to File → Examples → Communication → MultiSerial
Software serial is a library that replicates the hardware serial behavior on other digital pins of the Arduino, using (you guessed it) software. You can have more than one software serials running in parallel, with the limitation being that only one can receive data at a time.
The SoftwareSerial library is inbuilt from Arduino IDE 1.0 and above. To use it, all you need to include is −
#include <SoftwareSerial.h>
The other limitations (board specific) of SoftwareSerial library can be found here.
Speeds up to 115200 bps are possible using the SoftwareSerial library. You can find examples related to the usage of SoftwareSerial by going to File → Examples →SoftwareSerial
C - nested if statements

It is always legal in C programming to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).
The syntax for a nested if statement is as follows −
if( boolean_expression 1) {

   /* Executes when the boolean expression 1 is true */
   if(boolean_expression 2) {
      /* Executes when the boolean expression 2 is true */
   }
}

You can nest else if...else in the similar way as you have nested if statements.
#include <stdio.h>
 
int main () {

   /* local variable definition */
   int a = 100;
   int b = 200;
 
   /* check the boolean condition */
   if( a == 100 ) {
   
      /* if condition is true then check the following */
      if( b == 200 ) {
         /* if condition is true then print the following */
         printf("Value of a is 100 and b is 200\n" );
      }
   }
   
   printf("Exact value of a is : %d\n", a );
   printf("Exact value of b is : %d\n", b );
 
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Value of a is 100 and b is 200
Exact value of a is : 100
Exact value of b is : 200

 Print
 Add Notes
 Bookmark this page
How to Add GIFs on README .md File in a GitHub Repository? - GeeksforGeeks

10 Nov, 2021
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects. Github is a highly used software that is used for version control. It is more helpful when more than one person is working on a project. GIF as we all know stands for Graphics Interchange Format is a bitmap image format. This format supports 8 bits per pixel.
Proceeding further Git and Github basics are a must pre-requisite to go where here we will be getting how we can add GIFs in the README.md file of a GitHub repository.
Step 1: First of all, create a GitHub repository on Github, for illustration purposes we are taking a custom repository as depicted below: 
For example, We have created a Github repository with the name GeeksForGeeks.
Step 2: Upload the GIF in the repository which you want to add in README.
For example, custom GIF have ben uploaded in above repository named “Geeks For Geeks”.
Step 3: Click on the “Add a README” button.
A new window will open.
Step 4: Open the added GIF file in your repository and copy the URL.
Step 5: Now paste it inside your README.md file with command below as follows:
![](https://github.com/Your_Repository_Name/Your_GIF_Name.gif)
Example: Custom readme in the directory 
1.1 Click on the commit changes button at the bottom.
1.2 Your GIF will appear along with other README.md file contents.
Note: It is recommended to use GIFs size to be less than 30 MB.
GitHub
Git
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference Between Git Push Origin and Git Push Origin Master
How to Push Git Branch to Remote?
Git - Difference Between Git Fetch and Git Pull
How to Export Eclipse projects to GitHub?
Merge Conflicts and How to handle them
How to Add Git Credentials in Eclipse?
What is README.md File?
Top 10 GitHub Alternatives That You Can Consider
Git - Merge
Using Patches in Git
C | Pointer Basics | Question 12 - GeeksforGeeks

05 Feb, 2013
Consider this C code to swap two integers and these five statements after it:
void swap(int *px, int *py) {    *px = *px - *py;    *py = *px + *py;    *px = *py - *px; }
S1: will generate a compilation errorS2: may generate a segmentation fault at runtime depending on the arguments passedS3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the processS4: implements the swap procedure correctly for some but not all valid input pointersS5: may add or subtract integers and pointers.
(A) S1(B) S2 and S3(C) S2 and S4
(D) S2 and S5Answer: (C)Explanation: S2: May generate segmentation fault if value at pointers px or py is constant or px or py points to a memory location that is invalidS4: May not work for all inputs as arithmetic overflow can occur
C-Pointers
Pointers
C Language
C Quiz
Pointers
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Function Pointer in C
TCP Server-Client implementation in C
Structures in C
std::string class in C++
Exception Handling in C++
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Structure & Union | Question 4
C | File Handling | Question 5
C | File Handling | Question 1
Get elapsed time in minutes in Java

To get the elapsed time of an operation in minutes in Java, we use the System.currentTimeMillis() method. The java.lang.System.currentTimeMillis() returns the current time in milliseconds.
Declaration −The java.lang.System.currentTimeMillis() is declared as follows −
public static long currentTimeMillis()
The method returns time difference in milliseconds between the current time and midnight, January 1, 1970 (UTC or epoch time).
Let us see a program to compute the elapsed time of an operation in minutes in Java −
 Live Demo
public class Example {
   public static void main(String[] args) throws Exception {
      // finding the time before the operation is executed
      long start = System.currentTimeMillis();
      for (int i = 0; i <5; i++) {
         Thread.sleep(60);
      }
      // finding the time after the operation is executed
      long end = System.currentTimeMillis();
      // finding the time difference
      float msec = end - start;
      // converting it into seconds
      float sec= msec/1000F;
      // converting it into minutes
      float minutes=sec/60F;
      System.out.println(minutes + " minutes");
   }
}
0.0050000004 minutes
C# | Boolean.ToString() Method - GeeksforGeeks

04 Oct, 2021
This method is used to convert the value of this instance to its equivalent string representation i.e. either “True” or “False”.
Syntax:
public override string ToString ();
Return Value: This method returns “True” (the value of the TrueString property) if the value of this instance is true, or “False” (the value of the FalseString property) if the value of this instance is false.
Below programs illustrate the use of Boolean.ToString() Method:
Example 1: 
C#
// C# program to demonstrate// Boolean.ToString()// Methodusing System; class GFG {     // Main Method    public static void Main()    {         // initializing the bool variables        bool cat = false;        bool dog = true;         // getting the value of string property        string value1 = cat.ToString();        string value2 = dog.ToString();         // print the string property        Console.WriteLine("cat.ToString() returns {0}", value1);        Console.WriteLine("dog.ToString() returns {0}", value2);    }}
cat.ToString() returns False
dog.ToString() returns True
 
Example 2:
C#
// C# program to demonstrate// Boolean.ToString()// Methodusing System; class GFG {     // Main Method    public static void Main()    {         // initializing the bool variables        bool alpha = false;        bool beta = true;        bool gamma = true;        bool delta = false;        bool theta = true;         // calling getValue() method        getValue(alpha);        getValue(beta);        getValue(gamma);        getValue(delta);        getValue(theta);    }     // defining getValue() method    public static void getValue(bool variable)    {         // getting the value of string property        string value = variable.ToString();         // print the string property        Console.WriteLine("{0}", value);    }}
False
True
True
False
True
 
Note: XML is case-sensitive, and that the XML specification recognizes “true” and “false” as the valid set of Boolean values. If the string returned by the ToString() method is to be written to an XML file, its String.ToLowerInvariant method should be called first to convert it to lowercase.
Reference: 
https://docs.microsoft.com/en-us/dotnet/api/system.boolean.tostring?view=netframework-4.7.2#System_Boolean_ToString
rajeev0719singh
sagartomar9927
CSharp Boolean Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Constructors
Introduction to .NET Framework
C# | Data Types
Reverse a string in PL/SQL

29 Jun, 2018
Prerequisite – PL/SQL introduction
In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given a string, the task is to reverse a string using PL/SQL.
Examples:
Input: skeegrofskeeg
Output: geeksforgeeks

Input: geeks
Output: skeeg

Approach:
Find the length of the string.
Then traverse the string in a reverse manner.
Store the characters in another string.
Print the final string.
Below is the required implementation:
DECLARE    -- declare variable str , len     -- and str1 of datatype varchar    str  VARCHAR(20) := 'skeegrofskeeg';    len  NUMBER;    str1 VARCHAR(20);BEGIN    -- Here we find the length of string    len := Length(str);      -- here we starting a loop from max len to 1    FOR i IN REVERSE 1.. len LOOP        -- assigning the reverse string in str1                       str1 := str1                || Substr(str, i, 1);    END LOOP;      dbms_output.Put_line('Reverse of string is '                         || str1);END;-- Program End 
Output :
Reverse of string is geeksforgeeks

SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML textarea autocomplete Attribute

09 May, 2022
The HTML <textarea> autocomplete Attribute is used to specify whether the Textarea field has autocomplete on or off. When the autocomplete attribute is set to on, the browser will automatically complete the values based on which the user entered before. It works with many input fields such as text, search, URL, email, password, date pickers, range, and color.Syntax:  
<Textarea autocomplete="on | off">
Attribute Values:  
on: It has a default value. It specifies that autocomplete is enabled.
off: It specifies that the autocomplete is disabled.
Example: This example illustrates the use of autocomplete attribute in textarea element  
html
<!DOCTYPE html><html> <head>    <title>        HTML textarea autocomplete Attribute    </title></head> <body style="text-align:center">    <h1 style="color: green;">        GeeksforGeeks    </h1>    <h2>        HTML Textarea        autocomplete Attribute    </h2>     <textarea id="geeks" autocomplete="on"        autofocus>        write something here----    </textarea></body> </html>
Output:  
Supported Browsers: The browsers supported by HTML | <textarea> autocomplete attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
chhabradhanvi
rkbhola5
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::remove_const in C++ with Examples

21 Jun, 2020
The std::remove_const template of C++ STL is present in the <type_traits> header file. The std::remove_const template of C++ STL is used to get the type T without const qualification. It return the boolean value true if T is without const qualified, otherwise return false. Below is the syntax for the same:
Header File:
#include<type_traits>

Template Class:
template <class T>
struct remove_const;

Syntax:
std::remove_const<T>::value

Parameter: This template std::remove_const accepts a single parameter T(Trait class) to check whether T is without const qualified or not.
Return Value: The template std::remove_const returns a boolean value:
True: If type T is without const qualified.
False: If type T is with const qualified.
Below is the program to demonstrate std::remove_const in C++:
Program:
// C++ program to illustrate// std::remove_const#include <bits/stdc++.h>#include <type_traits>using namespace std;  // Driver Codeint main(){    // Declare variable of type    // int, const int, const int*,    // int * const and const int&    typedef remove_const<int>::type A;    typedef remove_const<const int>::type B;    typedef remove_const<const int*>::type C;    typedef remove_const<int* const>::type D;    typedef remove_const<const int&>::type E;      cout << std::boolalpha;      // Checking const of the above    // declared variables    cout << "A is without const int? "         << is_same<int, A>::value         << endl;      cout << "B is without const int? "         << is_same<int, B>::value         << endl;      cout << "C is without const int? "         << is_same<int, C>::value         << endl;      cout << "D is without const int? "         << is_same<int, D>::value         << endl;      cout << "E is without const int? "         << is_same<const int, E>::value         << endl;      return 0;}
A is without const int? true
B is without const int? true
C is without const int? false
D is without const int? false
E is without const int? false

Reference: http://www.cplusplus.com/reference/type_traits/remove_const/
CPP-Functions
STL
C++
C++ Programs
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to generate a random letter in Python?

03 Mar, 2021
In this article, let’s discuss how to generate a random letter. Python provides rich module support and some of these modules can help us to generate random numbers and letters. There are multiple ways we can do that using various Python modules.
Method 1: Using string and random module
The string module has a special function ascii_letters which returns a string containing all the alphabets from a-z and A-Z, i.e. all the lowercase and uppercase alphabets. Using random.choice() we can choose any of the particular characters from that string.
Code:
Python3
# Import string and random moduleimport stringimport random  # Randomly choose a letter from all the ascii_lettersrandomLetter = random.choice(string.ascii_letters)print(randomLetter)
Output:
w
Method 2: Using the only random module
Using random.randint(x,y) we can generate random integers from x to y. So we can randomly generate ASCII value of one of the alphabets and then typecast them to char using chr() function.
Code:
Python3
# Import string and random moduleimport random  # Randomly generate a ascii value# from 'a' to 'z' and 'A' to 'Z'randomLowerLetter = chr(random.randint(ord('a'), ord('z')))randomUpperLetter = chr(random.randint(ord('A'), ord('Z')))print(randomLowerLetter, randomUpperLetter)
Output:
n M
Picked
Python-random
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to close window using JavaScript which is opened by the user with a URL ?

05 Nov, 2020
JavaScript does not allow one to close a window opened by the user, using the window.close() method due to security issues. However, we can close a window by using a workaround. The approach to be followed is by opening the current URL using JavaScript so that it could be closed with a script.
The steps below demonstrate this approach:
Step 1: Opening a new window using the open() method: First we need to open a new window using the window.open() method. The current URL can be accessed using the location property of the window object. The target attribute or name value of the window is given as _self. This is important as it makes the URL replace the current page.
Step 2: Close this open window using the close() method: The window.close() method closes the window on which it is called. The window that was opened in the first step is closed by using this method. This works because the window has now been opened by our script instead of the user.
Note: This approach may not work on all browsers due to different implementations of browser security.
The example below demonstrates the above steps:
Example:
HTML
<!DOCTYPE html><html>  <body>    <h1 style="color: green;">        GeeksforGeeks    </h1>      <p>        Click on the button below to        close the current window.    </p>      <!-- Define the button to        close the window -->    <button onclick="return closeWindow();">        Close Window    </button>          <script type="text/javascript">        function closeWindow() {              // Open the new window             // with the URL replacing the            // current page using the            // _self value            let new_window =                open(location, '_self');              // Close this window            new_window.close();              return false;        }    </script></body>  </html>
Output:
HTML-Misc
JavaScript-Misc
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
How to auto-resize an image to fit a div container using CSS?
Angular File Upload
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Differences between Functional Components and Class Components in React
Roadmap to Learn JavaScript For Beginners
Difference Between PUT and PATCH Request
Translator App Project using Django

16 Mar, 2021
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
In this article we will make a translator app using Django.
Installation
pip install django
Text translation from one language to another is increasingly becoming common for various websites as they cater to an international audience. The python package which helps us do this is called translate.
pip install translate
Then create new project
django-admin startproject translator
cd translator
Then create new app inside the project
python manage.py startapp main
Then add the app name inside the settings.py 
views.py
Python3
from django.shortcuts import render,HttpResponsefrom translate import Translator# Create your views here.  def home(request):    if request.method == "POST":        text = request.POST["translate"]        language = request.POST["language"]        translator= Translator(to_lang=language)        translation = translator.translate(text)        return HttpResponse(translation)    return render(request,"main/index.html")
Then create directory templates inside the app.
Inside that create new directory main
Create new file index.html
HTML
<!DOCTYPE html><html><head>    <title>GFG</title></head><body><form method="post">    {% csrf_token %}    <input type="text" name="translate" required>    <br>    <select required name="language">        <option value="Hindi">Hindi</option>        <option value="Marathi">Marathi</option>        <option value="German">German</option>    </select>    <br>    <button type="submit">Translate</button></form></body></html>
Then create new file urls.py inside the app
Python3
from django.urls import pathfrom .views import *  urlpatterns = [    path('',home,name="home"),]
Then add then main.urls inside url translator/urls.py
Python3
from django.contrib import adminfrom django.urls import path,include  urlpatterns = [    path('admin/', admin.site.urls),    path('',include("main.urls"))]
To run this app open cmd or terminal 
python manage.py runserver
Output :-
Django-Projects
Python Django
Python Framework
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
Create a directory in Python