code-rag-bench/online-tutorials huggingface dataset:
C++ Boolean Matrix

Boolean matrix is a matrix that has only two elements 0 and 1. For this boolean Matrix question, we have a boolean matrix arr[m][n] of size mXn. And the condition to solve is, if m[i][j] = 1 then m[i] = 1 and m[j] = 1 which means all elements of the ith row and jth column will become 1.
Let’s take an example,
Input: arr[2][2] = 1 0
                   0 0
Output: arr[2][2] = 1 1
                    1 0
Explanation− arr[0][0] = 1 which means arr[0][0]=arr[0][1]=1 & arr[0][0]=arr[1][0]=1.
Here, we will take two flag variables and check if the rows and columns need to be changed to one of not. If yes flag = 1 otherwise 0. And then based on this flag value we will change the values of the elements of the rows and columns. We will do the same procedure for all the elements of the array.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
const int R = 3;
#define C 4
void matrixflip(int mat[R][C]) {
   int row_flag = 0;
   int col_flag = 0;
   for (int i = 0; i < R; i++) {
      for (int j = 0; j < C; j++) {
         if (i == 0 && mat[i][j] == 1)
            row_flag = 1;
         if (j == 0 && mat[i][j] == 1)
            col_flag = 1;
         if (mat[i][j] == 1) {
            mat[0][j] = 1;
            mat[i][0] = 1;
         }
      }
   }
   for (int i = 1; i < R; i++) {
      for (int j = 1; j < C; j++) {
         if (mat[0][j] == 1 || mat[i][0] == 1) {
            mat[i][j] = 1;
         }
      }
   }
   if (row_flag) {
      for (int i = 0; i < C; i++) {
         mat[0][i] = 1;
      }
   }
   if (col_flag) {
      for (int i = 0; i < R; i++) {
         mat[i][0] = 1;
      }
   }
}
int main() {
   int mat[R][C] = { { 1, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 1, 0 } };
   cout << "Input Matrix :\n";
   for (int i = 0; i < R; i++) {
      for (int j = 0; j < C; j++) {
         cout << mat[i][j]<<" ";
      }
      cout <<endl;
   }
   matrixflip(mat);
   cout << "Matrix after bit flip :\n";
   for (int i = 0; i < R; i++) {
      for (int j = 0; j < C; j++) {
         cout << mat[i][j]<<" ";
      }
      cout <<endl;
   }
   return 0;
}
Input Martix:
1 0 0 0
0 0 0 0
0 0 1 0
Matirx after bit flip :
1 1 1 1
1 0 1 0
1 1 1 1
CSS Combinators

A combinator is something that explains the relationship between the selectors.
A CSS selector can contain more than one simple selector. Between the simple 
selectors, we can include a combinator.
There are four different combinators in CSS:
descendant selector (space)
child selector (>)
adjacent sibling selector (+)
general sibling selector (~)
The descendant selector matches all elements that are descendants of a specified 
element.
The following example selects all <p> elements inside <div> elements: 
The child selector selects all elements that are the children of a 
specified element.
The following example selects all <p> elements that are  
children of a <div> 
element:
The adjacent sibling selector is used to select an element that is directly 
after another specific element.
Sibling elements must have the same parent element, and "adjacent" means 
"immediately following".
The following example selects the first <p> element that are placed immediately after <div> elements:
The general sibling selector selects all elements that are next siblings of a specified element.
The following example selects all <p> elements that are next siblings of <div> elements: 
Change the color of all <p> elements, that are descendants of <div> elements, to "red".
<style>
 {
  color: red;
}
</style>

<body>

<div>
  <p>This is a paragraph.</p>
  <p>This is a paragraph.</p>
</div>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>

</body>

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.
GATE | GATE-CS-2009 | Question 42 - GeeksforGeeks

28 Jun, 2021
Which of the following statements are TRUE?
I.  There exist parsing algorithms for some programming languages 
     whose complexities are less than O(n3).
II.  A programming language which allows recursion can be implemented 
    with static storage allocation.
III. No L-attributed definition can be evaluated in The framework 
     of bottom-up parsing.
IV. Code improving transformations can be performed at both source 
    language and intermediate code level.
(A) I and II(B) I and IV(C) III and IV(D) I, III and IVAnswer: (B)Explanation: II is false, in recursion, compiler cannot determine the space needed for recursive calls.
III is false.  See http://www.cs.sunysb.edu/~cse304/Fall09/Lectures/attributes-handout.pdfQuiz of this Question
GATE-CS-2009
GATE-GATE-CS-2009
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Number of edges in a perfect binary tree with N levels

10 Mar, 2022
Given a positive integer N, the task is to find the count of edges of a perfect binary tree with N levels.Examples:  
Input: N = 2
Output: 2
  1
 / \
2   3

Input: N = 3
Output: 6
     1
   /    \
  2      3
 / \    /  \
4   5  6    7
 
