code-rag-bench/online-tutorials huggingface dataset:
Scala - do-while Loop

Unlike while loop, which tests the loop condition at the top of the loop, the do-while loop checks its condition at the bottom of the loop. A do-while loop is similar to a while loop, except that a do-while loop is guaranteed to execute at least one time.
The following is the syntax for do-while loop.
do {
   statement(s);
} 
while( condition );

Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is tested. If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false.
Try the following example program to understand loop control statements (while statement) in Scala Programming Language.
object Demo {
   def main(args: Array[String]) {
      // Local variable declaration:
      var a = 10;

      // do loop execution
      do {
         println( "Value of a: " + a );
         a = a + 1;
      }
      while( a < 20 )
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Angular CLI - ng run Command

This chapter explains the syntax, argument and options of ng run command along with an example.
The syntax for ng run command is as follows −
ng run project:target[:configuration]

ng run command runs an Architect target with an optional custom builder configuration defined in angular.json in your project. Here project is the name of the application as defined in angular.json. 
The argument for ng run command is as follows −
Options are optional parameters.
A named builder configuration, defined in the "configurations" section of angular.json. The builder uses the named configuration to run the given target.
Aliases: -c.
Shows a help message for this command in the console.
Default: false.
First move to an angular project updated using ng generate command and then run the command.This chapter is available at
https://www.tutorialspoint.com/angular_cli/angular_cli_ng_generate.htm.
An example for ng run command is given below −
\>Node\>TutorialsPoint> ng run TutorialsPoint:build
Generating ES5 bundles for differential loading...
ES5 bundle generation complete.

chunk {polyfills} polyfills-es2015.js, polyfills-es2015.js.map (polyfills) 141 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 656 kB [initial] [rendered]
chunk {main} main-es2015.js, main-es2015.js.map (main) 12.9 kB [initial] [rendered]
chunk {main} main-es5.js, main-es5.js.map (main) 15.1 kB [initial] [rendered]
chunk {runtime} runtime-es2015.js, runtime-es2015.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {runtime} runtime-es5.js, runtime-es5.js.map (runtime) 6.16 kB [entry] [rendered]
chunk {styles} styles-es2015.js, styles-es2015.js.map (styles) 12.4 kB [initial] [rendered]
chunk {styles} styles-es5.js, styles-es5.js.map (styles) 13.9 kB [initial] [rendered]
chunk {vendor} vendor-es2015.js, vendor-es2015.js.map (vendor) 2.66 MB [initial] [rendered]
chunk {vendor} vendor-es5.js, vendor-es5.js.map (vendor) 3.11 MB [initial] [rendered]
Date: 2020-06-04T02:31:28.919Z - Hash: dd73885c28e550d01341 - Time: 13742ms

Here ng build command has built our project TutorialsPoint successfully.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to create a modal popup using JavaScript and CSS?

Creating a modal popup means adding a dialog box, which generates on click of a button and close when user clicks anywhere outside of the popup.
Here’s how a popup looks like below with header and a text. You can also add a footer to it −
To create a modal popup using CSS and JavaScript, try to run the following code −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .popup {
            display: none;
            position: fixed;
            z-index: 1;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background-color: #F1F1F1;
            background-color: rgba(0,0,0,0.4);
            -webkit-animation-name: fadeIn;
            -webkit-animation-duration: 0.4s;
            animation-name: fadeIn;
            animation-duration: 0.4s
         }
         .popup-content {
            position: fixed;
            bottom: 0;
            background-color: #ffffff;
            width: 100%;
            -webkit-animation-name: slideIn;
            -webkit-animation-duration: 0.5s;
            animation-name: slideIn;
            animation-duration: 0.5s
         }
         .end {
            color: white;
            float: right;
            font-size: 15px;
            font-weight: bold;
         }
         .end:hover,
         .end:focus {
            color: #000;
            text-decoration: underline;
            cursor: pointer;
         }
         .popup-header {
            padding: 1px 10px;
            background-color: #8AC1E0;
            color: white;
         }
         .popup-body {padding: 1px 5px;}
         @-webkit-keyframes slideIn {
            from {bottom: -300px; opacity: 0}
            to {bottom: 0; opacity: 1}
         }
         @keyframes slideIn {
            from {bottom: -300px; opacity: 0}
            to {bottom: 0; opacity: 1}
         }
         @-webkit-keyframes fadeIn {
            from {opacity: 0}
            to {opacity: 1}
         }
         @keyframes fadeIn {
            from {opacity: 0}
            to {opacity: 1}
         }
      </style>
   </head>
   <body>
      <h2>Heading</h2>
      <button id="btn">Click for Popup</button>
      <div id="myModal" class="popup">
         <!-- Modal content -->
         <div class="popup-content">
            <div class="popup-header">
               <span class="end">×</span>
               <h2>Header</h2>
            </div>
            <div class="popup-body">
               <p>Demo Text</p>
            </div>
         </div>
      </div>
      <script>
         var popup = document.getElementById('myModal');
         var myBytton = document.getElementById("btn");
         var span = document.getElementsByClassName("end")[0];
         myBytton.onclick = function() {
            popup.style.display = "block";
         }
         span.onclick = function() {
            popup.style.display = "none";
         }
         window.onclick = function(event) {
            if (event.target == popup) {
               popup.style.display = "none";
            }
         }
      </script>
   </body>
</html>
PHP - Simple XML GET

XML Get has used to get the node values from xml file. The following example shows, How to get the data from xml.
Note.xml is xml file, It can accessed by php file.
<SUBJECT>
   <COURSE>Android</COURSE>
   <COUNTRY>India</COUNTRY>
   <COMPANY>TutorialsPoint</COMPANY>
   <PRICE>$10</PRICE>
</SUBJECT>
Index page has rights to get access the xml data by using implexml_load_file().
<?php
   $xml = simplexml_load_file("note.xml") or die("Error: Object Creation failure");
?>

<html>
   <head>
      
      <body>
         
         <?php
            echo $xml->COURSE . "<br>";
            echo $xml->COUNTRY . "<br>";
            echo $xml->COMPANY . "<br>";
            echo $xml->PRICE;
         ?>
         
      </body>
      
   </head>
</html>
It will produce the following result −
The below code is having information about how to get node values from xml file and XML should be as follows −
<?xml version = "1.0" encoding = "utf-8"?>
<tutorialspoint>
   
   <course category = "JAVA">
      <title lang = "en">Java</title>
      <tutor>Gopal</tutor>
      <duration></duration>
      <price>$30</price>
   </course>
   
   <course category = "HADOOP">
      <title lang = "en">Hadoop</title>.
      <tutor>Satish</tutor>
      <duration>3>/duration>
      <price>$50</price>
   </course>
   
   <course category = "HTML">
      <title lang = "en">html</title>
      <tutor>raju</tutor>
      <duration>5</duration>
      <price>$50</price>
   </course>
   
   <course category = "WEB">
      <title lang = "en">Web Technologies</title>
      <tutor>Javed</tutor>
      <duration>10</duration>
      <price>$60</price>
   </course>

</tutorialspoint>
PHP code should be as follows
<html>
   <body>
   
      <?php
         $xml = simplexml_load_file("books.xml") or die("Error: Cannot create object");
         
         foreach($xml->children() as $books) { 
            echo $books->title . "<br> "; 
            echo $books->tutor . "<br> "; 
            echo $books->duration . "<br> ";
            echo $books->price . "<hr>"; 
         }
      ?>
      
   </body>
</html>
It will produce the following result −

    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Java program to count words in a given string

The words in a given string can be counted using a while loop. An example of this is given as follows −
String = Sky is blue
Number of words = 3
A program that demonstrates this is given as follows.
 Live Demo
public class Example {
   public static void main(String args[]) {
      int flag = 0;
      int count = 0;
      int i = 0;
      String str = "The sunset is beautiful";
      while (i < str.length()) {
         if (str.charAt(i) == ' ' || str.charAt(i) == '\n' || str.charAt(i) == '\t') {
            flag = 0;
         }else if (flag == 0) {
            flag = 1;
            count++;
         }
         i++;
      }
      System.out.println("The string is: " + str);
      System.out.println("No of words in the above string are: " + count);
   }
}
The output of the above program is as follows.
The string is : The sunset is beautiful
No of words in the above string are : 4
Now let us understand the above program.
First, the string str is defined. Then a while loop is used to obtain the number of words in the string. This is done using the flag variable that is initially initialized to 0. The code snippet that demonstrates this is given as follows.
int flag = 0;
int count = 0;
int i = 0;
String str = "The sunset is beautiful";
while (i < str.length()) {
   if (str.charAt(i) == ' ' || str.charAt(i) == '\n' || str.charAt(i) == '\t') {
      flag = 0;
   }else if (flag == 0) {
      flag = 1;
      count++;
   }
   i++;
}
Finally, the string and the number of words in it are displayed. The code snippet that demonstrates this is given as follows.
System.out.println("The string is: " + str);
System.out.println("No of words in the above string are: " + count);
Semaphores in Operating System

Semaphores are integer variables that are used to solve the critical section problem by using two atomic operations, wait and signal that are used for process synchronization.
The definitions of wait and signal are as follows −
WaitThe wait operation decrements the value of its argument S, if it is positive. If S is negative or zero, then no operation is performed.
The wait operation decrements the value of its argument S, if it is positive. If S is negative or zero, then no operation is performed.
wait(S)
{
   while (S<=0);

   S--;
}
SignalThe signal operation increments the value of its argument S.
The signal operation increments the value of its argument S.
signal(S)
{
   S++;
}
There are two main types of semaphores i.e. counting semaphores and binary semaphores. Details about these are given as follows −
Counting SemaphoresThese are integer value semaphores and have an unrestricted value domain. These semaphores are used to coordinate the resource access, where the semaphore count is the number of available resources. If the resources are added, semaphore count automatically incremented and if the resources are removed, the count is decremented.
These are integer value semaphores and have an unrestricted value domain. These semaphores are used to coordinate the resource access, where the semaphore count is the number of available resources. If the resources are added, semaphore count automatically incremented and if the resources are removed, the count is decremented.
Binary SemaphoresThe binary semaphores are like counting semaphores but their value is restricted to 0 and 1. The wait operation only works when the semaphore is 1 and the signal operation succeeds when semaphore is 0. It is sometimes easier to implement binary semaphores than counting semaphores.
The binary semaphores are like counting semaphores but their value is restricted to 0 and 1. The wait operation only works when the semaphore is 1 and the signal operation succeeds when semaphore is 0. It is sometimes easier to implement binary semaphores than counting semaphores.
Some of the advantages of semaphores are as follows −
Semaphores allow only one process into the critical section. They follow the mutual exclusion principle strictly and are much more efficient than some other methods of synchronization.
There is no resource wastage because of busy waiting in semaphores as processor time is not wasted unnecessarily to check if a condition is fulfilled to allow a process to access the critical section.
Semaphores are implemented in the machine independent code of the microkernel. So they are machine independent.
Some of the disadvantages of semaphores are as follows −
Semaphores are complicated so the wait and signal operations must be implemented in the correct order to prevent deadlocks.
Semaphores are impractical for last scale use as their use leads to loss of modularity. This happens because the wait and signal operations prevent the creation of a structured layout for the system.
Semaphores may lead to a priority inversion where low priority processes may access the critical section first and high priority processes later.
Java Program to add and remove elements from a set which maintains the insertion order

Create a LinkedHashSet −
LinkedHashSet<Integer>set = new LinkedHashSet<Integer>();
Now, add elements to the Set −
set.add(20);
set.add(60);
set.add(80);
set.add(120);
set.add(150);
set.add(200);
For removing the elements −
set.remove(150);
set.remove(260);
Above process of insertion and deletion won’t affect the insertion order.
 Live Demo
import java.util.LinkedHashSet;
public class Demo {
   public static void main(String[] args) {
      LinkedHashSet<Integer>set = new LinkedHashSet<Integer>();
      set.add(20);
      set.add(60);
      set.add(80);
      set.add(120);
      set.add(150);
      set.add(200);
      set.add(220);
      set.add(260);
      set.add(380);
      System.out.println("Set = "+set);
      set.remove(150);
      set.remove(260);
      System.out.println("Updated Set = "+set);
      set.remove(60);
      System.out.println("Updated Set = "+set);
   }
}
Set = [20, 60, 80, 120, 150, 200, 220, 260, 380]
Updated Set = [20, 60, 80, 120, 200, 220, 380]
Updated Set = [20, 80, 120, 200, 220, 380]
Lodash _.truncate() Method - GeeksforGeeks

18 Sep, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.
The _.truncate() method of String in lodash is used to truncate the stated string if it is longer than the specified string length. The last characters of the string which are truncated are replaced with the stated omission string which is by defaults “...”.
Syntax:
_.truncate([string=''], [options={}])

Parameters: This method accepts two parameters as mentioned above and described below:
[string=”]: It is the string to be truncated.
[options={}]: It is the options object.
Here, the options field are as follows:
[options.length]: It is the maximum string length which is by default 30.[options.omission=’...’]: It is the string which will indicate that the stated text is omitted.[options.separator] (RegExp|string): It is the separator pattern which is to be truncated.
[options.length]: It is the maximum string length which is by default 30.
[options.omission=’...’]: It is the string which will indicate that the stated text is omitted.
[options.separator] (RegExp|string): It is the separator pattern which is to be truncated.
Return Value: This method returns the truncated string.
Example 1:
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Calling _.truncate() method with // its parameterlet res = _.truncate(  'GeeksforGeeks is a computer science portal.');  // Displays outputconsole.log(res);
Output:
GeeksforGeeks is a computer...
Here, the stated string is longer than the maximum length of the string so its truncated and the truncated string to be returned in the output must be of length 30 including the omission string.
Example 2:  
Javascript
// Requiring lodash libraryconst _ = require('lodash');  // Calling _.truncate() method with // its parameterlet res = _.truncate(  'GeeksforGeeks, is a computer science portal.', {     'length': 22,     'omission': '***'   });  // Displays outputconsole.log(res);
Output:
GeeksforGeeks, is a***
Here, the maximum length of the string as well as omission string both are specified. So, the resultant output is returned according to that.
JavaScript-Lodash
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 ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to connect a progress bar to a function in Tkinter?

A Progress Bar helps to visualize the state of a running process. We have used and interacted with many progress bars such as getting the status of downloading a file from the internet, Loading a file on the local system, etc.
Let us suppose that we want to create and connect a progress bar in our application. We will create a full-width progress bar by using ProgressBar(win, options) method. It can be configured through a button that enables and disables it.
#Import the required Libraries
from tkinter import *
from tkinter import ttk
import time

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

#Set the geometry
win.geometry("750x250")

#Define a function to Show a Progress Bar
#Create a ProgressBar in a function
def run_progress():
   my_progress= ttk.Progressbar(win, orient= HORIZONTAL, length= 500, mode= 'determinate')
   my_progress['value']+=500
   my_progress.pack(pady=40)
   button.config(state= "disable")

#Create a Button
button=ttk.Button(win, text= "Run",command= run_progress)
button.place(x= 340, y= 100)

win.mainloop()
Now run the above code to display a window that contains a progress bar.
In the given output, if we will click the "Run" Button, it will start running the Progress Bar.
Python Program to Form a New String where the First Character and the Last Character have been Exchanged

When it is required to form a new string where the first and last characters are exchanged, a method can be defined that uses indexing to form the new string.
Below is the demonstration of the same −
 Live Demo
def exchange_val(my_string):
   return my_string[-1:] + my_string[1:-1] + my_string[:1]

my_string = “Hi there how are you”
print(“The string is :”)
print(my_string)
print(“The modified string is :”)
print(exchange_val(my_string))
The string is :
Hi there how are you
The modified string is :
ui there how are yoH
A method named ‘exchange_val’ is defined that takes a string as a parameter.
A method named ‘exchange_val’ is defined that takes a string as a parameter.
It uses indexing to exchange the first and last characters of a string.
It uses indexing to exchange the first and last characters of a string.
Outside the method, a string is defined, and is displayed on the console.
Outside the method, a string is defined, and is displayed on the console.
This method is called by passing the string as a parameter to it.
This method is called by passing the string as a parameter to it.
This is displayed as output on the console.
This is displayed as output on the console.
Tryit Editor v3.6 - Show Node.js Command Prompt

var fs = require('fs');
​
//create a file named mynewfile1.txt:
fs.appendFile('mynewfile1.txt', 'Hello content!', function (err) {
  if (err) throw err;
Java - The Enumeration Interface

The Enumeration interface defines the methods by which you can enumerate (obtain one at a time) the elements in a collection of objects.
This legacy interface has been superceded by Iterator. Although not deprecated, Enumeration is considered obsolete for new code. However, it is used by several methods defined by the legacy classes such as Vector and Properties, is used by several other API classes, and is currently in widespread use in application code.
The methods declared by Enumeration are summarized in the following table −
boolean hasMoreElements( )
When implemented, it must return true while there are still more elements to extract, and false when all the elements have been enumerated.
Object nextElement( )
This returns the next object in the enumeration as a generic Object reference.
Following is an example showing usage of Enumeration.
import java.util.Vector;
import java.util.Enumeration;

public class EnumerationTester {

   public static void main(String args[]) {
      Enumeration days;
      Vector dayNames = new Vector();
      
      dayNames.add("Sunday");
      dayNames.add("Monday");
      dayNames.add("Tuesday");
      dayNames.add("Wednesday");
      dayNames.add("Thursday");
      dayNames.add("Friday");
      dayNames.add("Saturday");
      days = dayNames.elements();
      
      while (days.hasMoreElements()) {
         System.out.println(days.nextElement()); 
      }
   }
}
This will produce the following result −
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to replace only the first repeated value in a string in MySQL

For this, you can use REGEXP_REPLACE(). Let’s say our string is −
This is my first MySQL query. This is the first tutorial. I am learning for the first time.
We need to replace only the 1st occurrence of a specific word, let’s say “first”. The output should be −
This is my second MySQL query. This is the first tutorial. I am learning for the first time.
Let us create a table −
mysql> create table demo26
−> (
−> value text
−> );
Query OK, 0 rows affected (2.04 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo26 values('This is my first MySQL query. This is the first tutorial. I am learning for the first time.');
Query OK, 1 row affected (0.10 sec)
Display records from the table using select statement −
mysql> select *from demo26;
This will produce the following output −
+---------------------------------------------------------------------------------------------+
| value                                                                                       |
+---------------------------------------------------------------------------------------------+
| This is my first MySQL query. This is the first tutorial. I am learning for the first time. |
+---------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Following is the query to replace only 1st occurrence −
mysql> update demo26
−> set value = REGEXP_REPLACE(value, 'first', 'second', 1, 1 ) ;
Query OK, 1 row affected (0.19 sec)
Rows matched: 1 Changed: 1 Warnings: 0
Display records from the table using select statement −
mysql> select *from demo26;
This will produce the following output −
+----------------------------------------------------------------------------------------------+
| value                                                                                        |
+----------------------------------------------------------------------------------------------+
| This is my second MySQL query. This is the first tutorial. I am learning for the first time. |
+----------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Python | Multiply 2d numpy array corresponding to 1d array - GeeksforGeeks

15 Mar, 2019
Given a two numpy arrays, the task is to multiply 2d numpy array with 1d numpy array each row corresponding to one element in numpy. Let’s discuss a few methods for a given task.
Method #1: Using np.newaxis()
# Python code to demonstrate# multiplication of 2d array# with 1d array  import numpy as np  ini_array1 = np.array([[1, 2, 3], [2, 4, 5], [1, 2, 3]])ini_array2 = np.array([0, 2, 3])  # printing initial arraysprint("initial array", str(ini_array1))  # Multiplying arraysresult = ini_array1 * ini_array2[:, np.newaxis]  # printing resultprint("New resulting array: ", result)
initial array [[1 2 3]
 [2 4 5]
 [1 2 3]]
New resulting array:  [[ 0  0  0]
 [ 4  8 10]
 [ 3  6  9]]

 Method #2: Using axis as none
# Python code to demonstrate# multiplication of 2d array# with 1d array  import numpy as np  ini_array1 = np.array([[1, 2, 3], [2, 4, 5], [1, 2, 3]])ini_array2 = np.array([0, 2, 3])  # printing initial arraysprint("initial array", str(ini_array1))  # Multiplying arraysresult = ini_array1 * ini_array2[:, None]  # printing resultprint("New resulting array: ", result)
initial array [[1 2 3]
 [2 4 5]
 [1 2 3]]
New resulting array:  [[ 0  0  0]
 [ 4  8 10]
 [ 3  6  9]]

 Method #3: Using transpose()
# python code to demonstrate# multiplication of 2d array# with 1d array  import numpy as np  ini_array1 = np.array([[1, 2, 3], [2, 4, 5], [1, 2, 3]])ini_array2 = np.array([0, 2, 3])  # printing initial arraysprint("initial array", str(ini_array1))  # Multiplying arraysresult = (ini_array1.T * ini_array2).T  # printing resultprint("New resulting array: ", result)
initial array [[1 2 3]
 [2 4 5]
 [1 2 3]]
New resulting array:  [[ 0  0  0]
 [ 4  8 10]
 [ 3  6  9]]

Python numpy-program
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
How to call the constructor of a superclass from a constructor in java?

Whenever you inherit/extend a class, a copy of superclass’s members is created in the subclass object and thus, using the subclass object you can access the members of both classes.
In the following example we have a class named SuperClass with a method with name demo(). We are extending this class with another class (SubClass).
Now, you create an object of the subclass and call the method demo().
class SuperClass{
   public void demo() {
      System.out.println("demo method");
   }
}
public class SubClass extends SuperClass {
   public static void main(String args[]) {
      SubClass obj = new SubClass();
      obj.demo();
   }
}
demo method
In inheritance constructors are not inherited. You need to call them explicitly using the super keyword.
If a Super class have parameterized constructor. You need to accept these parameters in the sub class’s constructor and within it, you need to invoke the super class’s constructor using “super()” as −
public Student(String name, int age, String branch, int Student_id){
   super(name, age);
   this.branch = branch;
   this.Student_id = Student_id;
}
Following java program demonstrates how to call a super class’s constructor from the constructor of the sub class using the super keyword.
class Person{
   public String name;
   public int age;
   public Person(String name, int age){
      this.name = name;
      this.age = age;
   }
   public void displayPerson() {
      System.out.println("Data of the Person class: ");
      System.out.println("Name: "+this.name);
      System.out.println("Age: "+this.age);
   }
}
public class Student extends Person {
   public String branch;
   public int Student_id;
   public Student(String name, int age, String branch, int Student_id){
      super(name, age);
      this.branch = branch;
      this.Student_id = Student_id;
   }
   public void displayStudent() {
      System.out.println("Data of the Student class: ");
      System.out.println("Name: "+this.name);
      System.out.println("Age: "+this.age);
      System.out.println("Branch: "+this.branch);
      System.out.println("Student ID: "+this.Student_id);
   }
   public static void main(String[] args) throws CloneNotSupportedException {
      Person person = new Student("Krishna", 20, "IT", 1256);
      person.displayPerson();
   }
}
Data of the Person class:
Name: Krishna
Age: 20
GATE | GATE CS 2010 | Question 6 - GeeksforGeeks

19 Oct, 2020
The minterm expansion of f(P, Q, R) = PQ + QR’ + PR’ is(A) m2 + m4 + m6 + m7(B) m0 + m1 + m3 + m5(C) m0 + m1 + m6 + m7(D) m2 + m3 + m4 + m5Answer: (A)Explanation: K-map,
= PQ + QR’ + PR’ 
= PQ(R+R’) + (P+P’)QR’ + P(Q+Q’)R’
= PQR + PQR’ +PQR’ +P’QR’ + PQR’ + PQ’R’ 
= PQR(m7) + PQR'(m6)+P’QR'(m2) +PQ’R'(m4) 
= m2 + m4 + m6 + m7 
Option (A) is correct.Quiz of this Question
madarsh986
GATE-CS-2010
GATE-GATE CS 2010
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-2016 (Set 2) | Question 48
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
Multithreading in C


Multithreading is a specialized form of multitasking and a multitasking is the feature that allows your computer to run two or more programs concurrently. In general, there are two types of multitasking: process-based and thread-based.
Process-based multitasking handles the concurrent execution of programs. Thread-based multitasking deals with the concurrent execution of pieces of the same program.
A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.
C does not contain any built-in support for multithreaded applications. Instead, it relies entirely upon the operating system to provide this feature.
This tutorial assumes that you are working on Linux OS and we are going to write multi-threaded C program using POSIX. POSIX Threads, or Pthreads provides API which are available on many Unix-like POSIX systems such as FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris.
The following routine is used to create a POSIX thread −
#include <pthread.h>
pthread_create (thread, attr, start_routine, arg)
Here, pthread_create creates a new thread and makes it executable. This routine can be called any number of times from anywhere within your code. Here is the description of the parameters.
The maximum number of threads that may be created by a process is implementation dependent. Once created, threads are peers, and may create other threads. There is no implied hierarchy or dependency between threads.
There is following routine which we use to terminate a POSIX thread –
#include <pthread.h>
pthread_exit (status)
Here pthread_exit is used to explicitly exit a thread. Typically, the pthread_exit() routine is called after a thread has completed its work and is no longer required to exist.
If main() finishes before the threads it has created, and exits with pthread_exit(), the other threads will continue to execute. Otherwise, they will be automatically terminated when main() finishes.
#include <iostream>
#include <cstdlib>
#include <pthread.h>
using namespace std;
#define NUM_THREADS 5
void *PrintHello(void *threadid) {
   long tid;
   tid = (long)threadid;
   printf("Hello World! Thread ID, %d\n", tid);
   pthread_exit(NULL);
}
int main () {
   pthread_t threads[NUM_THREADS];
   int rc;
   int i;
   for( i = 0; i < NUM_THREADS; i++ ) {
      cout << "main() : creating thread, " << i << endl;
      rc = pthread_create(&threads[i], NULL, PrintHello, (void *)i);
      if (rc) {
         printf("Error:unable to create thread, %d\n", rc);
         exit(-1);
      }
   }
   pthread_exit(NULL);
}
$gcc test.cpp -lpthread
$./a.out
main() : creating thread, 0
main() : creating thread, 1
main() : creating thread, 2
main() : creating thread, 3
main() : creating thread, 4
Hello World! Thread ID, 0
Hello World! Thread ID, 1
Hello World! Thread ID, 2
Hello World! Thread ID, 3
Hello World! Thread ID, 4
Powershell - Create File

New-Item cmdlet is used to create a file by passing the path using -Path as path of the file and -ItemType as File.
In this example, we'll create a file in D:\Temp\Test Folder with name "Test File.txt"
Type the following command in PowerShell ISE Console
New-Item -Path 'D:\temp\Test Folder\Test File.txt' -ItemType File
You will see the following output.
Directory: D:\temp

Mode                LastWriteTime     Length Name                                               
----                -------------     ------ ----                                               
-a---          4/3/2018   7:14 PM          0  Test File.txt   

You can see the same in Windows Explorer where Test File.txt is created in D:/temp/Test Folder directory.

    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
JavaScript Arithmetic

Arithmetic operators perform arithmetic on numbers (literals or variables).
A typical arithmetic operation operates on two numbers.
The two numbers can be literals:
or variables:
or expressions:
The numbers (in an arithmetic operation) are called operands.
The operation (to be performed between the two operands) is defined by an operator.
The addition operator (+) adds numbers:
The subtraction operator (-) subtracts numbers.
The multiplication operator (*) multiplies numbers.
The division operator (/) divides numbers.
The modulus operator (%) returns the division remainder.
In arithmetic, the division of two integers produces a quotient
and a remainder.
In mathematics, the result of a modulo operation is the remainder of an arithmetic division.

The increment operator (++) increments numbers.
The decrement operator (--) decrements numbers.
The exponentiation operator (**) raises the first operand to the power of the second operand.
x ** y produces the same result as Math.pow(x,y):
Operator precedence describes the order in which operations are performed in 
an arithmetic expression.
Is the result of example above the same as 150 * 3, or is it the same as 100 
+ 150?
Is the addition or the multiplication done first?
As in traditional school mathematics, the multiplication is done first.
Multiplication (*) and division (/) have higher precedence than 
addition (+) and subtraction (-).
And (as in school mathematics) the precedence can be changed by using 
parentheses:
When using parentheses, the operations inside the parentheses are computed 
first. 
When many operations have the same precedence (like addition and 
subtraction), they are computed from left to 
right: 
Pale red entries indicates ECMAScript 2015 (ES6) or higher.
Expressions in parentheses are fully computed before the value is 
used in the rest of the expression.
Divide 10 by 2, and alert the result.
alert(10  2);

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

$_ENV is another superglobal associative array in PHP. It stores environment variables available to current script. $HTTP_ENV_VARS also contains the same information, but is not a superglobal, and now been deprecated.
Environment variables are imported into global namespace. Most of these variables are provided by the shell under which PHP parser is running. Hence, list of environment variables may be different on different platforms.
This array also includes CGI variables in case whether PHP is running as a server module orCGI processor.
PHP library has getenv()function to retrieve list of all environment variables or value of a specific environment variable
Following script displays values of all available environment variables
<?php
$arr=getenv();
foreach ($arr as $key=>$val)
echo "$key=>$val
";
?>
To obtain value of specific variable use its name as argument for getenv() function
 Live Demo
<?php
echo "Path: " . getenv("PATH");
?>
Browser will display result similar to following
Path: /usr/local/bin/factor:/root/.sdkman/candidates/kotlin/current/bin:/usr/GNUstep/System/Tools:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/scriba/bin:/usr/local/smlnj/bin:/usr/local/bin/std:/usr/local/bin/extra:/usr/local/fantom/bin:/usr/local/dart/bin:/usr/libexec/sdcc:/usr/local/icon-v950/bin:/usr/local/mozart/bin:/opt/Pawn/bin:/opt/pash/Source/PashConsole/bin/Debug/:.:/root/.sdkman/candidates/kotlin/current/bin:/usr/bin:/sbin:/bin
PHP also has putenv() function to create a new environment variable. The environment variable will only exist for the duration of the current request.
Changing value of certain environment variables should be avoided. By default, users will only be able to set environment variables that begin with PHP_ (e.g. PHP_FOO=BAR).
The safe_mode_protected_env_vars directive in php.ini contains a comma-delimited list of environment variables, that the end user won't be able to change using putenv().
 Live Demo
<?php
putenv("PHP_TEMPUSER=GUEST");
echo "Temp user: " . getenv("PHP_TEMPUSER");
?>
Browser will display result as following
Temp user: GUEST
How to check windows certificate expiry date using PowerShell?

To get the particular windows certificate expiry date from the particular store, we first need the full path of that certificate along with a thumbprint. If the thumbprint is not known to you, we can use the friendly name.
With the thumbprint,
Get-ChildItem Cert:\LocalMachine\root\0563B8630D62D75 | fl *
When you run the above command, it will get all the details of the certificate having thumbprint 0563B8630D62D75.
There you can see there are two fields listed, NotAfter and NotBefore which shows the expiry and start dates respectively. To filter them out,
Get-ChildItem Cert:\LocalMachine\root\0563B8630D62D75 | Select FriendlyName, NotAfter,NotBefore
FriendlyName NotAfter   NotBefore
------------ --------   ---------
DigiCert     11/9/2031  4:00:00 PM 11/9/2006 4:00:00 PM
With the FriendlyName property,
Get-ChildItem Cert:\LocalMachine\root\ | where{$_.FriendlyName -eq “DigiCert”} | Select FriendlyName, NotAfter,NotBefore
To get the details from the remote computer, use the Invoke-Command.
Invoke-Command -ComputerName Test1PC, Test2PC -ScriptBlock {
   Get-ChildItem Cert:\LocalMachine\root\ | where{$_.FriendlyName -eq “DigiCert”} | Select FriendlyName, NotAfter,NotBefore
}
JavaScript Function Literals

JavaScript 1.2 introduces the concept of function literals which is another new way of defining functions. A function literal is an expression that defines an unnamed function.
The syntax for a function literal is much like a function statement, except that it is used as an expression rather than a statement and no function name is required.
<script type = "text/javascript">
   <!--
      var variablename = function(Argument List) {
         Function Body 
      };
   //-->
</script>

Syntactically, you can specify a function name while creating a literal function as follows.
<script type = "text/javascript">
   <!--
      var variablename = function FunctionName(Argument List) {
         Function Body
      };
   //-->
</script>

But this name does not have any significance, so it is not worthwhile.
Try the following example. It shows the usage of function literals.
<html>
   <head>
      <script type = "text/javascript">
         <!--
            var func = function(x,y) { 
               return x*y 
            };
            function secondFunction() {
               var result;
               result = func(10,20);
               document.write ( result );
            }
         //-->
      </script>
   </head>
   
   <body>
      <p>Click the following button to call the function</p>
      
      <form>
         <input type = "button" onclick = "secondFunction()" value = "Call Function">
      </form>
      
      <p>Use different parameters inside the function and then try...</p>
   </body>
</html>
Click the following button to call the function
Use different parameters inside the function and then try...

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
HTML | type Attribute - GeeksforGeeks

06 Jul, 2021
The HTML type Attribute is used to specify the type of button for <button> elements. It is also used in the <input> element to specify the type of input to display. For embed elements like link, object, script, source, and style used to specify the Internet Media Type.  
Syntax: 
<element type="value"> 
Supported Tags: 
<a>
<area>
<embed>
<input>
<link>
<menu>
<object>
<script>
<source>
<style>
The below example illustrates the use of type attribute in HTML:
Example: 
html
<!DOCTYPE html><html>    <head>        <title>            HTML type Attribute        </title>    </head>         <body>        <h1>GeeksforGeeks</h1>                 <h3>HTML type Attribute</h3>                 <form action="#" method="get">            Username: <input type="text" name="uname">                         <br><br>                         Password: <input type="password" name="pwd">                         <br><br>                         <button type="submit" value="submit">                Submit            </button>                         <button type="reset" value="reset">                Reset            </button>        </form>    </body></html>                   
Output:  
Supported Browsers: The browser supported by HTML type attributes are 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.
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
C# Program to display a string in reverse alphabetic order

Set a string array and convert it to character array −
string str = "Amit";
char[] arr = str.ToCharArray();
Now, use the Reverse method to display the above string in reverse alphabetic order −
Array.Reverse(arr);
Here is the complete code −
 Live Demo
using System;
using System.Linq;
using System.IO;
class Program {
   static void Main() {
      string str = "Amit";
      char[] arr = str.ToCharArray();
      Console.WriteLine("Original String: "+str);
      // Reverse
      Array.Reverse(arr);
      Console.WriteLine("Reversed String: "+new string(arr));
   }
}
Original String: Amit
Reversed String: timA
How to change the background color of a plot created by using plot function in R?

To change the focus of a plot we can do multiple things and one such thing is changing the background of the plot. If the background color of a plot is different than white then obviously it will get attention of the readers because this is unusual as most of the times the plots have white backgrounds, hence if we want to attract readers on the plot then we might use this technique. It can be done by using par(bg= "color_name").
Creating a simple histogram −
 Live Demo
> x<-rnorm(100)
> hist(x)
Creating histogram with different background colors −
> par(bg="green")
> hist(x)
> par(bg="yellow")
> hist(x)
par(bg="blue")
> hist(x)
jQuery Examples - $("ul li:first")

"$("ul li:first")" get only the first <li> element of the <ul>.
Here is the simple syntax to use this selector −
$("tagname child-element:first")

Here is the description of all the parameters used by this selector −
tagname − Any standard container tag name like ol, ul etc.
tagname − Any standard container tag name like ol, ul etc.
child-element − list items li
child-element − list items li
:first − filter to get first element.
:first − filter to get first element.
This selector returns the first element.
<html>
   <head>
      <title>The Selector Example</title>
      <script type = "text/javascript" 
         src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
            /* Select link with an id of first and a class of big.*/
            $("ul li:first").css("background-color", "yellow");
         });
      </script>
   </head>
	
   <body>
      <ul>
         <li><a id = "first" class="big" href="#">Big</a></li>
         <li><a id = "first" class="medium" href="#">Medium</a></li>
         <li><a id = "first" class="small" href="#">Small</a></li>
      </ul>
   </body>
</html>
This will produce following result −
Big
Medium
Small
 Print
 Add Notes
 Bookmark this page