code-rag-bench/online-tutorials huggingface dataset:
What are the types of arrays in Java?

There are two types of arrays in Java they are  −
Single dimensional array − A single dimensional array of Java is a normal array where, the array contains sequential elements (of same type) −
int[] myArray = {10, 20, 30, 40}

 Live Demo
public class TestArray {
   public static void main(String[] args) {
      double[] myList = {1.9, 2.9, 3.4, 3.5};
      
      // Print all the array elements
      for (int i = 0; i < myList.length; i++) {
         System.out.println(myList[i] + " ");
      }
      
      // Summing all elements
      double total = 0;
      
      for (int i = 0; i < myList.length; i++) {
         total += myList[i];
      }
      System.out.println("Total is " + total);
      
      // Finding the largest element
      double max = myList[0];
      
      for (int i = 1; i < myList.length; i++) {
         if (myList[i] > max) max = myList[i];
      }
      System.out.println("Max is " + max);
   }
}
1.9
2.9
3.4
3.5
Total is 11.7
Max is 3.5

Multi-dimensional array − A multi-dimensional array in Java is an array of arrays. A two dimensional array is an array of one dimensional arrays and a three dimensional array is an array of two dimensional arrays.
 Live Demo
public class Tester {
   public static void main(String[] args) {
      int[][] multidimensionalArray = { {1,2},{2,3}, {3,4} };
      
      for(int i = 0 ; i < 3 ; i++){
         //row
         for(int j = 0 ; j < 2; j++){
            System.out.print(multidimensionalArray[i][j] + " ");
         }
         System.out.println();
      }
   }
}
1 2
2 3
3 4
p5.js | round() function - GeeksforGeeks

09 Apr, 2019
The round() function in p5.js is used to calculate the round value of a number. It calculates the integer closest to the number.
Syntax
round(number)