Approach: It can be observed that for the values of N = 1, 2, 3, ..., a series will be formed as 0, 2, 6, 14, 30, 62, ... whose Nth term is 2N – 2.Below is the implementation of the above approach:  
C++
Java
Python3
C#
Javascript
// C++ implementation of the approach#include <bits/stdc++.h>using namespace std; // Function to return the count// of edges in an n-level// perfect binary treeint cntEdges(int n){    int edges = pow(2, n) - 2;    return edges;} // Driver codeint main(){    int n = 4;     cout << cntEdges(n);     return 0;}
// Java implementation of the approachclass GFG{     // Function to return the count// of edges in an n-level// perfect binary treestatic int cntEdges(int n){    int edges = (int)Math.pow(2, n) - 2;    return edges;} // Driver codepublic static void main(String[] args){    int n = 4;     System.out.println(cntEdges(n));}} // This code is contributed by Code_Mech
# Python3 implementation of the approach # Function to return the count# of edges in an n-level# perfect binary treedef cntEdges(n) :     edges = 2 ** n - 2;         return edges; # Driver codeif __name__ == "__main__" :     n = 4;     print(cntEdges(n)); # This code is contributed by AnkitRai01
// C# implementation of the approachusing System;class GFG{     // Function to return the count// of edges in an n-level// perfect binary treestatic int cntEdges(int n){    int edges = (int)Math.Pow(2, n) - 2;    return edges;} // Driver codepublic static void Main(String[] args){    int n = 4;     Console.Write(cntEdges(n));}} // This code is contributed by Mohit Kumar
<script> // Javascript implementation of the approach // Function to return the count// of edges in an n-level// perfect binary treefunction cntEdges(n){    var edges = Math.pow(2, n) - 2;    return edges;} // Driver codevar n = 4;document.write(cntEdges(n));  </script>
14
 
Time Complexity: O(log n)
Auxiliary Space: O(1)
ankthon
Code_Mech
mohit kumar 29
shubham_singh
noob2000
subhammahato348
Binary Tree
Mathematical
Tree
Mathematical
Tree
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP | Unset() vs Unlink() Function

26 May, 2021
Both the function are used to do some undo operations but used in different situations cause both acts differently. The unlink() function is used when you want to delete the files completely. The unset() Function is used when you want to make that file empty.Unlink() function: The unlink() function is an inbuilt function in PHP which is used to delete a file. The filename of the file which has to be deleted is sent as a parameter and the function returns True on success and False on failure. The unlink() function in PHP accepts two-parameter.Syntax:  
unlink( filename, context )
Parameters: This function accepts two parameters as mentioned above and described below:  
filename: It is a mandatory parameter which specifies the filename of the file which has to be deleted.
context: It is an optional parameter which specifies the context of the file handle which can be used to modify the nature of the stream.
Return Value: It returns True on success and False on failure.Suppose there is a file named ‘gfg.txt’Example:  
php
<?php // PHP program to delete a file named gfg.txt// using unlink() function $file_pointer = fopen('gfg.txt'); // Writing on a file named gfg.txtfwrite($file_pointer, 'A computer science portal for geeks!');fclose($file_pointer); // Using unlink() function to delete a fileunlink('gfg.txt'); ?>
Output:  
1
Note: If we don’t have permissions to the file “gfg.txt”, the unlink() function generates an E_WARNING level error on failure.Unset() function: The Unset() function is an inbuilt function in PHP which is used to remove the content from the file by emptying it. It means that the function clears the content of a file rather deleting it. The unset() function not only clears the file content but also is used to unset a variable, thereby making it empty.Syntax:  
unset( $variable )
Parameter: This function accepts single parameter variable which is required. It is the variable which is needed to be unset.Return Value: This function does not return any value.Example:  
php
<?php      $var = "hello";         // Change would be reflected outside the function function unset_value() {    unset($GLOBALS['var']);}         unset_value();echo $var;?>
Output:  
No output
Difference between unlink() and unset() function:  
 
Akanksha_Rai
Divik Shrivastava
PHP-function
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
How to get parameters from a URL string in PHP?
Download file from URL using PHP
Split a comma delimited string into an array in PHP
How to convert array to string in PHP ?
How to call PHP function on the click of a Button ?
How to get parameters from a URL string in PHP?
Split a comma delimited string into an array in PHP
How to pass JavaScript variables to PHP ?
How to hide an element when printing a web page using CSS?

22 Mar, 2021
The media query is used to hide an element when printing web pages. Use @media print query and set the visibility hidden to that element that needs to hide at printing. 
Example 1: In this example, hide the element h1 at printing time. To hide the element h1 use media query and set visibility:hidden. 
html
<!DOCTYPE html><html>    <head>        <title>Hide element at print</title>        <style>            body {                text-align:center;            }            h1 {                color:green;            }            @media print {               .noprint {                  visibility: hidden;               }            }        </style>    </head>    <body>        <h1 class = "noprint">GeeksforGeeks</h1>         <p>GeeksforGeeks: It is a computer science        portal for geeks</p>     </body></html>                                     
Output: Before printing the page:  
After printing the page:  
Example 2: In this example, use a media query to hide image elements when printing the web pages. 
html
<!DOCTYPE html><html>    <head>        <title>Hide element at printing</title>        <style>            body {                text-align:center;            }            h1 {                color:green;            }            @media print {               img {                  visibility: hidden;               }            }        </style>    </head>    <body>        <h1>GeeksforGeeks</h1>         <p>A computer science portal for geeks</p>         <img src="gfg.png" alt="image">        <style>            .noprint {                visibility: hidden;            }            </style>    </body></html>                   
Output: Before printing the page:  
After printing the page:  
 
