code-rag-bench/online-tutorials huggingface dataset:
Print Linked List elements | Practice | GeeksforGeeks

Given a linked list. Print all the elements of the linked list.
Example 1:
Input:
N=2
LinkedList={1 , 2}
Output:
1 2
Explanation:
The linked list contains two 
elements 1 and 2.The elements 
are printed in a single line.
Example 2:
Input:
N = 3
Linked List = { 49, 10, 30}
Output: 
49 10 30
Explanation:
The linked list contains 3 
elements 49, 10 and 30. The 
elements are printed in a single 
line.
0
mayank180919991 week ago
void display(struct Node *head)
{
   //add code here
   struct Node *temp=head;
   while(temp!=NULL){
       printf("%d ",temp->data);
       temp=temp->next;
   }
}
0
rk09817251 week ago
Simple Java code snippet
 
 Node n = head;       while(n != null){           System.out.print(n.data + " ");           n = n.next;       }
0
kininarasimha2 weeks ago
#Javascript 
 
class Solution { display(head){   //code here   let curr = head;   let str = "";   while (curr) {       str += curr.data + " ";       curr = curr.next;   }   console.log(str); }}
+1
shahabuddinbravo402 weeks ago
 void display(Node *head)   {     while(head!=NULL){         cout<<head->data<<" ";         head=head->next;     }   }
0
neelasatyasai932 weeks ago
#PYTHON
class Solution:
   def display(self,node):
       #code here
       t=node
       if t==None:
           return 0
       print(t.data,end=" " )
       while t.next!=None:
           t=t.next
           print(t.data,end=" ")
+1
abhiramjammula2 weeks ago
void display(struct Node *head){  //add code here  while(head!=NULL)  {      printf("%d ",head->data);      head=head->next;  }}
0
hharshit81183 weeks ago
void display(struct Node *head){  while(head){      printf("%d ", head->data);      head = head->next;  }}
0
shilsoumyadip3 weeks ago
class Solution{   public: void display(Node *head)   {     while(head!=NULL)     {         cout<<head->data<<" ";         head=head->next ;     }   }}; 
0
yash7raut4 weeks ago
class Solution:   def display(self,node):       #code here       temp = node       while(temp):           print(temp.data,end=" ")           temp = temp.next
0
technophyle11 month ago
Simple and Easy Code :
class Solution
{
    public:
    void display(Node *head)
    {
      //your code goes here
      Node* tmp=head;
      while(tmp!=NULL)
      {
          cout<<tmp->data<<" ";
          tmp=tmp->next ;
      }
    }
};
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Find missing numbers in a sorted list range in Python

Given a list with sorted numbers, we want to find out which numbers are missing from the given range of numbers.
we can design a for loop to check for the range of numbers and use an if condition with the not in operator to check for the missing elements.
 Live Demo
listA = [1,5,6, 7,11,14]

# Original list
print("Given list : ",listA)

# using range
res = [x for x in range(listA[0], listA[-1]+1)
                              if x not in listA]
# Result
print("Missing elements from the list : \n" ,res)
Running the above code gives us the following result −
Given list : [1, 5, 6, 7, 11, 14]
Missing elements from the list :
[2, 3, 4, 8, 9, 10, 12, 13]
The ZIP function
 Live Demo
listA = [1,5,6, 7,11,14]

# printing original list
print("Given list : ",listA)

# using zip
res = []
for m,n in zip(listA,listA[1:]):
   if n - m > 1:
      for i in range(m+1,n):
         res.append(i)

# Result
print("Missing elements from the list : \n" ,res)
Running the above code gives us the following result −
Given list : [1, 5, 6, 7, 11, 14]
Missing elements from the list :
[2, 3, 4, 8, 9, 10, 12, 13]
Determine when a Frame or Window is Opened in Java

To determine when a Window is opened in Java, use the WindowListener, which is the listener interface for receiving window events..
WindowListener listener = new WindowAdapter() {
   public void windowOpened(WindowEvent evt) {
      Frame frame = (Frame) evt.getSource();
      System.out.println("Opened "+frame.getTitle());
   }
};
Above, we have used the windowOpened() method, which is invoked when a window has been opened −
public void windowOpened(WindowEvent evt) {
   Frame frame = (Frame) evt.getSource();
   System.out.println("Opened "+frame.getTitle());
}
The following is an example to determine when a frame or window is opened in Java −
package my;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
public class SwingDemo {
   public static void main(String args[]) throws BadLocationException {
      JFrame frame = new JFrame("Demo");
      WindowListener listener = new WindowAdapter() {
         public void windowOpened(WindowEvent evt) {
            Frame frame = (Frame) evt.getSource();
            System.out.println("Opened "+frame.getTitle());
         }
      };
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Container container = frame.getContentPane();
      JTextPane pane = new JTextPane();
      SimpleAttributeSet attributeSet = new SimpleAttributeSet();
      StyleConstants.setItalic(attributeSet, true);
      StyleConstants.setForeground(attributeSet, Color.black);
      StyleConstants.setBackground(attributeSet, Color.orange);
      pane.setCharacterAttributes(attributeSet, true);
      pane.setText("We are learning Java and this is a demo text!");
      JScrollPane scrollPane = new JScrollPane(pane);
      container.add(scrollPane, BorderLayout.CENTER);
      frame.setSize(550, 300);
      frame.addWindowListener(listener);
      frame.setVisible(true);
   }
}
Tryit Editor v3.6 - Show Node.js

var http = require('http');
​
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
Complex Numbers in Java

Complex numbers are those that have an imaginary part and a real part associated with it. They can
be added and subtracted like regular numbers. The real parts and imaginary parts are respectively
added or subtracted or even multiplied and divided.
 Live Demo
public class Demo{
   double my_real;
   double my_imag;
   public Demo(double my_real, double my_imag){
      this.my_real = my_real;
      this.my_imag = my_imag;
   }
   public static void main(String[] args){
      Demo n1 = new Demo(76.8, 24.0),
      n2 = new Demo(65.9, 11.23),
      temp;
      temp = add(n1, n2);
      System.out.printf("The sum of two complex numbers is %.1f + %.1fi", temp.my_real,
      temp.my_imag);
   }
   public static Demo add(Demo n1, Demo n2){
      Demo temp = new Demo(0.0, 0.0);
      temp.my_real = n1.my_real + n2.my_real;
      temp.my_imag = n1.my_imag + n2.my_imag;
      return(temp);
   }
}
The sum of two complex numbers is 142.7 + 35.2i
A class named Demo defines two double valued numbers, my_real, and my_imag. A constructor is
defined, that takes these two values. In the main function, an instance of the Demo class is created,
and the elements are added using the ‘add’ function and assigned to a temporary object (it is
created in the main function).
Next, they are displayed on the console. In the main function, another temporary instance is
created, and the real parts and imaginary parts of the complex numbers are added respectively, and
this temporary object is returned as output.
C program to find out the maximum value of AND, OR, and XOR operations that are less than a given value

Suppose we are given two integers k and n. Our task is to perform three operations; bitwise AND, bitwise OR, and bitwise XOR between all pairs of numbers up to range n. We return the maximum value of all three operations between any two pairs of numbers that is less than the given value k.
So, if the input is like n = 5, k = 5, then the output will be 4 3 4.
The greatest value of AND, OR, and XOR operations between all pairs of numbers that are less than 5 are 4, 3, and 4 respectively. We can see that the values of these operations are less than that of the given value k, which is 5.
To solve this, we will follow these steps −
andMax := 0, orMax = 0, xorMax = 0
value1 := 0, value2 = 0, value3 = 0
for initialize i := 1, when i <= n, update (increase i by 1), do:value1 := i AND jvalue2 := i OR jvalue3 := i XOR jif value1 > andMax and value1 < k, then −andMax := value1if value2 > orMax and value2 < k, then −orMax := value2if value3 > xorMax and value3 < k, then −xorMax := value3
value1 := i AND j
value2 := i OR j
value3 := i XOR j
if value1 > andMax and value1 < k, then −andMax := value1
andMax := value1
if value2 > orMax and value2 < k, then −orMax := value2
orMax := value2
if value3 > xorMax and value3 < k, then −xorMax := value3
xorMax := value3
print(andMax, orMax, xorMax)
Let us see the following implementation to get better understanding −
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

void solve(int n, int k) {
   int andMax = 0, orMax = 0, xorMax = 0;
   int value1 = 0, value2 = 0, value3 = 0;
   for (int i = 1; i <= n; i++) {
      for (int j = i+1; j <= n; j++) {
         value1 = i & j;
         value2 = i | j;
         value3 = i ^ j;
         if (value1 > andMax && value1 < k)
            andMax = value1;
         if (value2 > orMax && value2 < k)
            orMax = value2;
         if (value3 > xorMax && value3 < k)
            xorMax = value3;
      }
   }
   printf("%d %d %d ", andMax, orMax, xorMax);
}
int main() {
   solve(5, 5);
   return 0;
}
5, 5
4 3 4
HTML - <bdo> Tag

The HTML <bdo> tag is used to override the default text direction.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML bdo Tag</title>
   </head>

   <body>
      <bdo dir = "rtl">Here's some English embedded in text in another language
         requiring a right-to-left presentation.</bdo>
   </body>

</html>
This will produce the following result −
This tag supports all the global attributes described in HTML Attribute Reference
The HTML <bdo> tag also supports the following  additional attributes −
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
How to use spread operator to join two or more arrays in JavaScript?

Two join two or more arrays we have a built-in method called array.concat(). But we can join arrays much more easily by using spread operator.
var merged = [...arr1, ...arr2];
Lets' try to merge arrays without spread operator.
In the following example, instead of the spread operator, array.concat() method is used to join two arrays.
Live Demo
<html>
<body>
   <script>
      var arr1 = [1,2,3];
      var arr2 = [4,5,6];
      var merged = arr1.concat(arr2);
      document.write(merged);
   </script>
</body>
</html>
1,2,3,4,5,6
In the following example, spread operator is used to join two arrays.
Live Demo
<html>
<body>
   <script>
      var arr1 = [1,2,3];
      var arr2 = [4,5,6];
      var merged = [...arr1, ...arr2];
      document.write(merged);
   </script>
</body>
</html>
1,2,3,4,5,6
In the following example, spread operator is used to join 3 arrays. By using concat() method it is difficult if there are more arrays but by using spread operator it is very easy to join more number arrays.
Live Demo
<html>
<body>
   <script>
      var arr1 = [1,2,3];
      var arr2 = [4,5,6];
      var arr3 = [7,8,9];
      var merged = [...arr1,...arr2,...arr3];
      document.write(merged);
   </script>
</body>
</html>
1,2,3,4,5,6,7,8,9
String tokenisation function in C

In this section, we will see how to tokenize strings in C. The C has library function for this. The C library function char *strtok(char *str, const char *delim) breaks string str into a series of tokens using the delimiter delim.
Following is the declaration for strtok() function.
char *strtok(char *str, const char *delim)
It takes two parameters. The str - The contents of this string are modified and broken into smaller strings (tokens), and delim - This is the C string containing the delimiters. These may vary from one call to another. This function returns a pointer to the first token found in the string. A null pointer is returned if there are no tokens left to retrieve.
 Live Demo
#include <string.h>
#include <stdio.h>

int main () {
   char str[80] = "This is - www.tutorialspoint.com - website";
   const char s[2] = "-";
   char *token;

   /* get the first token */
   token = strtok(str, s);

   /* walk through other tokens */
   while( token != NULL ) {
      printf( " %s\n", token );
      token = strtok(NULL, s);
   }
   return(0);
}
This is
www.tutorialspoint.com
website
How to automate drag & drop functionality using Selenium WebDriver Java?

The drag and drop action is done with the help of a mouse. It happens when we drag and then place an element from one place to another. This is a common scenario when we try to move a file from one folder to another by simply drag and drop action.
Selenium uses the Actions class to perform the drag drop action. The dragAndDrop(source, destination) is a method under Actions class to do drag and drop operation. The method will first do a left click on the element, then continue the click to hold the source element. Next it shall move to the destination location and release the mouse.
Our aim to drag and drop the first box to the second box.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.interactions.Actions;
public class DragDrop{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "https://jqueryui.com/droppable/";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.switchTo().frame(0);
      // identify source and target element
      WebElement s=driver.findElement(By.("draggable"));
      WebElement t=driver.findElement(By.("droppable"));
      /Actions class with dragAndDrop()
      Actions act = new Actions(driver);
      act.dragAndDrop(s, t).build().perform();
      driver.quit();
   }
}
What are the benefits of a module in Java 9?

An important feature introduced in Java 9 is Module. By using a module, we can divide the code into smaller components called modules. It means each module has its own responsibility and declare its dependency on other modules to work correctly.
Below are the steps to create a modular project in Java 9:
Initially, we can create a file named "module-info.java" and add to a package(module) for which it is created. For instance, if our package name is com.mycompany.mypackage then the file goes to the same package (src/com.mycompany.mypackage/module-info.java). We can create a module by declaring "exports" and "requires" expressions.
If our modules require another module we can write below code
module com.tutorialspoint.greetings {
   requires org.tutorix;
}
To expose module contents, we can write below code
module org.tutorix {
   exports org.tutorix;
}
The modules hide unwanted and internal details very safely for better security. It means that a module can access only exported package contents and not all the contents or public/internal API of other modules, so the public in one module is not public to other modules.
The application becomes small and fast because we can use only whatever modules we want.
Easy deployment on small devices as memory requirements are very less.
Easy to support the single responsibility principle.
Easy to support less coupling between components.
Flask â HTTP methods

Http protocol is the foundation of data communication in world wide web. Different methods of data retrieval from specified URL are defined in this protocol.
The following table summarizes different http methods −
GET
Sends data in unencrypted form to the server. Most common method.
HEAD
Same as GET, but without response body
POST
Used to send HTML form data to server. Data received by POST method is not cached by server.
PUT
Replaces all current representations of the target resource with the uploaded content.
DELETE
Removes all current representations of the target resource given by a URL
By default, the Flask route responds to the GET requests. However, this preference can be altered by providing methods argument to route() decorator.
In order to demonstrate the use of POST method in URL routing, first let us create an HTML form and use the POST method to send form data to a URL.
Save the following script as login.html
<html>
   <body>
      <form action = "http://localhost:5000/login" method = "post">
         <p>Enter Name:</p>
         <p><input type = "text" name = "nm" /></p>
         <p><input type = "submit" value = "submit" /></p>
      </form>
   </body>
</html>
Now enter the following script in Python shell.
from flask import Flask, redirect, url_for, request
app = Flask(__name__)

@app.route('/success/<name>')
def success(name):
   return 'welcome %s' % name

@app.route('/login',methods = ['POST', 'GET'])
def login():
   if request.method == 'POST':
      user = request.form['nm']
      return redirect(url_for('success',name = user))
   else:
      user = request.args.get('nm')
      return redirect(url_for('success',name = user))

if __name__ == '__main__':
   app.run(debug = True)
After the development server starts running, open login.html in the browser, enter name in the text field and click Submit.
Form data is POSTed to the URL in action clause of form tag.
http://localhost/login is mapped to the login() function. Since the server has received data by POST method, value of ‘nm’ parameter obtained from the form data is obtained by −
user = request.form['nm']

It is passed to ‘/success’ URL as variable part. The browser displays a welcome message in the window.
Change the method parameter to ‘GET’ in login.html and open it again in the browser. The data received on server is by the GET method. The value of ‘nm’ parameter is now obtained by −
User = request.args.get(‘nm’)

Here, args is dictionary object containing a list of pairs of form parameter and its corresponding value. The value corresponding to ‘nm’ parameter is passed on to ‘/success’ URL as before.