Parameters: The function accepts only one parameter as mentioned above and described below:
number : This parameter stores the number to compute.Below program illustrates the round() function in p5.js:Example:function setup() {    //create Canvas of size 270*80      createCanvas(270, 80);}  function draw() {    background(220);    //initialize the parameter      let x = 67.54;    //call to round() function    let y = round(x);    textSize(16);    fill(color('red'));    text("Given Number is : " + x, 50, 30);    text("Computed Number is : " + y, 50, 50);}Output:Reference: https://p5js.org/reference/#/p5/roundMy Personal Notes
arrow_drop_upSave
Below program illustrates the round() function in p5.js:Example:
function setup() {    //create Canvas of size 270*80      createCanvas(270, 80);}  function draw() {    background(220);    //initialize the parameter      let x = 67.54;    //call to round() function    let y = round(x);    textSize(16);    fill(color('red'));    text("Given Number is : " + x, 50, 30);    text("Computed Number is : " + y, 50, 50);}
Output:
Reference: https://p5js.org/reference/#/p5/round
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Convert a string to an integer in JavaScript
How to append HTML code to a div using JavaScript ?
Set the value of an input field in JavaScript
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to copy only updated or newer files with PowerShell?

To copy only updated or newer files with PowerShell, we can use Copy-Item with some logic in the script that to check if the files exist on the destination folder if not then copy that file and if yes then compare the timestamp and copy the latest file. This would be tricky because we need to write several lines of code for it.
But Windows support xCopy utility which can directly copy the newer or updated files and this utility we can accommodate in PowerShell as well.
xCopy uses a switch called /d. its actual syntax is,
/d [:MM-DD-YYYY]
This means if the date specified, it copies the files and folders newer than that date and if don't specify any date then it copies all files and folders that are updated. An example is shown below.
Source:
C:\DSC
Destination:
E\Temp
Our folder structure is like this, LabMachine2k16.mof file also exists on the destination but it is an updated file, Test.txt is a new file and the Pagefile folder is a new folder but it is an empty one.
xcopy C:\DSC E:\Temp\ /s /d /e /f /y
PS C:\> xcopy C:\DSC E:\Temp\ /s /d /e /f /y
C:\DSC\LabMachine2k16.mof -> E:\Temp\LabMachine2k16.mof
C:\DSC\Test.txt -> E:\Temp\Test.txt
2 File(s) copied
Switches.
/s – Specifies the subfolder
/e – Specifies the empty directory
/d – Specifies the updated files to copy
/f – Displays the source and the destination.
/y – Confirms without asking user prompt.
How to get the specific process(es) information using PowerShell?

To find the specific process using Get-Process cmdlet, you need to use the –Name parameter. You can use single and multiple process names.
Get-Process -Name AcroRd32, audiodg
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
506 27 9888 19216 2.22 6320 1 AcroRd32
632 51 112196 17648 42.95 8052 1 AcroRd32
209 13 10344 17100 13.98 22748 0 audiodg
You can also achieve the same using Where-Object (alias: Where) command.
Get-Process | Where{$_.Name -eq "AcroRd32"}

But to get the multiple processes you need to use the –OR comparison operator.
Get-Process | Where{($_.Name -eq "AcroRd32") -or ($_.Name -eq "AudioDg")}
The result will be the same as displayed above.
To get the specific process information using the WMI object, you can use –Filter parameter or pipeline Where-Object command.Using the Where-Object command.
To get the specific process information using the WMI object, you can use –Filter parameter or pipeline Where-Object command.
Using the Where-Object command.
Get-WmiObject Win32_Process | Where{($_.Name -eq "AcroRd32.exe") -or ($_. Name -eq "AudioDg.exe")}

Using –Filter parameter.
Get-WmiObject Win32_Process -Filter {Name = 'AcroRD32.exe'}
To get the multiple processes, you need to use AND comparison operator.
Get-WmiObject Win32_Process -Filter {Name = 'AcroRD32.exe' or Name = 'AudioDg.exe'}
read() - Unix, Linux System Call

Unix - Home
Unix - Getting Started
Unix - File Management
Unix - Directories
Unix - File Permission
Unix - Environment
Unix - Basic Utilities
Unix - Pipes & Filters
Unix - Processes
Unix - Communication
Unix - The vi Editor
Unix - What is Shell?
Unix - Using Variables
Unix - Special Variables
Unix - Using Arrays
Unix - Basic Operators
Unix - Decision Making
Unix - Shell Loops
Unix - Loop Control
Unix - Shell Substitutions
Unix - Quoting Mechanisms
Unix - IO Redirections
Unix - Shell Functions
Unix - Manpage Help
Unix - Regular Expressions
Unix - File System Basics
Unix - User Administration
Unix - System Performance
Unix - System Logging
Unix - Signals and Traps
Unix - Useful Commands
Unix - Quick Guide
Unix - Builtin Functions
Unix - System Calls
Unix - Commands List
Unix Useful Resources
Computer Glossary
Who is Who
Copyright © 2014 by tutorialspoint
#include <unistd.h> 

ssize_t read(int fd, void *buf, size_t count); 


ssize_t read(int fd, void *buf, size_t count); 


If
count is zero, read() returns zero and has no other results.
If
count is greater than SSIZE_MAX, the result is unspecified.




Many filesystems and disks were considered to be fast enough that the
implementation of
O_NONBLOCK was deemed unnecessary. So, O_NONBLOCK may not be available on files
and/or disks.

close (2)
close (2)
fcntl (2)
fcntl (2)
ioctl (2)
ioctl (2)
lseek (2)
lseek (2)
open (2)
open (2)
pread (2)
pread (2)
readdir (2)
readdir (2)
readlink (2)
readlink (2)
readv (2)
readv (2)
select (2)
select (2)
write (2)
write (2)

Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
arecord command in Linux with examples - GeeksforGeeks

07 Apr, 2022
arecord is a command-line sound recorder for ALSA(Advanced Linux Sound Architecture) sound card drivers. It supports several file formats and multiple soundcards with multiple devices. It is basically used to record audio using the command-line interface. Syntax:
arecord [flags] [filename]
If the filename is not specified then it uses Standard input. Options:
-h, –help : It is used to show the help messages and exit.
–version : Print current version.
-l, –list-devices : List all soundcards and digital audio devices.
-L, –list-pcms : List all PCMs(Pulse Code Modulation) defined.
-D, –device=NAME : Select PCM by name.
-q –quiet : Quiet mode. Suppress messages (not sound :).
-t, –file-type TYPE File type (voc, wav, raw or au). If this parameter is omitted the WAVE format is used.
-c, –channels=# : The number of channels. The default is one channel. Valid values are 1 through 32.
-f –format=FORMAT : If no format is given U8 is used.
-r, –rate=# : Sampling rate in Hertz. The default rate is 8000 Hertz.
-d, –duration=# : Interrupt after # seconds.
-s, –sleep-min=# : Min ticks to sleep. The default is not to sleep.
-M, –mmap : Use memory-mapped (mmap) I/O mode for the audio stream. If this option is not set, the read/write I/O mode will be used.
-N, –nonblock : Open the audio device in non-blocking mode. If the device is busy the program will exit immediately.
Note: It contains various other options that we normally don’t need. If you want to know more about you can simply run following command on the terminal.
arecord --help
Recognized Sample Formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE G723_24 G723_24_1B G723_40 G723_40_1B DSD_U8 DSD_U16_LE DSD_U32_LE DSD_U16_BE DSD_U32_BE Note: Some of these may not be available on selected hardware. Examples:
Recording audio through arecord (It will record an audio of 5 secs of U8 format and mp3 type named sample.mp3): 
Now we will demonstrate how it really sounds like to record.
Now we will play that recorded audio using aplay command.(microphone input is off.)
rkbhola5
linux-command
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
ZIP command in Linux with examples
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
diff command in Linux with examples
scp command in Linux with Examples
C | Arrays | Question 7 - GeeksforGeeks

03 Aug, 2018
Consider the following declaration of a ‘two-dimensional array in C:
char a[100][100]; 
Assuming that the main memory is byte-addressable and that the array is stored starting from memory address 0, the address of a[40][50] is (GATE CS 2002)
(A) 4040(B) 4050(C) 5040(D) 5050Answer: (B)Explanation:
Address of a[40][50] = Base address + 40*100*element_size + 50*element_size
                      = 0 + 4000*1 + 50*1
                     = 4050
Based on row major or column major
if row major then the result will be 4050
if column major then 
            Address of a[40][50] = Base address + 50*100*element_size + 40*element_size
                      = 0 + 5000*1 + 40*1
                     = 5040
Quiz of this Question
GehadAhmed
Arrays
C-Arrays
C Language
C Quiz
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
fork() in C
Function Pointer in C
Substring in C++
std::string class in C++
Enumeration (or enum) in C
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | File Handling | Question 1
C | Misc | Question 7
C | Pointer Basics | Question 14
C++ Program to print current Day, Date and Time - GeeksforGeeks

31 Jul, 2017
In order to facilitate finding the current local day, date and time, C++ has defined several functions in the header file , so functions which will help us in achieving our objective of finding local day, date and time are:
time():
It is used to find the current calendar time.
Its return type is time_t, which is an arithmetic data type capable of storing time returned by this function.
If its argument is not NULL, then it assigns its argument the same value as its return value.
localtime():
It uses the argument of time(), which has the same value as the return value of time(), to fill a structure having date and time as its components, with corresponding time in local timezone.
asctime():
It is used to convert the contents in the structure filled by localtime into a human-readable version which finally returns day, date and time in the given format:Day Month Date hh:mm:ss Year

Day Month Date hh:mm:ss Year

// C++ program to find Current Day, Date// and Local Time#include<iostream>#include<ctime>using namespace std;int main(){    // Declaring argument for time()    time_t tt;      // Declaring variable to store return value of    // localtime()    struct tm * ti;      // Applying time()    time (&tt);      // Using localtime()    ti = localtime(&tt);      cout << "Current Day, Date and Time is = "          << asctime(ti);    return 0;}
Output:
It will show the current day, date and localtime, in the
format Day Month Date hh:mm:ss Year

Points to remember:
This program will give output different for different time zones as per the time in that time zone.The Day, Date and Time in the output is independent of the system day, date and time. You can change your system date and time settings, but still the output will not be affected, and will give the correct information.
This program will give output different for different time zones as per the time in that time zone.
The Day, Date and Time in the output is independent of the system day, date and time. You can change your system date and time settings, but still the output will not be affected, and will give the correct information.
This article is contributed by Mrigendra Singh. 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.
CPP-Library
date-time-program
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Inheritance in C++
Multidimensional Arrays in C / C++
Socket Programming in C/C++
C++ Classes and Objects
Operator Overloading in C++
Bitwise Operators in C/C++
Constructors in C++
Virtual Function in C++
Copy Constructor in C++
Templates in C++ with Examples
What does main() return in C and C++?

19 Sep, 2019
C
According to coding standards, a good return program must exit the main function with 0. Although we are using void main() in C, In which we have not suppose to write any kind of return statement but that doesn’t mean that C code doesn’t require 0 as exit code. Let’s see one example to clear our thinking about need of return 0 statement in our code.
Example #1 :
#include <stdio.h>  void main(){      // This code will run properly    // but in the end,    // it will demand an exit code.    printf("It works fine");}
It works fine
Runtime Error:
NZEC
As we can see in the output the compiler throws a runtime error NZEC, Which means that Non Zero Exit Code. That means that our main program exited with non zero exiting code so if we want to be a developer than we make these small things in our mind.
Correct Code for C :
#include <stdio.h>  int main(){      // This code will run properly    // but in the end,    // it will demand an exit code.    printf("This is correct output");    return 0;}
This is correct output
Note: Returning value other than zero will throw the same runtime error. So make sure our code return only 0.
Example #2 :
#include <stdio.h>  int main(){      printf("GeeksforGeeks");    return "gfg";}
It works fine
Runtime Error:
NZEC
Correct Code for C :
#include <stdio.h>  int main(){      printf("GeeksforGeeks");    return 0;}
GeeksforGeeks
C++
In case of C++, We are not able to use void keyword with our main() function according to coding namespace standards that’s why we only intend to use int keyword only with main function in C++. Let’s see some examples to justify these statements.
Example #3 :
#include <iostream>using namespace std;  void main(){    cout << "GeeksforGeeks";}
prog.cpp:4:11: error: '::main' must return 'int'
 void main()
           ^

Correct Code for C++ :
#include <iostream>using namespace std;  int main(){    cout << "GeeksforGeeks";    return 0;}
GeeksforGeeks
Example #4 :
#include <iostream>using namespace std;  char main(){    cout << "GeeksforGeeks";    return "gfg";}
prog.cpp:4:11: error: '::main' must return 'int'
 char main()
           ^
prog.cpp: In function 'int main()':
prog.cpp:7:9: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
  return "gfg";
         ^

Correct Code for C++ :
#include <iostream>using namespace std;  int main(){    cout << "GeeksforGeeks";    return 0;}
GeeksforGeeks
cooldude69
main
Picked
return
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program for Left Rotation and Right Rotation of a String

27 May, 2022
Given a string of size n, write functions to perform the following operations on a string-
Left (Or anticlockwise) rotate the given string by d elements (where d <= n)Right (Or clockwise) rotate the given string by d elements (where d <= n).
Left (Or anticlockwise) rotate the given string by d elements (where d <= n)
Right (Or clockwise) rotate the given string by d elements (where d <= n).
Examples: 
Input : s = "GeeksforGeeks"
        d = 2
Output : Left Rotation  : "eksforGeeksGe" 
         Right Rotation : "ksGeeksforGee"  


Input : s = "qwertyu" 
        d = 2
Output : Left rotation : "ertyuqw"
         Right rotation : "yuqwert"
A Simple Solution is to use a temporary string to do rotations. For left rotation, first, copy last n-d characters, then copy first d characters in order to the temporary string. For right rotation, first, copy last d characters, then copy n-d characters. 
Can we do both rotations in-place and O(n) time? The idea is based on a reversal algorithm for rotation.
// Left rotate string s by d (Assuming d <= n)
leftRotate(s, d)
  reverse(s, 0, d-1); // Reverse substring s[0..d-1]
  reverse(s, d, n-1); // Reverse substring s[d..n-1]
  reverse(s, 0, n-1); // Reverse whole string.  

// Right rotate string s by d (Assuming d <= n)
rightRotate(s, d)

  // We can also call above reverse steps
  // with d = n-d.
  leftRotate(s, n-d)  
Below is the implementation of the above steps : 
Java
// Java program for Left Rotation and Right// Rotation of a Stringimport java.util.*;import java.io.*; class GFG{             // function that rotates s towards left by d    static String leftrotate(String str, int d)    {            String ans = str.substring(d) + str.substring(0, d);            return ans;    }     // function that rotates s towards right by d    static String rightrotate(String str, int d)    {            return leftrotate(str, str.length() - d);    }     // Driver code    public static void main(String args[])    {            String str1 = "GeeksforGeeks";            System.out.println(leftrotate(str1, 2));             String str2 = "GeeksforGeeks";            System.out.println(rightrotate(str2, 2));    }} // This code is contributed by rachana soma
Output: 
Left rotation:  eksforGeeksGe
Right rotation:  ksGeeksforGee                 
Time Complexity: O(N), as we are using a loop to traverse N times so it will cost us O(N) time.Auxiliary Space: O(1), as we are not using any extra space.
Please refer complete article on Left Rotation and Right Rotation of a String for more details!
rohitsingh57
rohan07
rotation
Java
Java Programs
Strings
Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Draw Ellipse Using Turtle in Python

29 Sep, 2021
Prerequisite: Turtle Programming Basics
Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move turtle, there are some functions i.e forward(), backward(), etc.
Approach:
The following steps are used :
Import turtle
Divide the ellipse into four arcs
Define a method to form these arc in pair
Call the function.
Below is the implementation :
Python3
# import packageimport turtle # method to draw ellipsedef draw(rad):       # rad --> radius of arc  for i in range(2):         # two arcs    turtle.circle(rad,90)    turtle.circle(rad//2,90) # Main section# tilt the shape to negative 45turtle.seth(-45) # calling draw methoddraw(100)
Output :
The following steps are used :
Import turtle
Set Screen
Divide the ellipse into four arcs
Define a method to form these arc in pair
Call the function multiple times for different colors.
Below is the implementation :
Python3
# import package and making objectimport turtlescreen = turtle.Screen() # method to draw ellipsedef draw(rad):       # rad --> radius for arc    for i in range(2):        turtle.circle(rad,90)        turtle.circle(rad//2,90) # Main Section# Set screen sizescreen.setup(500,500) # Set screen colorscreen.bgcolor('black') # Colorscol=['violet','blue','green','yellow',     'orange','red'] # some integersval=10ind=0 # turtle speedturtle.speed(100) # loop for multiple ellipsefor i in range(36):         # oriented the ellipse at angle = -val    turtle.seth(-val)         # color of ellipse    turtle.color(col[ind])         # to access different color    if ind==5:        ind=0    else:        ind+=1         # calling method    draw(80)         # orientation change    val+=10 # for hiding the turtleturtle.hideturtle()
Output :
 
sweetyty
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.append() in Python

04 Dec, 2020
The numpy.append() appends values along the mentioned axis at the end of the arraySyntax :
numpy.append(array, values, axis = None)
Parameters :
array   : [array_like]Input array. 
values  : [array_like]values to be added in the arr. Values should be 
     shaped so that arr[...,obj,...] = values. If the axis is defined values can be of any
     shape as it will be flattened before use.
axis    : Axis along which we want to insert the values. By default, array
     is flattened.    

Return :
An copy of array with values being appended at the end as per the mentioned object
along a given axis. 

Code 1 : Appending arrays
# Python Program illustrating# numpy.append()  import numpy as geek  #Working on 1Darr1 = geek.arange(5)print("1D arr1 : ", arr1)print("Shape : ", arr1.shape)    arr2 = geek.arange(8, 12)print("\n1D arr2 : ", arr2)print("Shape : ", arr2.shape)    # appending the arraysarr3 = geek.append(arr1, arr2)print("\nAppended arr3 : ", arr3)
Output :
1D arr1 :  [0 1 2 3 4]
Shape :  (5,)

1D arr2 :  [ 8  9 10 11]
Shape :  (4,)

Appended arr3 :  [ 0  1  2  3  4  8  9 10 11]


Code 2 : Playing with axis
# Python Program illustrating# numpy.append()  import numpy as geek  #Working on 1Darr1 = geek.arange(8).reshape(2, 4)print("2D arr1 : \n", arr1)print("Shape : ", arr1.shape)    arr2 = geek.arange(8, 16).reshape(2, 4)print("\n2D arr2 : \n", arr2)print("Shape : ", arr2.shape)    # appending the arraysarr3 = geek.append(arr1, arr2)print("\nAppended arr3 by flattened : ", arr3)  # appending the arrays with axis = 0arr3 = geek.append(arr1, arr2, axis = 0)print("\nAppended arr3 with axis 0 : \n", arr3)  # appending the arrays with axis = 1arr3 = geek.append(arr1, arr2, axis = 1)print("\nAppended arr3 with axis 1 : \n", arr3)
Output :
2D arr1 : 
 [[0 1 2 3]
 [4 5 6 7]]
Shape :  (2, 4)

2D arr2 : 
 [[ 8  9 10 11]
 [12 13 14 15]]
Shape :  (2, 4)

Appended arr3 by flattened :  [ 0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15]

Appended arr3 with axis 0 : 
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]]