AshokJaiswal
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS Props Complete Reference

07 Jun, 2022
React allows us to pass information to a Component (from a parent component to a child component) using something called props (short for properties). Props is basically an object which is available for all the React components. Props are read only and cannot be modified by the component to which it belongs. 
Passing and Accessing props: We can pass props to any component as we declare attributes for any HTML tag. Have a look at the below code snippet:
<Welcome fullName = "Harsh Agarwal" />
In the above code snippet, we are passing a prop named fullName to the component named Welcome. This prop has the value “Harsh Agarwal”. Let us now see how can we access this prop (property).
For a React component, props object will store the prop as key : value pairs and it will look as shown below. fullName is the key and “John Wick” is the value.
props = { fullName: "Harsh Agarwal" }
In case of functional components, we can access a prop value as shown below.
props.propName;
Example:
Javascript
import React from "react";import ReactDOM from "react-dom"; /* Below given code will create a functional component called Welcome.   This component takes one prop called fullName and displays a welcome message   to the user. */ function Welcome(props) {  return (    <div>      <h1>Hello {props.fullName}</h1>      <h2>Welcome to GeeksforGeeks</h2>    </div>  );} /* Below given code will render the HTML returned by the   Welcome component inside the HTML element for which   the id is "root" */ ReactDOM.render(  <Welcome fullName="Harsh Agarwal" />,  document.getElementById("root"));
Output:
 
The Complete list of Props are listed below:
ReactJS | Methods as Props
ReactJS | PropTypes
ReactJS | Props – Set 1
ReactJS | Props – Set 2
Unidirectional Data Flow
ReactJS | State in React
ReactJS | State vs props
ReactJS | Implementing State & Lifecycle
Rohit_Dwivedi
react-js
JavaScript
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is AGP(Accelerated Graphics Port)?

22 May, 2020
An Accelerated Graphics Port (AGP) is a point to point channel that is used for high-speed video output. This port is used to connect graphic cards to a computer’s motherboard. It increases the speed at which machines can render graphics while using the system’s resources more efficiently. The primary purpose of an AGP is to convey 3-D images much more smoothly than is possible on a regular PC.
The AGP was developed by Intel in the year 1996 and was launched in Socket 7 Intel P5 Pentium and Slot 1 P6 Pentium II processors. Gradually everyone started using it. Chipsets like VIA Apollo VP3, SiS 5591/5592, and the ALI Aladdin V were the first Socket 7 chipsets to support AGP.Early AGP boards used graphics processors built around Peripheral Component Interconnect (PCI) and were simply bridged to AGP. It can be said that the AGP is built from the PCI that PCI is the base. Bridging didn’t help the cards benefit much from the new bus except for the increased 66 MHz bus clock and the doubled bandwidth over PCI. Intel’s i740 was explicitly designed to exploit the new features of AGP. In fact, it was designed to texture only from AGP memory.
The various versions of AGP are discussed here
It has high quality and very fast performance.
It has a direct path to the PC’s main memory.
It connects to the CPU and operates at the speed of the processor bus.
It sends video information more quickly to the card for processing.
It uses the main memory to hold 3D images.
It provides the graphics card with two methods of directly accessing texture maps in system memory: pipelining and sideband addressing.
The port is identified by its brown colour.
It enabled to develop new classes of applications on the PC such as 3D CAD/CAM, data visualization and 3D user interfaces.
Direct Memory Execution of textures-The texture maps are directly accessed from the system memory instead of pre-loading the texture data into the Graphic card’s own memory and then accessing it. It eliminates the extra work by allowing the texture to remain in system memory where it can be directly executed on by the graphics chip.
Creation of 3D images- The CPU must perform intensive 3D calculations. The graphics controller processes the texture data and bitmaps. In many cases, the controller has to read elements from 7 or 8 different textures and combine them into a single pixel on the screen. When this calculation is performed, the pixel must be stored in the memory buffer. The memory occupied by these textures are so large, they cannot be stored on the video card’s buffer. With APG they are stored in the main system memory.
AGP was introduced as a replacement for the slower Peripheral Component Interconnect (PCI) interfaces. AGP provides a direct line of communication to the CPU and RAM, which in turn allows for quicker rendering of graphics.
Picked
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bootstrap 4 .btn-outline-success Button class

Use the btn-outline-success class in Bootstrap to set green outline to a button.
Green button outline states success and you can set a button like this −
<button type="button" class="btn btn-outline-success">
  Result
</button>
Above I have set the class on <button> element just like we set a class on any other element in HTML or Bootstrap.
Here is an example to learn how to work with the btn-outline-success class in Bootstrap −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>
<body>
  <h2>Result</h2>
  <p>The following are the subjects:</p>
  <ul class = "list-group">
    <li class = "list-group-item">Maths</li>
    <li class = "list-group-item">Digital Electronics</li>
  </ul>
  <p>For result, click below:</p>
  <button type="button" class="btn btn-outline-success">Result</button>