    22 Lectures 
     6 hours 

 Malhar Lathkar

    21 Lectures 
     1.5 hours 

 Jack Chan

    16 Lectures 
     4 hours 

 Malhar Lathkar

    54 Lectures 
     6 hours 

 Srikanth Guskra

    88 Lectures 
     3.5 hours 

 Jorge Escobar

    80 Lectures 
     12 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Output of C programs | Set 43 - GeeksforGeeks

28 Aug, 2017
1. What is the output of following program?
#include <stdio.h>int main(){    int a = 1, b = 2, c = 3;    c = a == b;    printf("%d", c);    return 0;}
Choose the correct answer:(A) 0(B) 1(C) 2(D) 3
Answer : (A)
Explanation :“==” is relational operator which returns only two values, either 0 or 1.0: If a == b is false1: If a == b is trueSincea=1b=2So, a == b is false hence C = 0.
2. What is the output of following program?
#include <stdio.h>int main(){    int a = 20;    ;    ;    printf("%d", a);    ;    return 0;}
Choose the correct answer:(A) 20(B) Error(C) ;20;(D) ;20
Answer : (A)
Explanation : ; (statement terminator) and no expression/statement is available here, so this is a null statement has no side effect, hence no error is occurred.
3. What is the output of following program?
#include <stdio.h>int main(){    int a = 15;    float b = 1.234;    printf("%*f", a, b);    return 0;}
Choose the correct answer:
(A) 1.234(B) 1.234000(C) Compilation Error(D) Runtime error
Answer : (B)
Explanation : You can define width formatting at run time using %*, This is known as Indirect width precision. printf(“%*f”, a, b); is considered as “%15f”, hence value of b is printed with left padding by 15.
4. What is the output of following program?
#include <stdio.h>void main(){    int a = 1, b = 2, c = 3;    char d = 0;    if (a, b, c, d)    {        printf("EXAM");    }}
Choose the correct answer:(A) No Output and No Error(B) EXAM(C) Run time error(D) Compile time error
Answer : (A)
Explanation :Print statement will not execute because ‘ if ‘condition return false. Value of variable d is 0.
5. What is the output of following program?
#include <stdio.h>void main(){    int a = 25;      printf("%o %x", a, a);    getch();}
Choose the correct answer:(A) 25 25(B) 025 0x25(C) 12 42(D) 31 19(E) None of these
Answer : (D)
Explanation :%o is used to print the number in octal number format.%x is used to print the number in hexadecimal number format.Note: In c octal number starts with 0 and hexadecimal number starts with 0x.
This article is contributed by Siddharth Pandey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Different ways to copy a string in C/C++
Runtime Errors
Output of Java Program | Set 3
Output of Java program | Set 5
Output of C++ Program | Set 1
Output of Java Program | Set 7
Output of python program | Set 2
error: call of overloaded ‘function(x)’ is ambiguous | Ambiguity in Function overloading in C++
How to show full column content in a PySpark Dataframe ?
Output of C Programs | Set 3
Python | Merge first and last elements separately in a list - GeeksforGeeks

07 Jun, 2019
Given a list of lists, where each sublist consists of only two elements, write a Python program to merge the first and last element of each sublist separately and finally, output a list of two sub-lists, one containing all first elements and other containing all last elements.
Examples:
Input : [['x', 'y'], ['a', 'b'], ['m', 'n']]
Output : [['x', 'a', 'm'], ['y', 'b', 'n']]

Input : [[1, 2], [3, 4], [5, 6], [7, 8]]
Output : [[1, 3, 5, 7], [2, 4, 6, 8]]