Appended arr3 with axis 1 : 
 [[ 0  1  2  3  8  9 10 11]
 [ 4  5  6  7 12 13 14 15]]

References :https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.append.html#numpy.append.This article is contributed by Mohit Gupta_OMG . 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.
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is strncmp() Function in C language?

The C library function int strncmp(const char *str1, const char *str2, size_t n) compares at most the first n bytes of str1 and str2.
An array of characters is called a string.
The syntax for declaring an array is as follows −
char stringname [size];
For example − char string[50]; string of length 50 characters
Using single character constant −
char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}
Using string constants −
char string[10] = "Hello":;
Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.
This function is used for comparing first ‘n’ characters of 2 strings.
The syntax for strncmp() function is as follows −
strncmp ( string1, string2, n)
char a[10] = "the";
char b[10] = "there"
strncmp (a,b,3);
The output would be that the Both strings are equal.
Given below is a C program to compare a specific character between two strings using strncmp library function −
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring two strings//
   char string1[25],string2[25];
   int value;
   //Reading string 1 and String 2//
   printf("Enter String 1: ");
   gets(string1);
   printf("Enter String 2: ");
   gets(string2);
   //Comparing using library function//
   value = strncmp(string1,string2,4);
   //If conditions//
   if(value==0){
      printf("%s is same as %s",string1,string2);
   }
   else if(value>0){
      printf("%s is greater than %s",string1,string2);
   } else {
      printf("%s is less than %s",string1,string2);
   }
}
When the above program is executed, it produces the following result −
Run1:
Enter String 1: Welcome
Enter String 2: TO my World
Welcome is greater than TO my World
Run 2:
Enter String 1: welcome
Enter String 2: welcome
welcome is same as welcome
Upgrading a Docker Installation of MySQL