</body>
</html>
How out-gridview selection works in PowerShell?

With the PowerShell Out-Gridview output, you have an option to select one or multiple selections.
For example, if we run the below command, it will show us the output in the grid format.
PS C:\> Get-Process | Out-GridView
In this output, you don’t get any option to select the rows because its output mode is none. To add the single selection from the output, use the Output mode to single, and for the multiple selections use the output mode to multiple. Once you add the OutpuMode property you can see the OK and Cancel button at the bottom right of the grid.
Single output mode −
PS C:\> Get-Process | Out-GridView -OutputMode Single
We will select cmd and press ok.
NPM(K) PM(M) WS(M) CPU(s) Id    SI ProcessName
------ ----- ----- ------ ----- -- -----------
5      2.36  17.58 0.22   26096 1  cmd
Multiple selections,
PS C:\> Get-Process | Out-GridView -OutputMode Multiple
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ ----- -- -----------
5      2.36  17.42 0.22   26096 1 cmd
41     20.99 7.89  29.95  24040 1 AcroRd32
Create a stopwatch using python

A stopwatch is used to measure the time interval between two events usually in seconds to minutes. It has various usage like in sports or measuring the flow of heat, current etc in an industrial setup. Python can be used to creat a stopwatch by using its tkinter library.
This library will have the GUI features to create a stopwatch showing the  Start, Stop and Reset  option. The key component of the program is using the lable.after()  module of tkinter.
label.after(parent, ms, function = None)
where
parent: The object of the widget which is using this function.
ms: Time in miliseconds.
function: Call back function
In the below program we use this method as out key component of the program and design a widget showing the GUI features in the stopwatch.
import tkinter as tink
count = -1
run = False
def var_name(mark):
   def value():
      if run:
         global count
         # Just beore starting
         if count == -1:
            show = "Starting"
         else:
            show = str(count)
         mark['text'] = show
         #Increment the count after
         #every 1 second
         mark.after(1000, value)
         count += 1
   value()
# While Running
def Start(mark):
   global run
   run = True
   var_name(mark)
   start['state'] = 'disabled'
   stop['state'] = 'normal'
   reset['state'] = 'normal'
# While stopped
def Stop():
   global run
   start['state'] = 'normal'
   stop['state'] = 'disabled'
   reset['state'] = 'normal'
   run = False
# For Reset
def Reset(label):
   global count
   count = -1
   if run == False:
      reset['state'] = 'disabled'
      mark['text'] = 'Welcome'
   else:
      mark['text'] = 'Start'

base = tink.Tk()
base.title("PYTHON STOPWATCH")
base.minsize(width=300, height=200)
mark = tink.Label(base, text="Welcome", fg="blue", font="Times 25 bold",bg="white")
mark.pack()
start = tink.Button(base, text='Start',width=25, command=lambda: Start(mark))
stop = tink.Button(base, text='Stop', width=25, state='disabled', command=Stop)
reset = tink.Button(base, text='Reset',width=25, state='disabled', command=lambda: Reset(mark))
start.pack()
stop.pack()
reset.pack()
base.mainloop()
The below images show the three different scenarios when the stopwatch is run.
Perl continue Statement

A continue BLOCK, is always executed just before the conditional is about to be evaluated again. A continue statement can be used with while and foreach loops. A continue statement can also be used alone along with a BLOCK of code in which case it will be assumed as a flow control statement rather than a function.
The syntax for a continue statement with while loop is as follows −
while(condition) {
   statement(s);
} continue {
   statement(s);
}

The syntax for a continue statement with foreach loop is as follows −
foreach $a (@listA) {
   statement(s);
} continue {
   statement(s);
}

The syntax for a continue statement with a BLOCK of code is as follows −
continue {
   statement(s);
}

The following program simulates a for loop using a while loop −
#/usr/local/bin/perl
   
$a = 0;
while($a < 3) {
   print "Value of a = $a\n";
} continue {
   $a = $a + 1;
}
This would produce the following result −
Value of a = 0
Value of a = 1
Value of a = 2

The following program shows the usage of continue statement with foreach loop −
#/usr/local/bin/perl
   
@list = (1, 2, 3, 4, 5);
foreach $a (@list) {
   print "Value of a = $a\n";
} continue {
   last if $a == 4;
}
This would produce the following result −
Value of a = 1
Value of a = 2
Value of a = 3
Value of a = 4


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2015 (Set 3) | Question 49 - GeeksforGeeks

28 Jun, 2021
Consider the following recursive C function. If get(6) function is being called in main() then how many times will the get() function be invoked before returning to the main()?
void get (int n){   if (n < 1) return;   get(n-1);   get(n-3);   printf("%d", n);}
(A) 15(B) 25(C) 35(D) 45Answer: (B)Explanation:
                              get(6) [25 Calls]
                              /      \
               [17 Calls] get(5)       get(3) [7 Calls]
                        /     \
                    get(4)    get(2)[5 Calls]
                   /    \ 
     [7 Calls] get(3)  get(1)[3 Calls]
                /     \
             get(2)   get(0)
            /    \
[3 Calls]get(1)  get(-1) 
   /  \