 Approach #1 : List comprehension and zip
# Python3 program to Merge first and last# elements separately in a list of lists  def merge(lst):          return [list(ele) for ele in list(zip(*lst))]      # Driver codelst = [['x', 'y'], ['a', 'b'], ['m', 'n']]print(merge(lst))
[['x', 'a', 'm'], ['y', 'b', 'n']]

 Approach #2 : Using Numpy array
First convert the given list to numpy array and then return transpose of the array, and finally convert the array to list.
# Python3 program to Merge first and last# elements separately in a list of listsimport numpy as np  def merge(lst):    arr = np.array(lst)    return arr.T.tolist()      # Driver codelst = [['x', 'y'], ['a', 'b'], ['m', 'n']]print(merge(lst))
[['x', 'a', 'm'], ['y', 'b', 'n']]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Check if element exists in list in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Prototype - Form.Element getValue() Method

This method returns the current value of a form control. A string is returned for most controls; only multiple select boxes return an array of values. The global shortcut for this method is $F().
formElement.getValue();

It returns a string or array of strings.
Following is the example to show how a control receives focus −
<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function showResult() {
            var value = $('age').getValue();
            alert("Returned value is : " + value );
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br />

      <form id = "example" action = "#" onsubmit = "return false">
         <fieldset>
            <legend>User info</legend>
            <div>
               <label for = "username">Username:</label> 
               <input name = "username" id = "username" value = "Sai" type = "text">
            </div>
            <div>
               <label for = "age">Age:</label> 
               <input name = "age" id = "age" value = "23" size = "3" type = "text">
            </div>
            <div><label for = "hobbies">Your hobbies :</label>
               <select name = "hobbies" id = "hobbies" multiple = "multiple">
                  <option>coding</option>
                  <option>swimming</option>
                  <option>hiking</option>
                  <option>drawing</option>
               </select>
            </div>
         </fieldset>
      </form>
   
      <br />
      <input type = "button" value = "Toggle" onclick = "showResult();"/>
   </body>
</html>
Click the button to see the result.

    127 Lectures 
     11.5 hours 

 Aleksandar Cucukovic
 Print
 Add Notes
 Bookmark this page
HTML DOM MouseEvent clientX Property

The HTML DOM MouseEvent clientX property returns the horizontal (x) coordinate of the mouse pointer if a mouse event was triggered. Use with clientY to get the vertical coordinate as well.
Following is the syntax −
Returning reference to the clientX object
MouseEventObject.clientX
Let us see an example of MouseEvent clientX property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>MouseEvent clientX</title>
<style>
   * {
      padding: 2px;
      margin:5px;
   }
   form {
      width:70%;
      margin: 0 auto;
      text-align: center;
   }
   #outer {
      width:70%;
      margin: 0 auto;
      padding: 0;
      text-align: center;
      border:1px solid black;
      height: 105px;
      background-color: #28a745;
   }
   input[type="button"] {
      border-radius: 10px;
   }
   #upper {
      border-bottom: 1px solid black;
      height: 40px;
      margin: 0 0 15px 0;
      background-color: #DC3545;
   }
   #lower {
      border-top: 1px solid black;
      height: 40px;
      margin: 15px 0 0 0;
      background-color: #DC3545;
   }