Before upgrading the docker installation of MySQL, ensure that the below mentioned steps have been followed −
Download a MySQL server docker image.
Download a MySQL server docker image.
Start a MySQL server instance.
Start a MySQL server instance.
Connect to MySQL server instance from within the container.
Connect to MySQL server instance from within the container.
Following are the steps to upgrade a Docker installation of MySQL 5.7 to 8.0 −
Stop the MySQL 5.6 server using the below command. Here mysql56 is the name of the container.
Stop the MySQL 5.6 server using the below command. Here mysql56 is the name of the container.
docker stop mysql56
Download the MySQL 5.7 Server Docker image.
Download the MySQL 5.7 Server Docker image.
Start a new MySQL 5.7 Docker container with the help of the old server data and
configuration.
Start a new MySQL 5.7 Docker container with the help of the old server data and
configuration.
Perform modifications if required.
Perform modifications if required.
If MySQL community server is present, run the below command −
If MySQL community server is present, run the below command −
docker run --name=mysql57 \
--mount type=bind,src=/path-on-host-machine/my.cnf,dst=/etc/my.cnf \
--mount type=bind,src=/path-on-host-machine/datadir,dst=/var/lib/mysql \
-d mysql/mysql-server:5.7
If required, adjust mysql/mysql-server to the correct repository name.
If required, adjust mysql/mysql-server to the correct repository name.
Wait for the server to finish the startup operations.
Wait for the server to finish the startup operations.
The status of the server can be checked for using the ‘docker ps’ command.
The status of the server can be checked for using the ‘docker ps’ command.
Run the mysql_upgrade utility in the MySQL 5.7 Server container using the below command −
Run the mysql_upgrade utility in the MySQL 5.7 Server container using the below command −
docker exec -it mysql57 mysql_upgrade -uroot -p
When it prompts, enter the root password for the old MySQL 5.6 Server.
When it prompts, enter the root password for the old MySQL 5.6 Server.
Finish the upgrade by restarting the MySQL 5.7 Server container using the below command −
Finish the upgrade by restarting the MySQL 5.7 Server container using the below command −
docker restart mysql57
What is Default access level in Java?