get(0) get(-2)
We can verify the same by running below program.
# include <stdio.h>int count = 0;  void get (int n){    count++;    if (n < 1) return;    get(n-1);    get(n-3);}int main(){    get(6);    printf("%d ", count);}
Output: 25Quiz of this Question
GATE-CS-2015 (Set 3)
GATE-GATE-CS-2015 (Set 3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE CS 2012 | Question 40
MomentJS - Locale

This method helps to get/set the duration using locale. When used with humanize, you will see the difference in output for locale() method.
moment.duration().locale();
moment.duration().locale(String);

var hi = moment.duration(1, "day").locale("hi").humanize();
var en = moment.duration(1, "minutes").locale("en").humanize();
var ja = moment.duration(1, "seconds").locale("ja").humanize();
var it = moment.duration(1, "hours").locale("it").humanize();
var marathi = moment.duration(1, "day").locale("mr").humanize();
var konkani = moment.duration(1, "day").locale("gom-latn").humanize();
var kn = moment.duration(1, "day").locale("kn").humanize();
 Print
 Add Notes
 Bookmark this page
C program to implement Euclid’ s algorithm

Implement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers and to output the results along with the given integers.
The solution to implement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers is as follows −
The logic used to find GCD and LCM is as follows −
if(firstno*secondno!=0){
   gcd=gcd_rec(firstno,secondno);
   printf("\nThe GCD of %d and %d is %d\n",firstno,secondno,gcd);
   printf("\nThe LCM of %d and %d is %d\n",firstno,secondno,(firstno*secondno)/gcd);
}
The called function is as follows −
int gcd_rec(int x, int y){
   if (y == 0)
      return x;
   return gcd_rec(y, x % y);
}
Following is the C program to implement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers −
 Live Demo
#include<stdio.h>
int gcd_rec(int,int);
void main(){
   int firstno,secondno,gcd;
   printf("Enter the two no.s to find GCD and LCM:");
   scanf("%d%d",&firstno,&secondno);
   if(firstno*secondno!=0){
      gcd=gcd_rec(firstno,secondno);
      printf("\nThe GCD of %d and %d is %d\n",firstno,secondno,gcd);
      printf("\nThe LCM of %d and %d is %d\n",firstno,secondno,(firstno*secondno)/gcd);
   }
   else
      printf("One of the entered no. is zero:Quitting\n");
   }
   /*Function for Euclid's Procedure*/
   int gcd_rec(int x, int y){
   if (y == 0)
      return x;
   return gcd_rec(y, x % y);
}
When the above program is executed, it produces the following result −
Enter the two no.s to find GCD and LCM:4 8

The GCD of 4 and 8 is 4

The LCM of 4 and 8 is 8
How to format date string in PowerShell?

By default the when you run the (Get-Date) cmdlet, its output is in the below format.
PS C:\WINDOWS\system32> Get-Date
18 March 2020 22:56:18
You can format the above output in the various format supported by PowerShell.
d – Short date pattern.
d – Short date pattern.
PS C:\WINDOWS\system32> Get-Date -Format d
18-03-2020
D – Long date pattern
D – Long date pattern
PS C:\WINDOWS\system32> Get-Date -Format D
18 March 2020
f – Full date pattern with a short time pattern.
f – Full date pattern with a short time pattern.
PS C:\WINDOWS\system32> Get-Date -Format f
18 March 2020 23:01
F – Full date pattern with a long time pattern.
F – Full date pattern with a long time pattern.
PS C:\WINDOWS\system32> Get-Date -Format F
18 March 2020 23:02:22
g – General date pattern with a short time pattern.
g – General date pattern with a short time pattern.
PS C:\WINDOWS\system32> Get-Date -Format g 18-03-2020 23:03
G – General date pattern with a long time pattern.
G – General date pattern with a long time pattern.
PS C:\WINDOWS\system32> Get-Date -Format G
18-03-2020 23:05:39
M/m – Month day pattern.
M/m – Month day pattern.
PS C:\WINDOWS\system32> Get-Date -Format M
18 March
PS C:\WINDOWS\system32> Get-Date -Format m
18 March
O,o – Round trip date/time pattern
O,o – Round trip date/time pattern
PS C:\WINDOWS\system32> Get-Date -Format O
2020-03-18T23:08:36.8098960+05:30
PS C:\WINDOWS\system32> Get-Date -Format o
2020-03-18T23:08:36.8098960+05:30
R,r – RFC1123 pattern
R,r – RFC1123 pattern
PS C:\WINDOWS\system32> Get-Date -Format R
Wed, 18 Mar 2020 23:10:06 GMT
PS C:\WINDOWS\system32> Get-Date -Format r
Wed, 18 Mar 2020 23:10:06 GMT
s – Sortable Date/Time pattern
s – Sortable Date/Time pattern
PS C:\WINDOWS\system32> Get-Date -Format s
2020-03-18T23:12:12
t – Short time pattern.
t – Short time pattern.
PS C:\WINDOWS\system32> Get-Date -Format t
23:13
T – Long time pattern.
T – Long time pattern.
PS C:\WINDOWS\system32> Get-Date -Format T
23:13:09
u – Universal Sortable date/time pattern.
u – Universal Sortable date/time pattern.
PS C:\WINDOWS\system32> Get-Date -Format u
2020-03-19 20:21:37Z
U – Universal Full date/time format.
U – Universal Full date/time format.
PS C:\WINDOWS\system32> Get-Date -Format U
19 March 2020 14:51:41
Y,y – Year month pattern.
Y,y – Year month pattern.
PS C:\WINDOWS\system32> Get-Date -Format y
March, 2020
PS C:\WINDOWS\system32> Get-Date -Format Y
March, 2020
You can also format Get-Date into the .NET format and for that, you need to use –Format parameter.
.NET format specifier can be used as below.
You can use any of the above combinations to format the date in the required format.
Get-Date -Format "dd/MM/yyyy"
19-03-2020
PS C:\WINDOWS\system32> Get-Date -Format "dd/MM/yyyy -- dddd"
19-03-2020 -- Thursday
PS C:\WINDOWS\system32> Get-Date -Format "HH:mm K"
20:44 +05:30
You can format the date string into the universal format as well and for that, you need to use –Uformat parameter. Below specifiers used for the universal format.
Get-Date -UFormat "%d %m %Y"
19 03 2020
Get-Date -UFormat %R
21:15
How do I split a multi-line string into multiple lines?

We can use the method splitlines() in string class to achieve this. 
>>> """some
multi line
string""".splitlines()
['some', 'multi line', 'string']
We can also specify the delimiter '\n' in the split() method as follows −
>>> """some
multi line
string""".split('\n')
['some', 'multi line', 'string']
Python Pandas - Draw a Bar Plot and use median as the estimate of central tendency

Bar Plot in Seaborn is used to show point estimates and confidence intervals as rectangular bars. The seaborn.barplot() is used for this. Plotting horizontal bar plots with dataset columns as x and y values. Use the estimator parameter to set median as the estimate of central tendency.
Let’s say the following is our dataset in the form of a CSV file − Cricketers2.csv
At first, import the required libraries −
import seaborn as sb
import pandas as pd
import matplotlib.pyplot as plt
from numpy import median
Load data from a CSV file into a Pandas DataFrame −
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers2.csv")

Plotting horizontal bar plots with Matches and Academy using the estimator parameter to set median as the estimate of central tendency −
sb.barplot(x = dataFrame["Academy"], y = dataFrame["Matches"], estimator = median)
Following is the code −
import seaborn as sb
import pandas as pd
import matplotlib.pyplot as plt
from numpy import median

# Load data from a CSV file into a Pandas DataFrame
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers2.csv")

# plotting horizontal bar plots with Matches and Academy
# using the estimator parameter to set median as the estimate of central tendency
sb.barplot(x = dataFrame["Academy"], y = dataFrame["Matches"], estimator = median)

# display
plt.show()
This will produce the following output −
How to read data from *.CSV file using JavaScript?

To read .CSV using JavaScript, use the open-source CSV parser, Papa Parser. The following are the features −
Open Source
Parse millions of data using multi-threaded CSV parser
Supports multiple web browsers
Using the parser, you can easily skip commented characters
Let’s say your CSV file isn’t on your system. What will you do? Well, just use the following code snippet to get the file to parse from any link −
Papa.parse("http://example.com/myfile.csv", {

   download: true,
   complete: function(results) {
      document.write(results);
   }
});
C Program to Multiply two Floating Point Numbers?

Float is a shortened term for "floating-point." By definition, it's a fundamental data type built into the compiler that's used to define numeric values with floating decimal points. A floating-point type variable is a variable that can hold a real number, such as 4320.0, -3.33, or 0.01226. The floating part of the name floating point refers to the fact that the decimal point can “float”; that is, it can support a variable number of digits before and after the decimal point.
Input − a=11.23 b=6.7 
Output − 75.241 
Explanation − Use of Float variables. In this program, the user has two numbers (floating point numbers)means float variables. Then, the product of those two numbers is stored in a variable and displayed on the screen.
#include <stdio.h>
int main() {
   float a, b, c;
   a=11.23; b=6.7;
   c = (float)(a*b);
   // Displaying result up to 3 decimal places.
   printf("%3f", c);
   return 0;
}
75.241
What are auto and decltype in  C++?

Auto is a keyword in C++11 and later that is used for automatic type deduction. Type inference or deduction refers to the automatic detection of the data type of an expression in a programming language. It is a feature present in some strongly statically typed languages. For example, you want to create an iterator to iterate over a vector, you can simply use auto for that purpose. 
#include<iostream>
#include<vector>
using namespace std;
int main() {
   vector<int> arr(10);
   for(auto it = arr.begin(); it != arr.end(); it ++) {
      cin >> *it;
   }
   return 0;
}
In the above program, it will automatically get the type std:: vector<int>:: iterator.
The decltype type specifier yields the type of a specified expression. Unlike auto that deduces types based on values being assigned to the variable, decltype deduces the type from an expression passed to it. The value returned by decltype can directly be used to define another variable. For example, the above code can be written as the following using decltype −
#include <iostream>
#include <vector>
using namespace std;
int main() {
   vector<int> arr(10);
   for (decltype(arr.begin()) it = arr.begin(); it != arr.end(); it++) {
      cin >> *it;
   }
   return 0;
}

Note that The type denoted by decltype can be different from the type deduced by auto. You can read more about these subtle differences in this 12-page explanation of type deduction in C++ −http://thbecker.net/articles/auto_and_decltype/section_01.html
DB2 - with XML

This chapter describes use of XML with DB2.
PureXML feature allows you to store well-formed XML documents in columns of database tables. Those columns have XML database. Data is kept in its native hierarchical form by storing XML data in XML column. The stored XML data can be accessed and managed by DB2 database server functionality.  The storage of XML data in its native hierarchical form enables efficient search, retrieval, and update of XML. To update a value in XML data, you need to use XQuery, SQL or combination of both.
Create a database by issuing the following syntax:
Syntax:
db2 create database xmldb 
By default, databases use UTF-8 (UNICODE) code set. Activate the database and connect to it:
Syntax:
db2 activate db <db_name>
db2 connect to <db_name> 
Example:
db2 activate db xmldb 
db2 connect to xmldb  
Create a well-formed XML file and create a table with data type of the column as ‘XML’. It is mandatory to pass the SQL query containing XML syntax within double quotation marks.
Syntax:
db2 “create table <schema>.<table>(col <datatype>, 
col <xml datatype>)” 
Example:
db2 "create table shope.books(id bigint not null 
primary key, book XML)"   
Insert xml values into table, well-formed XML documents are inserted into XML type column using SQL statement ‘INSERT’.
Syntax:
db2 “insert into <table_name> values(value1, value2)” 
Example:
db2 "insert into shope.books values(1000, '<catalog>  
<book> 

