code-rag-bench/online-tutorials huggingface dataset:
What is strtok_r() function in C language?

This function is similar to the strtok() function. The only key difference is that the _r, which is called as re-entrant function.
A re-entrant function is a function which can be interrupted during its execution. This type of function can be used to resume execution.
Because of this fact, re-entrant functions are thread-safe, means they can safely be interrupted by threads without any harm.
strtok_r() function has an extra parameter called the context. so that function can resume at the right place.
The syntax for strtok_r() function is as follows:
#include <string.h>
char *strtok_r(char *string, const char *limiter, char **context);
Following is the C program for the use of strtok_r() function −
 Live Demo
#include <stdio.h>
#include <string.h>
int main(){
   char input_string[] = "Hello Tutorials Point";
   char token_list[20][20];
   char* context = NULL;
   char* token = strtok_r(input_string, " ", &context);
   int num_tokens = 0; // Index to token list. We will append to the list
   while (token != NULL){
      strcpy(token_list[num_tokens], token); // Copy to token list
      num_tokens++;
      token = strtok_r(NULL, " ", &context);
   }
   // Print the list of tokens
   printf("Token List:\n");
   for (int i=0; i < num_tokens; i++) {
      printf("%s\n", token_list[i]);
   }
   return 0;
}
When the above program is executed, it produces the following result −
Token List:
Hello
Tutorials
Point
How to get computer's UTC offset in Python?

The computer's UTC offset is the timezone set on your computer. YOu can get this timezone information using the time module. time.timezone returns UTC offset in seconds.
import time
print(-time.timezone) # India's timezone: +5:30
This will give the output −
19800
You can also use other workarounds to get the timezone information. You can create datetime objects for UTC and local timezones and subtract them and finally get the difference to find the timezone.
import time
from datetime import datetime
ts = time.time()
utc_offset = (datetime.fromtimestamp(ts) -
              datetime.utcfromtimestamp(ts)).total_seconds()
This will give the output −
19800
Split a URL in JavaScript after every forward slash?

To split a URL, use the split() method. Use toString() before that. Let us see an example
var newURL="http://www.example.com/index.html/homePage/aboutus/";
console.log(newURL);
var splitURL=newURL.toString().split("/");
console.log(splitURL);
Above, we have set forward slash in the split() function, since we need to split the URL after
every such slash.
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo150.js. This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo150.js
http://www.example.com/index.html/homePage/aboutus/[
   'http:',
   '',
   'www.example.com',
   'index.html',
   'homePage',
   'aboutus',
   ''
]
Importance of return type in Java?

A return statement causes the program control to transfer back to the caller of a method. Every method in Java is declared with a return type and it is mandatory for all java methods. A return type may be a primitive type like int, float, double, a reference type or void type(returns nothing).
There are a few important things to understand about returning the values
The type of data returned by a method must be compatible with the return type specified by the method. For instance, if the return type of some method is boolean, we can not return an integer.
The variable receiving the value returned by a method must also be compatible with the return type specified for the method.
The parameters can be passed in a sequence and they must be accepted by the method in the same sequence.
public class ReturnTypeTest1 {
   public int add() { // without arguments
      int x = 30;
      int y = 70;
      int z = x+y;
      return z;
   }
   public static void main(String args[]) {
      ReturnTypeTest1 test = new ReturnTypeTest1();
      int add = test.add();
      System.out.println("The sum of x and y is: " + add);
   }
}
The sum of x and y is: 100

public class ReturnTypeTest2 {
   public int add(int x, int y) { // with arguments
      int z = x+y;
      return z;
   }
   public static void main(String args[]) {
      ReturnTypeTest2 test = new ReturnTypeTest2();
      int add = test.add(10, 20);
      System.out.println("The sum of x and y is: " + add);
   }
}
The sum of x and y is: 30
C/C++ Tokens?

C++ Tokens are the smallest individual units of a program.
C++ is the superset of C and so most constructs of C are legal in C++ with their meaning and usage unchanged. So tokens, expressions, and data types are similar to that of C.
Following are the C++ tokens : (most of c++ tokens are basically similar to the C tokens)
Keywords
Identifiers
Constants
Variables
Operators
Keywords are reserved words which have fixed meaning, and its meaning cannot be changed. The meaning and working of these keywords are already known to the compiler. C++ has more numbers of keyword than C, and those extra ones have special working capabilities.
There are 32 of these, and here they are
auto const double float int short struct unsigned
break continue elseforlong signed switch void
case default enumgoto register sizeof typedef volatile
char do extern if return static unionwhile
There are another 30 reserved words that were not in C, are therefore new to C++,
and here they are -
asm dynamic_cast namespace reinterpret_cast try
bool explicit new static_cast typeid
catch false operator template typename
class friend privatethis using
const_cast inline public throw virtual
delete mutable protected true wchar_t
Identifiers are names given to different entries such as variables, structures, and functions. Also, identifier names should have to be unique because these entities are used in the execution of the program.
Identifier naming conventions
Only alphabetic characters, digits and underscores are permitted.
Only alphabetic characters, digits and underscores are permitted.
First letter must be an alphabet or underscore (_).
First letter must be an alphabet or underscore (_).
Identifiers are case sensitive.
Identifiers are case sensitive.
Reserved keywords can not be used as an identifier's name.
Reserved keywords can not be used as an identifier's name.
Constants are like a variable, except that their value never changes during execution once defined.
There are two other different ways to define constants in C++. These are:
By using const keyword
By using const keyword
By using #define preprocessor
By using #define preprocessor
Declaration of a constant :
const [data_type] [constant_name]=[value];
A variable is a meaningful name of data storage location in computer memory. When using a variable you refer to memory address of computer.
Syntax to declare a variable
[data_type] [variable_name];
#include <iostream.h>
int main() {
   int a,b;// a and b are integer variable
   cout<<" Enter first number :";
   cin>>a;
   cout<<" Enter the second number:";
   cin>>b;
   int sum;
   sum=a+b;
   cout<<" Sum is : "<<sum <<"\n";
   return 0;
}
C++ operator is a symbol that is used to perform mathematical or logical manipulations.
Arithmetic Operators
Increment and Decrement Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Misc Operators
Multiply any Number with using Bitwise Operator in C++