The default access level is available when no access level is specified. All the classes, data members, methods etc. which have the default access level can only be accessed inside the same package.
A program that demonstrates the default access level in Java is given as follows:
 Live Demo
class Employee {
   int empno;
   String name;
   void insert(int e, String n) {
      empno = e;
      name = n;
   }
   void display() {
      System.out.println("Employee Number: " + empno);
      System.out.println("Name: " + name);
   }
}
public class Demo {
   public static void main(String[] args) {
      Employee emp = new Employee();
      emp.insert(105, "James Nortan");
      emp.display();
   }
}
Employee Number: 105
Name: James Nortan
Now let us understand the above program.
The Employee class is created with data members empno, name and member functions insert() and display(). The Employee class and the data members empno, name have the default access control. A code snippet which demonstrates this is as follows:
class Employee {
   int empno;
   String name;
   void insert(int e, String n) {
      empno = e;
      name = n;
   }
   void display() {
      System.out.println("Employee Number: " + empno);
      System.out.println("Name: " + name);
   }
}
In the main() method, an object emp of class Employee is created. Then insert() method is called with parameters 105 and “James Norton”. Finally the display() method is called. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String[] args) {
      Employee emp = new Employee();
      emp.insert(105, "James Nortan");
      emp.display();
   }
}
EasyUI React Droppable Component - GeeksforGeeks