<author> Gambardella Matthew</author> 
<title>XML Developers Guide</title> 
<genre>Computer</genre> 
<price>44.95</price> 
<publish_date>2000-10-01</publish_date> 
<description>An in-depth look at creating application 
with XML</description> 
</book> 

</catalog>')"   
You can update XML data in a table by using the following syntax:
Syntax:
db2 “update <table_name> set <column>=<value> where 
<column>=<value>”  
Example:
db2 "update shope.books set book='<catalog>  

<book> 
<author> Gambardella, Matthew</author>  
<title>XML Developers Guide</title>  
<genre>Computer</genre>  
<price>44.95</price>  
<publish_date>2000-10-01</publish_date>  
<description>An in-depth XML</description>
  
</book> 
 
</catalog>' where id=1000"  

    10 Lectures 
     1.5 hours 

 Nishant Malik

    41 Lectures 
     8.5 hours 

 Parth Panjabi

    53 Lectures 
     11.5 hours 

 Parth Panjabi

    33 Lectures 
     7 hours 

 Parth Panjabi

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    178 Lectures 
     14.5 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Java Examples - Swing applet in JAVA?

How to use swing applet in JAVA?
Following example demonstrates how to go use Swing Applet in JAVA by implementing ActionListener & by creating JLabels.
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class SApplet extends Applet implements ActionListener {
   TextField input,output;
   Label label1,label2;
   Button b1;
   JLabel lbl;
   int num, sum = 0;
   
   public void init() {
      label1 = new Label("please enter number : ");
      add(label1);
      label1.setBackground(Color.yellow);
      label1.setForeground(Color.magenta);
      input = new TextField(5);
      
      add(input);
      label2 = new Label("Sum : ");
      
      add(label2);
      label2.setBackground(Color.yellow);
      label2.setForeground(Color.magenta);
      output = new TextField(20);
      
      add(output);
      b1 = new Button("Add");
      
      add(b1);
      b1.addActionListener(this);
      lbl = new JLabel("Swing Applet Example. ");
      add(lbl);
      setBackground(Color.yellow);
   } 
   public void actionPerformed(ActionEvent ae ){
      try {
         num = Integer.parseInt(input.getText());
         sum = sum+num;
         input.setText("");
         output.setText(Integer.toString(sum));
         lbl.setForeground(Color.blue);
         lbl.setText("Output of the second Text Box : " + output.getText());
      } catch(NumberFormatException e) {
         lbl.setForeground(Color.red);
         lbl.setText("Invalid Entry!");
      }
   }  
}
The above code sample will produce the following result in a java enabled web browser.
View in Browser. 

 Print
 Add Notes
 Bookmark this page