In this tutorial, we are going write a program that multiplies the given two numbers using bitwise operators.
The left shift (<<) operator is used for the multiplication whereas the right shift (>>) is used for the division.
The multiplication of two numbers x, y can be written as x * y = (x * 2) * (y / 2) if y is even else it's equal to x * y = (x * y) * (y / 2) + x.
So whenever the second number becomes odd, add the first number to the result. Let's see the steps to solve the problem.
Initialise two numbers.
Write a loop that iterates till the second number becomes 0.If the second number is odd, then add the first number to the result.Left shift first number by 1 bit.Right shift second number by 1 bit.
If the second number is odd, then add the first number to the result.
Left shift first number by 1 bit.
Right shift second number by 1 bit.
Following is the implementation of the above algorithm in C++
#include <bits/stdc++.h>
using namespace std;
int multiplyTwoNumbers(int a, int b) {
   int result = 0;
   while (b > 0) {
      if (b & 1) {
         result += a;
         }
      a = a << 1;
      b = b >> 1;
   }
   return result;
}
int main() {
   cout << multiplyTwoNumbers(75, 4) << endl;
   cout << multiplyTwoNumbers(90, 9) << endl;
   cout << multiplyTwoNumbers(83, 66) << endl;
   return 0;
}
If you run the above code, then you will get the following result.
300
810
5478
Online JSON Formatter

Editable JSON Code
12345678910111213141516{"Company": {"Employee": {"FirstName": "Tanmay","LastName": "Patil","ContactNo": "1234567890","Email": "tanmaypatil@xyz.com","Address": {"City": "Bangalore","State": "Karnataka","Zip": "560212"}}}}X
Privacy Policy
Cookies Policy
Terms of Use
C++ Program to Calculate Power Using Recursion

The power of a number can be calculated as x^y where x is the number and y is its power.
For example.
Let’s say, x = 2 and y = 10
x^y =1024
Here, x^y is 2^10
A program to find the power using recursion is as follows.
 Live Demo
#include <iostream>
using namespace std;
int FindPower(int base, int power) {
   if (power == 0)
   return 1;
   else
   return (base * FindPower(base, power-1));
}
int main() {
   int base = 3, power = 5;
   cout<<base<<" raised to the power "<<power<<" is "<<FindPower(base, power);
   return 0;
}
3 raised to the power 5 is 243
In the above program, the function findPower() is a recursive function. If the power is zero, then the function returns 1 because any number raised to power 0 is 1. If the power is not 0, then the function recursively calls itself. This is demonstrated using the following code snippet.
int FindPower(int base, int power) {
   if (power == 0)
   return 1;
   else
   return (base * findPower(base, power-1));
}
In the main() function, the findPower() function is called initially and the power of a number is displayed.
This can be seen in the below code snippet.
3 raised to the power 5 is 243
Concatenating variable number of arrays into one - JavaScript

We are required to write a JavaScript function that takes in any number of JavaScript arrays and returns one single array with all the values from input arrays concatenated into it.
For example − If the input arrays are −
[1, 5], [44, 67, 3], [2, 5], [7], [4], [3, 7], [6]
Then the output should be −
const output = [1, 5, 44, 67, 3, 2, 5, 7, 4, 3, 7, 6];
Following is the code −
const a = [1, 5], b = [44, 67, 3], c = [2, 5], d = [7], e = [4], f = [3,
7], g = [6];
const concatArrays = (...arr) => {
   const res = arr.reduce((acc, val) => {
      return acc.concat(...val);
   }, []);
   return res;
};
console.log(concatArrays(a, b, c, d, e, f, g));
Following is the output in the console −
[
   1, 5, 44, 67, 3,
   2, 5,  7,  4, 3,
   7, 6
]
Hiding SAP ABAP table control column