</style>
</head>
<body>
   <form>
      <fieldset>
      <legend>MouseEvent-clientX</legend>
      <div id="outer">
      <div id="upper"><h2>Danger</h2></div>
      <div id="lower"><h2>Danger</h2></div>
      </div>
         <input type="button" id="start" value="Start" onclick="gameStart()">
      <div id="divDisplay"></div>
      </fieldset>
   </form>
<script>
   var divDisplay = document.getElementById('divDisplay');
   var gameDisplay = document.getElementById('outer');
   function playGame(event) {
      var x = event.clientX;
      var y = event.clientY;
      if(y > 95 && y < 110){
         divDisplay.textContent = 'Keep Going!';
         if(x === 439){
            divDisplay.textContent = 'Congrats! You Did it!';
            gameDisplay.removeEventListener('mousemove', playGame);
         }
      }
      else{
            divDisplay.textContent = 'You moved to DANGER area. You loose!';
            gameDisplay.removeEventListener('mousemove', playGame);
      }
   }
   function gameStart(){
      gameDisplay.addEventListener('mousemove',playGame);
   }
</script>
</body>
</html>
After clicking ‘Start’ button and cursor in green (safe) area −
After clicking ‘Start’ button and cursor at end of green (safe) area −
After clicking ‘Start’ button and cursor in red (danger) area −
Detect Cycle in a an Undirected Graph