Difference between import and package in Java?

In Java classes and interfaces related to each other are grouped under a package. Package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in java.io package.
You can group required classes and interfaces under one package just by declaring the package at the top of the Class/Interface (file) using the keyword package as −
package com.tutorialspoint.mypackage;
public class Sample{
   public void demo(){
      System.out.println("This is a method of the sample class");
   }
   public static void main(String args[]){
      System.out.println("Hello how are you......");
   }
}
Unlike other programs to compile a program with a package, you need to use the –d option of the javac command specifying the destination path where you need to create the package.
javac –d . Sample.java
If you haven’t mentioned the destination path the package will be created in the current directory.
To execute the byte code within a file you need to specify the absolute class name (name along with the package) as −
java com.tutorialspoint.mypackage.Sample
Hello how are you......
To access the classes/interfaces that are grouped under a package, you need to add the location of the package in the classpath variable (or make sure the package is in the current directory) and import the class/interface of it using the import keyword.
import com.tutorialspoint.mypackage.Sample;
public class Test{
   public static void main(String args[]){
      Sample obj = new Sample();
      obj.demo();
   }
}
This is a method of the sample class
As discussed above the package keyword is used to group certain classes and interface under one package and, the import keyword is used include/use the classes and interface from a package in the current program.
How to set multiple cookies in JavaScript?