You can use the structure CXTAB_CONTROL that has the following components:
INVISIBLE C(1) Flag (X or blank) for visibility of entire table control.
You can use sample program: RSDEMO02 that allow you to modify properties of table control and view the results.
When you use this Table control INVISIBLE, this changes the content to “xxxxxxxxxxxx” like a hidden password. If you want to hide the complete column including data and header, your code should be like this −
MODULE MODIFY_100 OUTPUT.
 DATA wa_tabctrl TYPE cxtab_column .
looping the table control
LOOP AT TABCTRL-COLS INTO WA_TABCTRL.
 IF WA_TABCTRL-NAME =  'POSNR'. 
When you get on the desired screen you need to flag the INVISIBLE field for the table control, not the SCREEN table.
WA_TABCTRL-INVISIBLE =  'X'.
Modify the table for table control like this
      MODIFY TABCTRL-COLS FROM WA_TABCTRL.
     ENDIF.
  ENDLOOP.
 ENDMODULE.
Local Inner Class in C#

A nested class is a class declared in another enclosing class and it has inner as well as outer class. It is a member of its enclosing class and the members of an enclosing class have no access to members of a nested class
Let us see an example code snippet of nested classes in C#.
Here, class Two is a local inner class −
class One {
   public int num1;
   public class Two {
      public int num2;
   }
}
class Demo {
   static void Main() {
      One x = new One();
      x.num1++;

      One.Two xy = new One.Two();
      xy.num2++;
   }
}
The example shows that class Two is a nested class. Class Two is enclosed inside the class One declaration.
The class Two here is enclosed inside the declaration of class One. Class Two is thus a nested class. Because it has a public accessibility modifier, it can be accessed in places other than class One's scope.
Python program to validate email address

Suppose we have an email address as string. We have to check whether this is valid or not based on the following conditions −
The format must be username@company.domain format
The format must be username@company.domain format
Username can only contain upper and lowercase letters, numbers, dashes and underscores
Username can only contain upper and lowercase letters, numbers, dashes and underscores
Company name can only contain upper and lowercase letters and numbers
Company name can only contain upper and lowercase letters and numbers
Domain can only contain upper and lowercase letters
Domain can only contain upper and lowercase letters
Maximum length of the extension is 3.
Maximum length of the extension is 3.
We can use regular expression to validate the mail addresses. Regular expressions can be used by importing re library. To match a pattern we shall use match() function under re library.
So, if the input is like s = "popular_website15@comPany.com", then the output will be True
To solve this, we will follow these steps −
pat := "starting with [a-zA-Z0-9-_] then @ then company name with [a-zA-Z0-9] then separated by dot and domain with [a-z] whose length is 1 to 3 and this is present at end"
if pat matches with s, thenreturn True
return True
otherwise return False
Let us see the following implementation to get better understanding
import re

def solve(s):
   pat = "^[a-zA-Z0-9-_]+@[a-zA-Z0-9]+\.[a-z]{1,3}$"
   if re.match(pat,s):
      return True
   return False

s = "popular_website15@comPany.com"
print(solve(s))
"popular_website15@comPany.com"

True
Why do we need a copy constructor and when should we use a copy constructor in Java?

A copy constructor is a parameterized constructor and it can be used when we want to copy the values of one object to another.
class Employee {
   int id;
   String name;

   Employee(int id, String name)
   {
      this.id = id;
      this.name = name;
   }
   Employee(Employee e)
   {
      id = e.id;
      name = e.name;
   }
   void show()
   {
      System.out.println(id + " " + name);
   }
   public static void main(String args[])
   {
      Employee e1 = new Employee(001, "Aditya");
      Employee e2 = new Employee(e1);
      e1.show();
      e2.show();
   }
}
In the above code, e1 is passed as an argument to the second constructor. Thus values of e1 are copied into object e2.
1 Aditya
1 Aditya
Firebase - Google Authentication

In this chapter, we will show you how to set up Google authentication in Firebase.
Open Firebase dashboard and click Auth on the left side menu. To open the list of available methods, you need to click on SIGN_IN_METHODS in the tab menu.
Now you can choose Google from the list, enable it and save it.
Inside our index.html, we will add two buttons.
<button onclick = "googleSignin()">Google Signin</button>
<button onclick = "googleSignout()">Google Signout</button>
In this step, we will create Signin and Signout functions. We will use signInWithPopup() and signOut() methods.
Let us consider the following example.
var provider = new firebase.auth.GoogleAuthProvider();

function googleSignin() {
   firebase.auth()
   
   .signInWithPopup(provider).then(function(result) {
      var token = result.credential.accessToken;
      var user = result.user;
		
      console.log(token)
      console.log(user)
   }).catch(function(error) {
      var errorCode = error.code;
      var errorMessage = error.message;
		
      console.log(error.code)
      console.log(error.message)
   });
}

function googleSignout() {
   firebase.auth().signOut()
	
   .then(function() {
      console.log('Signout Succesfull')
   }, function(error) {
      console.log('Signout Failed')  
   });
}
After we refresh the page, we can click on the Google Signin button to trigger the Google popup. If signing in is successful, the developer console will log in our user.
We can also click on the Google Signout button to logout from the app. The console will confirm that the logout was successful.

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
How to replace substring in MongoDB document?