To detect if there is any cycle in the undirected graph or not, we will use the DFS traversal for the given graph. For every visited vertex v, when we have found any adjacent vertex u, such that u is already visited, and u is not the parent of vertex v. Then one cycle is detected. 
We will assume that there are no parallel edges for any pair of vertices.
Input and Output:
Adjacency matrix
   
    0 1 0 0 0
    1 0 1 1 0
    0 1 0 0 1
    0 1 0 0 1
    0 0 1 1 0

Output:
The graph has cycle.
dfs(vertex, visited, parent)
Input: The start vertex, the visited set, and the parent node of the vertex.Output: True a cycle is found.Begin
   add vertex in the visited set
   for all vertex v which is adjacent with vertex, do
      if v = parent, then
         return true
      if v is not in the visited set, then
         return true
      if dfs(v, visited, vertex) is true, then
         return true
   done
   return false
End hasCycle(graph)

Input: The given graph.

Output: True when a cycle has found.Begin
   for all vertex v in the graph, do
      if v is not in the visited set, then
         go for next iteration
      if dfs(v, visited, φ) is true, then     //parent of v is null
         return true
      return false
   done
End


Input: The start vertex, the visited set, and the parent node of the vertex.
#include<iostream>
#include<set>
#define NODE 5
using namespace std;

int graph[NODE][NODE] = {
   {0, 1, 0, 0, 0},
   {1, 0, 1, 1, 0},
   {0, 1, 0, 0, 1},
   {0, 1, 0, 0, 1},
   {0, 0, 1, 1, 0}
};