30 Sep, 2021
In this article, we will learn how to design a draggable widget using jQuery EasyUI. EasyUI is an HTML5 framework for using user interface components based on jQuery, React, Angular, and Vue technologies. It helps in building features for interactive web and mobile applications saving a lot of time for developers. The component creates a droppable area from the markup or selector where we can drop the draggable elements.
Droppable Props:
scope: This prop is used for dropping scopes.
disabled: This prop is used to stop resizing the droppable area.
Droppable Events:
onDragEnter: The assigned event fires when the draggable object is dragged enter.
onDragOver: The assigned event fires when the draggable object is dragged over.
onDragLeave: The assigned event fires when the draggable object is dragged leave.
onDrop: The assigned event fires when the draggable object is dropped over.
Creating React Application and Installing Module:
Step 1: Create a React application using the following command.
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Step 3: After creating the ReactJS application, import the EasyUI modules using the following syntax.
import { Droppable } from "rc-easyui";
Project Structure: It will look like this.
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react';import { Draggable, Droppable } from 'rc-easyui';   class App extends React.Component {  render() {    return (      <div>        <h2>EasyUI React Draggable Component</h2>        <Draggable>          <div style={{ width: '100px',                        height: '25',                         border: '2px solid #ccc',                        background: 'green'                      }}>            <p style={{ textAlign: 'center',                        fontsize: '24px' }}>              Geeksforgeeks            </p>            </div>        </Draggable>        <Droppable          onDragEnter={() => this.setState({ isover: true })}          onDragLeave={() => this.setState({ isover: false })}          onDrop={() => this.setState({ dropped: true })}        >          <div>            <p style={{ textAlign: 'center' }}>Drop here</p>            </div>        </Droppable>      </div>    );  }}   export default App;
Step to run the application: Run the application using the following command.
npm start
Output:
EasyUI
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
How to navigate on path by button click in react router ?
How to create a table in ReactJS ?
How to parse JSON Data into React Table Component ?
Installation of Node.js on Linux
Roadmap to Become a Web Developer in 2022
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
React Native - TouchableOpacity

In this chapter we will show you button example using TouchableOpacity component.
First we need to create src/components/home/TouchableOpacity.js file.
This is just a simple container component with no additional functionality.
src/components/home/HomeContainer.js
import React, { Component } from 'react'
import TouchableOpacityExample from './TouchableOpacityExample'