In order to replace substring in MongoDB document, you can use the replace() function. To understand it further, let us create a collection with document. The query to create a collection with document is as follows −
> db.replaceSubstringDemo.insertOne({"WebsiteURL":"www.gogle.com"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76eaf21e9c5dd6f1f78276")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.replaceSubstringDemo.find().pretty();
{
   "_id" : ObjectId("5c76eaf21e9c5dd6f1f78276"),
   "WebsiteURL" : "www.gogle.com"
}
Here is the query to replace substring in MongoDB document −
> db.replaceSubstringDemo.find({WebsiteURL:"www.gogle.com"}).forEach(function(url,k){
   ... url.WebsiteURL=url.WebsiteURL.replace("www.gogle.com","www.google.com");
   ... db.replaceSubstringDemo.save(url)
   ... });
Let us display the document from a collection once again to verify the replacement has been done or not. The query is as follows −
> db.replaceSubstringDemo.find().pretty();
{
   "_id" : ObjectId("5c76eaf21e9c5dd6f1f78276"),
   "WebsiteURL" : "www.google.com"
}
How to iterate the values in an enum in Java?

Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.
enum Days {
   SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
You can iterate the contents of an enumeration using for loop, using forEach loop and, using java.util.stream.
You can retrieve the contents of an enum using the values() method. This method returns an array containing all the values. Once you obtain the array you can iterate it using the for loop.
Following java program iterates the contents of the enum Days created above, using the for loop −
public class IterateEnum{
   public static void main(String args[]) {
      Days days[] = Days.values();
      System.out.println("Contents of the enum are: ");
      //Iterating enum using the for loop
      for(Days day: days) {
         System.out.println(day);
      }
   }
}
Contents of the enum are:
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
You can convert the enum into a list or set and perform required actions on each element of the list using the forEach() method.
EnumSet.allOf(Days.class).forEach(day -> System.out.println(day));
Or,
Arrays.asList(Days.values()).forEach(day -> System.out.println(day));
Following java program converts the enum Days created above into a set and, iterates its contents using forEach loop −
import java.util.EnumSet;
public class IterateEnum{
   public static void main(String args[]) {
      Days days[] = Days.values();
      System.out.println("Contents of the enum are: ");
      //Iterating enum using forEach loop
      EnumSet.allOf(Days.class).forEach(day -> System.out.println(day));
   }
}
Contents of the enum are:
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
You can use foreach loop with streams too. Therefore, using the of() method of the Stream class you can convert the contents of an enum into a stream and perform required operation on its elements using the forEach loop.
Following java program converts the enum Days created above into a Stream using the of() method and, iterates its contents using forEach loop −
import java.util.stream.Stream;
public class IterateEnum{
   public static void main(String args[]) {
      Days days[] = Days.values();
      System.out.println("Contents of the enum are: ");
      //Iterating the enum using java.util.stream
      Stream.of(Days.values()).forEach(System.out::println);
   }
}
Contents of the enum are:
SUNDAY
MONDAY
TUESDAY
WEDNESDAY
THURSDAY
FRIDAY
SATURDAY
Difference between while(1) and while(0) in C/C++

Here we will see what are the differences between while(1) and while(0) in C or C++. The while is a loop of C or C++. Using this loop we can check one condition, and the statements inside the loop will be executed while the condition is true.
The while(1) or while(any non-zero value) is used for infinite loop. There is no condition for while. As 1 or any non-zero value is present, then the condition is always true. So what are present inside the loop that will be executed forever. To come out from this infinite loop, we have to use conditional statement and break statement.
#include<iostream>
using namespace std;
main(){
   int i = 0;
   cout << "Starting Loop" << endl;
   while(1){
      cout << "The value of i: " << ++i <<endl;
      if(i == 10){ //when i is 10, then come out from loop
         break;
      }
   }
   cout << "Ending Loop" ;
}
Starting Loop
The value of i: 1
The value of i: 2
The value of i: 3
The value of i: 4
The value of i: 5
The value of i: 6
The value of i: 7
The value of i: 8
The value of i: 9
The value of i: 10
Ending Loop
Similarly the while(0) is treated as while with false condition. So this kind of loop is useless. It will never execute the inner statement as 0 is treated as false.
#include<iostream>
using namespace std;
main(){
   int i = 0;
   cout << "Starting Loop" << endl;
   while(0){
      cout << "The value of i: " << ++i <<endl;
      if(i == 10){ //when i is 10, then come out from loop
         break;
      }
   }
   cout << "Ending Loop" ;
}
Starting Loop
Ending Loop
JavaScript String - toLowerCase() Method

This method returns the calling string value converted to lowercase.
Its syntax is as follows −
string.toLowerCase( )

Returns the calling string value converted to lowercase.
Try the following example.
<html>
   <head>
      <title>JavaScript String toLowerCase() Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var str = "Apples are round, and Apples are Juicy.";
         document.write(str.toLowerCase( ));
      </script>      
   </body>
</html>
apples are round, and apples are juicy.


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Configuring Face Unlock in Ubuntu | Howdy - GeeksforGeeks

26 Aug, 2019
With the growth of AI and Machine Learning, the power of face recognition is increasing day by day. It has a lot of applications one of which is face authentication. So, to configure face unlock in ubuntu we will use howdy which provides Windows HelloTM style authentication for Linux. It is open-source, written in python and currently available for Debian/Ubuntu, Arch Linux, and Fedora.
Step 1: To install Howdy we need to add required PPA for Howdy
$ sudo add-apt-repository ppa:boltgolt/howdy
Type this command and press Enter
Step 2: After installing PPA it’s good to update and upgrade system.
$ sudo apt-get update && sudo apt-get upgrade
Step 3: Now installing howdy
$ sudo apt install howdy
While unpacking it will ask for trying camera press “y” and enter
Step 4: To configure howdy, add your face, so howdy can recognize your face.
$ sudo howdy add
To see more configure options:
$ howdy
GBlog
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Roadmap to Become a Web Developer in 2022
DSA Sheet by Love Babbar
Types of Software Testing
Top 10 Python Books for Beginners and Advanced Programmers
Working with PDF files in Python
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
Product of all the Composite Numbers in an array in C++

Given an array arr[n] of n number of integers, the task is to find the product of all composite numbers in an array.
Composite numbers are the whole numbers which are made by multiplying 2 other whole numbers. For example 6 is a composite number which can be made by multiplying 2 and 3 which are whole numbers. Also we can say they are not prime.
Input 
arr[] = {1, 2, 4, 5, 6, 7}
Output 
24
Explanation − the composite numbers in the array are 4 and 6 and their product is 24.
Input 
arr[] = {10, 2, 4, 5, 6, 11}
Output 
240
Explanation − the composite numbers in the array are 10, 4, 6 and their Product is 240.
Iterate every element of an array.
Iterate every element of an array.
Find for the non-prime or composite numbers, i.e. divisible by some other number except 1.
Find for the non-prime or composite numbers, i.e. divisible by some other number except 1.
Multiply all the composite numbers.
Multiply all the composite numbers.
Return the result.
Return the result.
Start
Step 1→ Declare function to find the product of consecutive numbers in array
   int product_arr(int arr[], int size)
      declare int max = *max_element(arr, arr + size)
      set vector<bool> prime(max + 1, true)
      set prime[0] = true
      set prime[1] = true
      Loop For int i = 2 and i * i <= max and i++
         IF (prime[i] == true)
            Loop For int j = i * 2 and j <= max and j += i
               Set prime[j] = false
            End
         End
      End
      Set int product = 1
      Loop For int i = 0 and i < size and i++
         IF (!prime[arr[i]])
            Set product *= arr[i]
         End
      End
      return product
Stop
 Live Demo
#include <bits/stdc++.h>
using namespace std;
//function to find product of consecutive numbers in an array
int product_arr(int arr[], int size){
   int max = *max_element(arr, arr + size);
   vector<bool> prime(max + 1, true);
   prime[0] = true;
   prime[1] = true;
   for (int i = 2; i * i <= max; i++){
      if (prime[i] == true){
         for (int j = i * 2; j <= max; j += i)
            prime[j] = false;
      }
   }
   int product = 1;
   for (int i = 0; i < size; i++)
      if (!prime[arr[i]]){
         product *= arr[i];
      }
      return product;
}
int main(){
   int arr[] = { 2, 4, 6, 8, 10};
   int size = sizeof(arr) / sizeof(arr[0]);
   cout<<"product of consecutive numbers in an array: "<<product_arr(arr, size);
   return 0;
}
If run the above code it will generate the following output −
product of consecutive numbers in an array: 1920
How to set the thumbnail image on video in HTML 5 ?

27 Apr, 2020
Introduction: In this article, we are going to learn how to set a thumbnail image for an HTML5 video. Thumbnail is the image that is displayed as a preview of the video. Basically it is used to represent what the video contains or what it is related to. It is displayed until the time the video is started. By default, the first frame of the video is displayed as the initial preview for the video.
Approach: Sometimes the user wants to display a specific image of his choice as the thumbnail of the video. This can be simply done by using the poster attribute. All you have to do is create a poster attribute in the video tag and place the URL of the thumbnail image in it.
Syntax:
<video height="" width="" poster="URL of the image to be displayed">
Example:
<!DOCTYPE html><html>  <body>      <video width="400"            height="350"            controls poster="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png">        <source src="https://media.geeksforgeeks.org/wp-content/uploads/20200409094356/Placement100-_-GeeksforGeeks2.mp4"                type="video/mp4">    </video></body>  </html>
Output:
Explanation: The poster attribute of the video tag contains the URL of the image that the user wants to set as the thumbnail of the video which is the image that will be visible until the user press the play button. The src attribute contains the URL of the video and the control attribute shows features like play/pause/seek/volume in the video.
For more information on HTML video tag please visit here
HTML-Misc
HTML5
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Steady State Model using MATLAB

20 Aug, 2020
A steady state model must be utilized to produce an underlying state when the model is begun from rest, an alleged “cold beginning.” On the off chance that a system is in a steady state, at that point the as of late watched conduct of the system will proceed into what’s to come. In systems, a system or a procedure is in a steady state if the factors (called state factors) which characterize the conduct of the system or the procedure are constant in time.
State Space Representation:
Arrange above in Matrix form
Code :
% Matrix of 3×3A = [1 2 0; 0 1 1; 0 0 1]   % Column of 3×1B = [0; 1; 0]   % Row of 1×3C = [1 0 0]   D = [5]  % Continuous time state space modelSYS = ss(A, B, C, D)   % Continuous time transfer functiontf(SYS)   % Continuous time zero/pole/gain modelzpk(SYS) 
Output :
MATLAB
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove unnecessary values from an Object in R Programming – na.omit() Function

23 Jun, 2020
na.omit() function in R Language is used to omit all unnecessary cases from data frame, matrix or vector.
Syntax: na.omit(data)
Parameter:data: Set of specified values of data frame, matrix or vector.
Returns: Range of values after NA omission.
Example 1:
# R program to remove # unnecessary values  # Creating a data framedata <- data.frame(          # Column with 2 missing values    x1 = c(1, 2, NA, 5, 9, 7, NA),           # Column with 1 missing values    x2 = c(11, 1, NA, 1, 7, 9, 1),           # Column without missing values    x3 = c(5, 7, 6, 2, 8, 1, 6))        data    # Apply na.omit() functiondata_omit <- na.omit(data)   # Print omitted data data_omit                                        
Output:
  
  x1 x2 x3
1  1 11  5
2  2  1  7
3 NA NA  6
4  5  1  2
5  9  7  8
6  7  9  1
7 NA  1  6
 
  x1 x2 x3
1  1 11  5
2  2  1  7
4  5  1  2
5  9  7  8
6  7  9  1

Example 2:
# R program to remove # unnecessary values  # Creating a data framedata <- data.frame(x1 = c(1, 2, NA, 5, 9, 7, NA))   # Original data vector with NAsdata$x1       # Calling na.omit() functionna.omit(data$x1)   # Vector without NAsas.numeric(na.omit(data$x1))       
Output :
[1]  1  2 NA  5  9  7 NA
[1] 1 2 5 9 7
attr(, "na.action")
[1] 3 7
attr(, "class")
[1] "omit"
[1] 1 2 5 9 7

R DataFrame-Function
R List-Function
R Matrix-Function
R Object-Function
R Vector-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tryit Editor v3.6 - Show Java

public class Main {
  public static void main(String[] args) {
    Person myObj = new Person();
    myObj.setName("John");
    System.out.println(myObj.getName());
  }
}



public class Person {
   private String name;

   // Getter
   public String getName() {
     return name;
   }

   // Setter
   public void setName(String newName) {
     this.name = newName;
Check if all array elements are distinct in Python

Suppose we have a list of numbers called nums, we have to check whether all elements in nums are unique or not.
So, if the input is like nums = [2, 3, 6, 5, 1, 8], then the output will be True as all elements are unique.
To solve this, we will follow these steps −
n := size of l
s := a new set
for i in range 0 to n, doinsert l[i] into s
insert l[i] into s
return true when size of s is same as size of l, otherwise false
Let us see the following implementation to get better understanding −
 Live Demo
def solve(l) :
   n = len(l)
   s = set()
   for i in range(0, n):
      s.add(l[i])
   return (len(s) == len(l))
l = [2, 3, 6, 5, 1, 8]
print(solve(l))
[2, 3, 6, 5, 1, 8]
True
How to create a MySQL table with MyISAM engine table?

To create a MySQL table with MyISAM engine, we can use ENGINE command. Let us first create a table using CREATE command.
mysql> create table StudentRecordWithMyISAM
   -> (
   -> Id int,
   -> StudentName varchar(100),
   -> StudentAge int
   -> )ENGINE=MyISAM;
Query OK, 0 rows affected (0.26 sec)
Above, we have set the ENGINE as “MyISAM”.
To check how many columns are present in the table, use DESC command.
mysql> DESC StudentRecordWithMyISAM;
The following is the output.
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| Id          | int(11)      | YES  |     | NULL    |       |
| StudentName | varchar(100) | YES  |     | NULL    |       |
| StudentAge  | int(11)      | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

To check if the table is presented with MyISAM or not.
mysql>  SHOW TABLE STATUS FROM business LIKE 'StudentRecordWithMyISAM';
The following is that output that clearly shows the ENGINE is MyISAM.
+-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| Name                    | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time         | Check_time | Collation          | Checksum | Create_options | Comment |
+-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
| studentrecordwithmyisam | MyISAM |      10 | Dynamic    |    0 |              0 |           0 | 281474976710655 |         1024 |         0 |              1 | 2018-10-22 15:47:01 | 2018-10-22 15:47:02 | NULL       | utf8mb4_unicode_ci |     NULL |                |         |
+-------------------------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------+
1 row in set (0.14 sec)

To check if the MyISAM table exists or not.
mysql> SELECT TABLE_NAME,
   ->  ENGINE
   -> FROM information_schema.TABLES
   -> WHERE TABLE_SCHEMA = 'business' and ENGINE = 'MyISAM';
The following is the output.
+-------------------------+--------+
| TABLE_NAME              | ENGINE |
+-------------------------+--------+
| studentrecordwithmyisam | MyISAM |
+-------------------------+--------+
1 row in set (0.00 sec)
HTML - <span> Tag

The HTML <span> tag is used for grouping and applying styles to inline elements.
There is a difference between the span tag and the div tag. The span tag is used with inline elements whilst the div tag is used with block-level content.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML span Tag</title>
   </head>

   <body>
      <p>This is a paragraph <span style = "color:#FF0000;">
         This is a paragraph</span>This is a paragraph</p>
      
      <p><span style = "color:#8866ff;">
         This is another paragraph</span></p>
   </body>

</html>
This will produce the following result −
This is a paragraph  
This is a paragraph 
This is a paragraph
 
This is another paragraph
This tag supports all the global attributes described in − HTML Attribute Reference
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
Combine columns into rows with MySQL?

To combine columns into rows, use UNION ALL. Following is the syntax −
select yourColumnName1 from yourTableName
   union all
select yourColumnName2 from yourTableName;
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Value1 int,
   -> Value2 int
   -> );
Query OK, 0 rows affected (0.88 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,200);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values(500,600);
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+--------+
| Value1 | Value2 |
+--------+--------+
|    100 |    200 |
|    500 |    600 |
+--------+--------+
2 rows in set (0.00 sec)
Here is the query to combine columns into rows −
mysql> select Value1 from DemoTable
   -> union all
   -> select Value2 from DemoTable;
This will produce the following output −
+--------+
| Value1 |
+--------+
|    100 |
|    500 |
|    200 |
|    600 |
+--------+
4 rows in set (0.00 sec)
How to make the marker face color transparent without making the line transparent in Matplotlib?

To make the marker face color transparent without making the line transparent in matplotlib, we can take the following steps −
Create x_data and y_data(sin(x_data)), using numpy.
Create x_data and y_data(sin(x_data)), using numpy.
Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque.
Plot curve using x_data and y_data, with marker style and marker size. By changing the alpha, we can make it transparent to opaque.
To get the essence of transparency (keeping alhpa value lesser), we can make grid lines, to see through.
To get the essence of transparency (keeping alhpa value lesser), we can make grid lines, to see through.
To display the figure, use the show() method.
To display the figure, use the show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x_data = np.linspace(1, 10, 100)
y_data = np.sin(x_data)
plt.plot(x_data, y_data, c='green', marker='o', alpha=.3, ms=10, lw=1)
plt.grid()
plt.show()
Program to check robot can reach target position or not in Python

Suppose we have a robot, that is currently sitting in at position (0, 0) (Cartesian plane). If we
have list of its moves that it can make, containing N(North), S(South), W(West), and E(East). We
have to check whether it can reach at destination coordinate (x, y).
So, if the input is like moves = ['N','N','E','E','S'], (x,y) = (2,1), then the output will be True,
To solve this, we will follow these steps −
temp_coord := [0,0]
for each move in moves, doif move is same as "N", thentemp_coord[1] := temp_coord[1] + 1otherwise when move is same as "S", thentemp_coord[1] := temp_coord[1] - 1otherwise when move is same as "E", thentemp_coord[0] := temp_coord[0] + 1otherwise when move is same as "W", thentemp_coord[0] := temp_coord[0] - 1
if move is same as "N", thentemp_coord[1] := temp_coord[1] + 1
temp_coord[1] := temp_coord[1] + 1
otherwise when move is same as "S", thentemp_coord[1] := temp_coord[1] - 1
temp_coord[1] := temp_coord[1] - 1
otherwise when move is same as "E", thentemp_coord[0] := temp_coord[0] + 1
temp_coord[0] := temp_coord[0] + 1
otherwise when move is same as "W", thentemp_coord[0] := temp_coord[0] - 1
temp_coord[0] := temp_coord[0] - 1
return True when temp_coord[0] is same as coord[0] and temp_coord[1] is same as
coord[1] otherwise false.
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, moves, coord):
      temp_coord = [0,0]
      for move in moves:
         if move == "N":
            temp_coord[1] += 1
         elif move == "S":
            temp_coord[1] -= 1
         elif move == "E":
            temp_coord[0] += 1
         elif move == "W":
            temp_coord[0] -= 1
      return temp_coord[0] == coord[0] and temp_coord[1] == coord[1]
ob = Solution()
moves = ['N','N','E','E','S']
coord = [2,1]
print(ob.solve(moves, coord))
['N','N','E','E','S'], [2,1]
True
Octal Arithmetic

Following are the characteristics of an octal number system.
Uses eight digits, 0,1,2,3,4,5,6,7.
Uses eight digits, 0,1,2,3,4,5,6,7.
Also called base 8 number system.
Also called base 8 number system.
Each position in an octal number represents a 0 power of the base (8). Example: 80
Each position in an octal number represents a 0 power of the base (8). Example: 80
Last position in an octal number represents an x power of the base (8). Example: 8x where x represents the last position - 1.
Last position in an octal number represents an x power of the base (8). Example: 8x where x represents the last position - 1.
Octal Number − 125708
Calculating Decimal Equivalent −
Note − 125708 is normally written as 12570.
Following octal addition table will help you to handle octal addition.
To use this table, simply follow the directions used in this example: Add 68 and 58. Locate 6 in the A column then locate the 5 in the B column. The point in 'sum' area where these two columns intersect is the 'sum' of two numbers.
68 + 58 = 138.

The subtraction of octal numbers follows the same rules as the subtraction of numbers in any other number system. The only variation is in borrowed number. In the decimal system, you borrow a group of 1010. In the binary system, you borrow a group of 210. In the octal system you borrow a group of 810.

    107 Lectures 
     13.5 hours 

 Arnab Chakraborty

    106 Lectures 
     8 hours 

 Arnab Chakraborty

    99 Lectures 
     6 hours 

 Arnab Chakraborty

    46 Lectures 
     2.5 hours 

 Shweta

    70 Lectures 
     9 hours 

 Abhilash Nelson

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj
 Print
 Add Notes
 Bookmark this page
ES6 - Boolean

The Boolean object represents two values, either "true" or "false". If the value parameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false.
Use the following syntax to create a boolean object.
var val = new Boolean(value);

Following is a list of the properties of Boolean object.
Returns a reference to the Boolean function that created the object.
The prototype property allows you to add properties and methods to an object.
Following is a list of the methods of Boolean object and their description.
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
Returns a string of either "true" or "false" depending upon the value of the object.
Returns the primitive value of the Boolean object.
In the following sections, we will take a look at a few examples to demonstrate the usage of the Boolean methods.

    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
C++ Arithmetic Operators

Try the following example to understand all the arithmetic operators available in C++.
Copy and paste the following C++ program in test.cpp file and compile and run this program.
#include <iostream>
using namespace std;
 
main() {
   int a = 21;
   int b = 10;
   int c ;
 
   c = a + b;
   cout << "Line 1 - Value of c is :" << c << endl ;
   
   c = a - b;
   cout << "Line 2 - Value of c is  :" << c << endl 
   ;
   c = a * b;
   cout << "Line 3 - Value of c is :" << c << endl ;
   
   c = a / b;
   cout << "Line 4 - Value of c is  :" << c << endl ;
   
   c = a % b;
   cout << "Line 5 - Value of c is  :" << c << endl ;
   
   c = a++; 
   cout << "Line 6 - Value of c is :" << c << endl ;
   
   c = a--; 
   cout << "Line 7 - Value of c is  :" << c << endl ;
   
   return 0;
}
When the above code is compiled and executed, it produces the following result −
Line 1 - Value of c is :31
Line 2 - Value of c is  :11
Line 3 - Value of c is :210
Line 4 - Value of c is  :2
Line 5 - Value of c is  :1
Line 6 - Value of c is :21
Line 7 - Value of c is  :22


    154 Lectures 
     11.5 hours 

 Arnab Chakraborty

    14 Lectures 
     57 mins

 Kaushik Roy Chowdhury

    30 Lectures 
     12.5 hours 

 Frahaan Hussain

    54 Lectures 
     3.5 hours 

 Frahaan Hussain

    77 Lectures 
     5.5 hours 

 Frahaan Hussain

    12 Lectures 
     3.5 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Python Arithmetic Operators Example

Assume variable a holds 10 and variable b holds 20, then −
Assume variable a holds 21 and variable b holds 10, then −
#!/usr/bin/python

a = 21
b = 10
c = 0

c = a + b
print "Line 1 - Value of c is ", c

c = a - b
print "Line 2 - Value of c is ", c 

c = a * b
print "Line 3 - Value of c is ", c 

c = a / b
print "Line 4 - Value of c is ", c 

c = a % b
print "Line 5 - Value of c is ", c

a = 2
b = 3
c = a**b 
print "Line 6 - Value of c is ", c

a = 10
b = 5
c = a//b 
print "Line 7 - Value of c is ", c
When you execute the above program, it produces the following result −
Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of c is 2
Line 5 - Value of c is 1
Line 6 - Value of c is 8
Line 7 - Value of c is 2


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to change the marker size with pandas.plot() in Matplotlib?

To change the marker size with pandas.plot(), we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Create a Pandas dataframe with three columns, col1, col2 and col3.
Use pandas.plot() with marker="*" and markersize=15.
To display the figure, use show() method.
import matplotlib.pyplot as plt
import pandas as pd

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

df = pd.DataFrame([[2, 1, 4], [5, 2, 1], [4, 0, 1]], columns=['col1', 'col2', 'col3'])

df.plot(marker="*", markersize=15)

plt.show()