bool dfs(int vertex, set<int>&visited, int parent) {
   visited.insert(vertex);
   for(int v = 0; v<NODE; v++) {
      if(graph[vertex][v]) {
         if(v == parent)    //if v is the parent not move that direction
            continue;
         if(visited.find(v) != visited.end())    //if v is already visited
            return true;
         if(dfs(v, visited, vertex))
            return true;
      }
   }
   return false;
}

bool hasCycle() {
   set<int> visited;       //visited set
   for(int v = 0; v<NODE; v++) {
      if(visited.find(v) != visited.end())    //when visited holds v, jump to next iteration
         continue;
      if(dfs(v, visited, -1)) {    //-1 as no parent of starting vertex
         return true;
      }
   }
   return false;
}

int main() {
   bool res;
   res = hasCycle();
   if(res)
      cout << "The graph has cycle." << endl;
   else
      cout << "The graph has no cycle." << endl;
}
The graph has cycle.
How to delete the local group from the windows system using PowerShell?

To delete the local group from the windows system using PowerShell, you need to use the RemoveLocalGroup command as shown below.
Remove-LocalGroup -Name TestGroup
In the above example, the local group name TestGroup will be removed from the local system. To remove the local group from the remote systems, we can use Invoke-Command as shown in the below example.
Invoke-Command -ComputerName Test1-Win2k12,Test1-Win2k16 -ScriptBlock
{Remove-LocalGroup -Name TestGroup}
Remove-Localgroup command is supported from the PowerShell version 5.1 onwards and this command is a part of Microsoft.PowerShell.LocalAccounts module. If you have the PS version 5.1 or the local accounts module not available then you can use the cmd command.
net localgroup testgroup /delete
Similarly, you can run the above command on the remote system using Invoke-Command method.
Invoke-Command -ComputerName Test1-Win2k12,Test1-Win2k16 -ScriptBlock{
   net localgroup TestGroup /delete
}
How to create a Number Input using jQuery Mobile ? - GeeksforGeeks

14 Dec, 2020
jQuery Mobile is a web based technology used to make responsive content that can be accessed on all smartphones, tablets and desktops In this article, we will be creating a number input area using jQuery Mobile.
Approach: Add jQuery Mobile scripts needed for your project.
<link rel=”stylesheet” href=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”http://code.jquery.com/jquery-1.11.1.min.js”></script>
<script src=”http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>
Example: We will create a number input area using jQuery Mobile. We use type=”number” attribute to enter number only and use data-clear-btn=”true” attribute to clear the input text.
HTML
<!DOCTYPE html><html>  <head>    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />      <script src="http://code.jquery.com/jquery-1.11.1.min.js">    </script>      <script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">    </script></head>  <body>    <center>        <h1>GeeksforGeeks</h1>          <h4>            Design Number Input using jQuery Mobile        </h4>          <form style="width: 50%;">            <label for="numberInput1">Number Input Area:</label>            <input type="number" data-clear-btn="false"                 name="numberInput1" id="numberInput1" value=""                placeholder="Enter Number...">              <label for="numberInput2">                Number Input Area with clear button:            </label>            <input type="number" data-clear-btn="true"                 name="numberInput2" id="numberInput2" value=""                placeholder="Enter Number...">              <label for="numberInput3">                Number and pattern Input Area:            </label>            <input type="number" data-clear-btn="false"                 name="numberInput3" pattern="[0-9]*" id="numberInput3"                 value="" placeholder="Enter Number and pattern...">              <label for="numberInput4">                Number and pattern Input Area with clear button:            </label>            <input type="number" data-clear-btn="true"                 name="numberInput4" pattern="[0-9]*" id="numberInput4"                 value="" placeholder="Enter Number and pattern...">        </form>    </center></body>  </html>
Output:
jQuery-Misc
jQuery-Mobile
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
How to get the value in an input text box using jQuery ?
jQuery | parent() & parents() with Examples
Difference Between JavaScript and jQuery
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
Convert a string to an integer in JavaScript
Stringize and Token-pasting operator in C

In this section we will see what are the Stringize operator and Token Pasting operator in C. The Stringize operator is a preprocessor operator. It sends commands to compiler to convert a token into string. We use this operator at the macro definition.
Using stringize operator we can convert some text into string without using any quotes.
#include<stdio.h>
#define STR_PRINT(x) #x
main() {
   printf(STR_PRINT(This is a string without double quotes));
}
This is a string without double quotes
The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.
#include<stdio.h>
#define STR_CONCAT(x, y) x##y
main() {
   printf("%d", STR_CONCAT(20, 50));
}
2050
Rotating a 2-D (transposing a matrix) in JavaScript