With JavaScript, to set more than one cookie, set document.cookie more than once using the; separator.
You can try to run the following code to set multiple cookies −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script>
      var num=1;
      function addCookie() {
         document.cookie=num+"="+num;
         num++;
      }
      function listCookies() {
         var result = document.cookie;
         document.getElementById("list").innerHTML=result;
      }
      function removeCookies() {
         var res = document.cookie;
         var multiple = res.split(";");
         for(var i=0;i<multiple.length;i++) {
            var key = multiple[i].split("=");
            document.cookie=key[0]+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
         }
      }
      </script>
   </head>
   <body>
      <button onclick='addCookie()'>ADD</button><br>
      <button onclick='listCookies()'>LIST COOKIES</button><br>
      <button onclick='removeCookies()'>REMOVE</button>
      <h1>Cookies List</h1>
      <p id="list"></p>
   </body>
</html>
Download Anything to Google Drive using Google colab - GeeksforGeeks

30 Oct, 2019
When we download/upload something from a cloud server, it gives more transfer rate as compared to a normal server. We can use Google Drive for storage as well as fast speed download. The problem is how to upload something to G-Drive direct from Internet. So, Here we will see a solution to upload anything to Google drive directly from Internet.
All we need is google account and a few lines of code.
Google Colab:
Google Colab is a free cloud service with GPU support. It is like Jupyter Notebook and very simple to use. In this tutorial, we will be using Google Colab to download anything to our google drive.
Step #1 : Sign in to Google Colab and Create a new Python3 notebook. Step #2 : Importing google drive to colab
To import google drive, write this code in code section of colab and run it by Ctrl+Enter.
from google.colab import drivedrive.mount('/content/gdrive')
On running code, one blue link and a text box will appear we need to provide a permission text. So click the link and a new tab will open where you will be asked for permission to access google drive. After providing permissions a text will be displayed that we need to Copy and paste on colabs text box.
Paste text in box and press enter. That all to import gdrive. We can see google drive on Left side Panel. Step #3 : Download something to Google Drive
To download something all we need is URL to downloadable file.
import requests file_url = "http://1.droppdf.com/files/5iHzx/automate-the-boring-stuff-with-python-2015-.pdf"    r = requests.get(file_url, stream = True)   with open("/content/gdrive/My Drive/python.pdf", "wb") as file:     for block in r.iter_content(chunk_size = 1024):         if block:              file.write(block) 
Run this code to download the files in gdrive (Change the file_url with your file’s url).We can see on the left side panel that pdf file is downloaded.
Conclusion :We can use google colab to download any file on google drive. As you can see a folder parrot (parrot OS of 3.7 GB ), downloaded to gdrive using Colab.
nidhi_biet
GBlog
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Front End Developer Skills That You Need in 2022
DSA Sheet by Love Babbar
6 Best IDE's For Python in 2022
GET and POST requests using Python
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Read JSON file using Python
Python map() function
Python Dictionary
Taking input in Python
Read a file line by line in Python
How to deallocate the Azure VM using Azure CLI in PowerShell?

To deallocate the Azure VM using Azure CLI, we need to use the VM deallocation command az vm deallocate and need to provide the name of the VM and the resource group of the VM.
Before running the deallocation command, make sure that you are connected to the proper azure subscription and the azure account.
PS C:\> az vm deallocate -n VMName -g RGName --verbose
Or you can use
PS C:\> az vm deallocate --name VMName --resource-group RGName --verbose
If you are working on the multiple VMs, you can also apply the --no-wait parameter to continue next operation without waiting for the VM to stop.
PS C:\> az vm deallocate -n VmName -g RGName --no-wait --verbose
How do you make code reusable in C#?

To make code reusable in C#, use Interfaces. Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow.
For example, Shape Interface −
public interface IShape {
   void display();
}
Above we have declared an Interface Shape. You can notice that it begins with a capital “I”. It is a common convention that interfaces names begin with “I”.
We have not added an access specifier above since interface members are public by default.
In real applications, Polymorphism is key for code reuse. Interfaces are flexible because if you use interfaces, then with its help you can pass anything that implements that Interface.
Stopwatch class in C#

Stopwatch is a class in C# to measure the elapsed time. Use it to calculate the time a function took to execute. It is found under System.Diagnostics.
To get the elapsed time, firstly begin the Stopwatch −
var sw = Stopwatch.StartNew();
For elapsed ticks −
long ticks = sw.ElapsedTicks;
Let us see an example −
 Live Demo
using System;
using System.Linq;
using System.Diagnostics;
public class Demo {
   public static void Main() {
      var sw = Stopwatch.StartNew();
      long ticks = sw.ElapsedTicks;
      Console.WriteLine(ticks);
   }
}
582