export default class HomeContainer extends Component {

   constructor() {
      super();
   }
   render() {
      return (
         <TouchableOpacityExample buttonPressed = {this.buttonPressed}/>
      );
   }
}
Presentational component is a simple button with some styling.
src/components/home/TouchableOpacityExample.js
import React, { Component } from 'react'
import {
   View,
   TouchableOpacity,
   Text,
   StyleSheet
} from 'react-native'

export default TouchableOpacityExample = (props) => {
   return (
      <View style = {styles.container}>
         <TouchableOpacity>
            <Text style = {styles.button}>
               Button
            </Text>
         </TouchableOpacity>
      </View>
   )
}

const styles = StyleSheet.create ({
   container: {
      flex: 1,
      justifyContent: 'center',
      alignItems: 'center',
   },
   button: {
      borderWidth: 1,
      padding: 25,
      borderColor: 'black'
   }
})
When we press the button, opacity will change.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
CLOSINGBALANCEYEAR function

Evaluates the expression at the last date of the year in the current context.
CLOSINGBALANCEYEAR (<expression>, <dates>, [<filter>], [<year_end_date>])

expression
An expression that returns a scalar value.
dates
A column that contains dates.
filter
Optional.
An expression that specifies a filter to apply to the current context.
year_end_date
Optional.
A literal string with a date that defines the year end date. The default is December 31.
A scalar value.
The dates parameter can be any of the following −
A reference to a date/time column.
A reference to a date/time column.
A table expression that returns a single column of date/time values.
A table expression that returns a single column of date/time values.
A Boolean expression that defines a single-column table of date/time values.
A Boolean expression that defines a single-column table of date/time values.
Constraints on Boolean expressions −
The expression cannot reference a calculated field.
The expression cannot reference a calculated field.
The expression cannot use CALCULATE function.
The expression cannot use CALCULATE function.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
The expression cannot use any function that scans a table or returns a table, including aggregation functions.
However, a Boolean expression can use any function that looks up a single value, or that calculates a scalar value.
The filter parameter can be a Boolean expression or a table expression that defines a filter.
The year_end_date parameter is a string literal of a date, in the locale where the workbook was created. The year portion of the date is ignored.
Year End Inventory Value:= CLOSINGBALANCEYEAR ( 
   SUMX (ProductInventory, [UnitsBalance]*[UnitCost]),ProductInventory[InventoryDate]
) 

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Lua - Nested if statements

It is always legal in Lua programming to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).
The syntax for a nested if statement is as follows −
if( boolean_expression 1)
then
   --[ Executes when the boolean expression 1 is true --]
   if(boolean_expression 2)
   then
      --[ Executes when the boolean expression 2 is true --]
   end
end

You can nest else if...else in the similar way as you have nested if statement.
--[ local variable definition --]
a = 100;
b = 200;

--[ check the boolean condition --]

if( a == 100 )
then
   --[ if condition is true then check the following --]
   if( b == 200 )
   then
      --[ if condition is true then print the following --]
      print("Value of a is 100 and b is 200" );
   end
end

print("Exact value of a is :", a );
print("Exact value of b is :", b );
When you build and run the above code, it produces the following result.
Value of a is 100 and b is 200
Exact value of a is :	100
Exact value of b is :	200


    12 Lectures 
     2 hours 

 Manish Gupta

    80 Lectures 
     3 hours 

 Sanjeev Mittal

    54 Lectures 
     3.5 hours 

 Mehmet GOKTEPE
 Print
 Add Notes
 Bookmark this page
Python - Replace multiple words with K - GeeksforGeeks

22 Apr, 2020
Sometimes, while working with Python strings, we can have a problem in which we need to perform a replace of multiple words with a single word. This can have application in many domains including day-day programming and school programming. Lets discuss certain ways in which this task can be performed.
Method #1 : Using join() + split() + list comprehensionThe combination of above functions can be used to perform this task. In this, we split the string into words, check and replace the list words using join and list comprehension.
# Python3 code to demonstrate working of # Replace multiple words with K# Using join() + split() + list comprehension  # initializing stringtest_str = 'Geeksforgeeks is best for geeks and CS'  # printing original stringprint("The original string is : " + str(test_str))  # initializing word list word_list = ["best", 'CS', 'for']  # initializing replace word repl_wrd = 'gfg'  # Replace multiple words with K# Using join() + split() + list comprehensionres = ' '.join([repl_wrd if idx in word_list else idx for idx in test_str.split()])  # printing result print("String after multiple replace : " + str(res)) 
The original string is : Geeksforgeeks is best for geeks and CS
String after multiple replace : Geeksforgeeks is gfg gfg geeks and gfg

 
Method #2 : Using regex + join()The combination of above functions can be used to perform this task. In this, we find the words using regex and perform the replace using join() and list comprehension.
# Python3 code to demonstrate working of # Replace multiple words with K# Using regex + join()import re  # initializing stringtest_str = 'Geeksforgeeks is best for geeks and CS'  # printing original stringprint("The original string is : " + str(test_str))  # initializing word list word_list = ["best", 'CS', 'for']  # initializing replace word repl_wrd = 'gfg'  # Replace multiple words with K# Using regex + join()res = re.sub("|".join(sorted(word_list, key = len, reverse = True)), repl_wrd, test_str)  # printing result print("String after multiple replace : " + str(res)) 
The original string is : Geeksforgeeks is best for geeks and CS
String after multiple replace : Geeksforgeeks is gfg gfg geeks and gfg