The transpose of a matrix (2-D array) is simply a flipped version of the original matrix (2-D
array). We can transpose a matrix (2-D array) by switching its rows with its columns.
The code for this will be −
const arr = [
   [1, 1, 1],
   [2, 2, 2],
   [3, 3, 3],
];
const transpose = arr => {
   for (let i = 0; i < arr.length; i++) {
      for (let j = 0; j < i; j++) {
         const tmp = arr[i][j];
         arr[i][j] = arr[j][i];
         arr[j][i] = tmp;
      };
   }
}
transpose(arr);
console.log(arr);
The output in the console −
[ [ 1, 2, 3 ], [ 1, 2, 3 ], [ 1, 2, 3 ] ]
How to edit the style of a heading in Treeview (Python ttk)?

Python Treeview widget is introduced for creating a Table look-like GUI in application. It includes many inbuilt features and functions which can be used to configure the properties. However, to configure the style of a tkinter widget, we generally refer to use ttk themed widget. This allows you to edit the style such as background color, foreground color, and other properties of the treeview widget as well.
In this example, we will create an instance of the ttk style widget and then configure the style of heading by passing 'Treeview.Heading' as the style parameter.
# Import the required libraries
from tkinter import *
from tkinter import ttk

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

# Set the size of the tkinter window
win.geometry("700x350")
s = ttk.Style()
s.theme_use('clam')

# Configure the style of Heading in Treeview widget
s.configure('Treeview.Heading', background="green3")

# Add a Treeview widget
tree= ttk.Treeview(win, column=("c1", "c2"), show= 'headings', height= 8)
tree.column("# 1",anchor=CENTER)
tree.heading("# 1", text= "ID")
tree.column("# 2", anchor= CENTER)
tree.heading("# 2", text= "FName")

# Insert the data in Treeview widget
tree.insert('', 'end',text= "1",values=('1','Honda'))
tree.insert('', 'end',text= "2",values=('2', 'Hundayi'))
tree.insert('', 'end',text= "3",values=('3', 'Tesla'))
tree.insert('', 'end',text= "4",values=('4', 'Wolkswagon'))
tree.insert('', 'end',text= "5",values=('5', 'Tata'))
tree.insert('', 'end',text= "6",values=('6', 'Renault'))
tree.insert('', 'end',text= "7",values=('7', 'Audi'))
tree.insert('', 'end',text= "8",values=('8', 'BMW'))

tree.pack()

win.mainloop()
Executing the above code will display a window containing a table with a customized heading background color.
ES6 - constructor ()

Javascript Boolean constructor() method returns a reference to the Boolean function that created the instance's prototype.
Use the following syntax to create a Boolean constructor() method. It returns the function that created this object's instance.
boolean.constructor()

<html>
   <head>
      <title>JavaScript constructor() Method</title>
   </head>
   <body>
      <script type="text/javascript">
         var bool = new Boolean( );
         document.write("bool.constructor() is : " + bool.constructor);
      </script>
   </body>
</html>
The following output is displayed on successful execution of the above code.
bool.constructor() is : function Boolean() { [native code] }


    32 Lectures 
     3.5 hours 

 Sharad Kumar

    40 Lectures 
     5 hours 

 Richa Maheshwari

    16 Lectures 
     1 hours 

 Anadi Sharma

    50 Lectures 
     6.5 hours 

 Gowthami Swarna

    14 Lectures 
     1 hours 

 Deepti Trivedi

    31 Lectures 
     1.5 hours 

 Shweta
 Print
 Add Notes
 Bookmark this page
What do you mean by odd loops in C language?

In C programming language, the Control statements are used to repeat a set of statements.
They are as follows −
for loop
while loop
do-while loop
In for loop and while loop, the condition specifies the number of times, in which a loop can be executed.
for (k = 1; k<=5; k++)
Here, the loop will execute until k<=5, when ever k>5 the control come out of the loop.
So, here the for-loop condition specifies the number of times a loop can be executed i.e 5 times the loop executes.
Following is the C program for the for loop −
 Live Demo
main( ){
   int k;
   for (k = 1; k<=5; k++){
      printf ("%d",k);
   }
}
When the above program is executed, it produces the following output −
1 2 3 4 5
while (k< = 5)
Here, the loop will execute until k<=5, when ever k>5 the control come out of the loop.
So, here also, the while-loop condition specifies the number of times in which a loop can be executed i.e. 5 times the loop executes.
Following is the C program for the while loop −
 Live Demo
main( ){
   int k;
   k = 1;
   while (k<=5){
      printf ("%d",k);
      k++;
   }
}
When the above program is executed, it produces the following output −
1 2 3 4 5
Sometimes a user may not know about how many times a loop is to be executed. If we want to execute a loop for unknown number of times, then the concept of odd loops should be implemented. This can be done using for-loop, while-loop or do-while-loops.
Following is the C program for the odd loop −
 Live Demo
#include<stdio.h>
int main(){
   int number;
   number=1;
   while(number==1) // odd loop don’t know how many times loop executes{
      printf("enter a number:\n");
      scanf("%d",&number);
      if((number%2)==0)
         printf("number is even\n");
      else
         printf("number is odd\n");
         printf("do you want to test any number\n");
         printf("if yes then press '1'\n");// if press 1 loop executes again
         printf("else press '0'\n");//if press 0 exist from loop
         scanf("%d",&number);
   }
   return 0;
}
When the above program is executed, it produces the following output −
enter a number:
3
number is odd
do you want to test any number
if yes then press '1'
else press '0'
1
enter a number:
4
number is even
do you want to test any number
if yes then press '1'
else press '0'
1
enter a number:
9
number is odd
do you want to test any number
if yes then press '1'
else press '0'
0
Program to convert IP address to hexadecimal in C++

Given with the input as an IP address value and the task is to represent the given IP address as its hexadecimal equivalent.
IP address or Internet protocol is a unique number to that uniquely describes your hardware connected to a network. Internet means over the network and protocol defines the set of rules and regulations that must be followed for connection. Because of IP address only it is possible for a system to communicate with another system over a network. There are two versions of IP that are −
IPv4(Internet Protocol Version 4)
IPv6(Internet Protocol Version 6)
IP address is represented as the sequence of numbers which are in the form −
151.101.65.121
For this conversion, below program is using the header file “arpa/inet.h” which is created for the internet operations
Input-: 127.0.0.1
Ouput-: 0x7f000001
Input-: 172.31.0.2
Output-: 0xac1f0002
Start
Step1-> Declare function to reverse
   void reverse(char* str)
      set int len = 2
      set int r = strlen(str) – 2
      Loop While (len < r)
         call swap(str[len++], str[r++])
         Call swap(str[len++], str[r])
         Set r = r – 3
      End
   End
Step 2-> Declare function to convert IP address to hexadecimal
   void convert(int ip_add)
      declare char str[15]
      call sprintf(str, "0x%08x", ip_add)
      call reverse(str)
      print str
step 3-> In main()
   declare int ip_add = inet_addr("127.0.0.1")
   call convert(ip_add)
Stop
 Live Demo
#include <arpa/inet.h>
#include <iostream>
#include <string.h>
using namespace std;
//reverse hexadecimal number
void reverse(char* str) {
   int len = 2;
   int r = strlen(str) - 2;
   while (len < r) {
      swap(str[len++], str[r++]);
      swap(str[len++], str[r]);
      r = r - 3;
   }
}
//Convert IP address to heaxdecimal
void convert(int ip_add) {
   char str[15];
   sprintf(str, "0x%08x", ip_add);
   reverse(str);
   cout << str << "\n";
}
int main() {
   int ip_add = inet_addr("127.0.0.1");
   convert(ip_add);
   return 0;
}
IF WE RUN THE ABOVE CODE IT WILL GENERATE FOLLOWING OUTPUT
0x7f000001
Recursively list nested object keys JavaScript

Let’s say, we have an object with other objects being its property value, it is nested to 2-3 levels
or even more.
Here is the sample object −
const people = {
   Ram: {
      fullName: 'Ram Kumar',
      details: {
         age: 31,
         isEmployed: true
      }
   },
   Sourav: {
      fullName: 'Sourav Singh',
      details: {
         age: 22,
         isEmployed: false
      }
   },
   Jay: {
      fullName: 'Jay Grewal',
      details: {
         age: 26,
         isEmployed: true
      }
   }
}
Our job is to write a function that accepts this object and a string, searches the whole object for
that string as key and returns an array that contains value of all the keys that matched with the
string
Let’s call the function recursiveSearch(), recursion would be the most appropriate way of
tackling this situation, given the nesting.
So, the full code for this function recursiveSearch() will be −
const people = {
   Ram: {
      fullName: 'Ram Kumar',
      details: {
         age: 31,
         isEmployed: true
      }
   },
   Sourav: {
      fullName: 'Sourav Singh',
      details: {
         age: 22,
         isEmployed: false
      }
   },
   Jay: {
      fullName: 'Jay Grewal',
      details: {
         age: 26,
         isEmployed: true
      }
   }
}
const recursiveSearch = (obj, searchKey, results = []) => {
   const r = results;
   Object.keys(obj).forEach(key => {
      const value = obj[key];
      if(key === searchKey && typeof value !== 'object'){
         r.push(value);
      }else if(typeof value === 'object'){
         recursiveSearch(value, searchKey, r);
      }
   });
   return r;
};
console.log(recursiveSearch(people, 'age'));
The output in the console will be −
[ 31, 22, 26 ]
In the above function, first of all we iterate over the main object and whenever we encounter a
nesting we recursively iterate over the sub object search for the desired key, if we find the
desired key, we immediately record its value in the results array and at the last when we finish
iterating, we return the results array that contains the desired values.
The time complexity of this function is O(mn) where is the number of child objects inside the
main object and m is the deepest level of nesting.
How to print without newline in Python?

In python the print statement adds a new line character by default. So when we have multiple print statements the output from each of them is printed in multiple lines as you can see in the example below. Our goal is to print them in a single line and use some special parameters to the print function to achieve that.
The below example prints multiple statements with new lines in each of them.
print("Apple")
print("Mango")
print("Banana")
Running the above code gives us the following result −
Apple
Mango
Banana
We can use the end parameter to use a specific character at the end of the output from each print statement. In the below example we use "," as special character with the end parameter, which will appear at the end of the output of each print statement. The result will not be printed in multiple lines.
print("Apple" , end ="," )
print("Mango", end =",")
print("Banana")
Running the above code gives us the following result −
Apple,Mango,Banana