Python string-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 ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Convert a list to dictionary
What is Bitwise OR Operator (|) in JavaScript?

It performs a Boolean OR operation on each bit of its integer arguments.
You can try to run the following code to learn how to work with Bitwise OR Operator (|) −
<html>
   <body>
      <script>
         var a = 2; // Bit presentation 10
         var b = 3; // Bit presentation 11

         document.write("(a | b) => ");
         result = (a | b);
         document.write(result);
      </script>
   </body>
</html>
NumPy - Array Creation Routines

A new ndarray object can be constructed by any of the following array creation routines or using a low-level ndarray constructor.
It creates an uninitialized array of specified shape and dtype. It uses the following constructor −
numpy.empty(shape, dtype = float, order = 'C')

The constructor takes the following parameters.
Shape
Shape of an empty array in int or tuple of int
Dtype
Desired output data type. Optional
Order
'C' for C-style row-major array, 'F' for FORTRAN style column-major array
The following code shows an example of an empty array.
import numpy as np 
x = np.empty([3,2], dtype = int) 
print x
The output is as follows −
[[22649312    1701344351] 
 [1818321759  1885959276] 
 [16779776    156368896]]

Note − The elements in an array show random values as they are not initialized.
Returns a new array of specified size, filled with zeros.
numpy.zeros(shape, dtype = float, order = 'C')

The constructor takes the following parameters.
Shape
Shape of an empty array in int or sequence of int
Dtype
Desired output data type. Optional
Order
'C' for C-style row-major array, 'F' for FORTRAN style column-major array
# array of five zeros. Default dtype is float 
import numpy as np 
x = np.zeros(5) 
print x
The output is as follows −
[ 0.  0.  0.  0.  0.]

import numpy as np 
x = np.zeros((5,), dtype = np.int) 
print x
Now, the output would be as follows −
[0  0  0  0  0]

# custom type 
import numpy as np 
x = np.zeros((2,2), dtype = [('x', 'i4'), ('y', 'i4')])  
print x
It should produce the following output −
[[(0,0)(0,0)]
 [(0,0)(0,0)]]         

Returns a new array of specified size and type, filled with ones.
numpy.ones(shape, dtype = None, order = 'C')

The constructor takes the following parameters.
Shape
Shape of an empty array in int or tuple of int
Dtype
Desired output data type. Optional
Order
'C' for C-style row-major array, 'F' for FORTRAN style column-major array
# array of five ones. Default dtype is float 
import numpy as np 
x = np.ones(5) 
print x
The output is as follows −
[ 1.  1.  1.  1.  1.]

import numpy as np 
x = np.ones([2,2], dtype = int) 
print x
Now, the output would be as follows −
[[1  1] 
 [1  1]]


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
How to display text Right-to-Left Using CSS ? - GeeksforGeeks

16 Jul, 2021
The task is to display a text from the right to left direction by using CSS. This is done with the help of the CSS Direction property. By default, the text alignment is set to left to right direction in HTML Document.  To display the text from right to left, we simply set the direction property to the value of “rtl”. 
Syntax:
element_selector {
   direction: rtl;
} 
Example 1:
HTML
<!DOCTYPE html><html>  <head>    <style>        h1,        h2 {            color: green;            text-align: center;        }          .rtl {            direction: rtl;        }    </style></head>  <body>    <h1>        GeeksforGeeks    </h1>      <h2>        How to display text         Right-to-Left Using CSS?    </h2>      <p class="rtl">        This text goes from right to left.    </p></body>  </html>
 
Output: 
Right to left
Example 2: In the above code, if we add some more text content in the “p” element, we get the following output. Notice the effect in both the results.
HTML
<!DOCTYPE html><html>  <head>    <style>        h1,        h2 {            color: green;            text-align: center;        }          .rtl {            direction: rtl;        }    </style></head>  <body>    <h1>        GeeksforGeeks    </h1>      <h2>        How to display text Right-to-Left Using CSS?    </h2>      <p class="rtl">        This text goes from right to left.        Another line is added.    </p></body>  </html>
Output:
Right to left 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Properties
CSS-Questions
HTML-Questions
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to Create Time-Table schedule using HTML ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)