# Trending November 2023 # How To Perform Arithmetic Operations On Two # Suggested December 2023 # Top 20 Popular

You are reading the article How To Perform Arithmetic Operations On Two updated in November 2023 on the website Hatcungthantuong.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested December 2023 How To Perform Arithmetic Operations On Two

An array is a group of related data items that are stored with single name.

For example, int student[30]; Operations of array

Searching − It is used to find whether particular element is present or not

Sorting − It helps in arranging the elements in an array either in ascending or descending order.

Traversing − It processes every element in an array sequentially.

Inserting − It helps in inserting the elements in an array.

Deleting − It helps in deleting an element in an array.

The logic applied to perform arithmetic operation of two-dimensional array is as follows −

for(row = 0; row < i; row++){    for(col = 0;col < j;col++){       add[row][col] = A[row][col] + B[row][col];       sub[row][col] = A[row][col] - B[row][col];       mul[row][col] = A[row][col] * B[row][col];       div[row][col] = A[row][col] / B[row][col];       mod[row][col] = A[row][col] % B[row][col];    } for(row = 0; row < i; row++){    for(col = 0; col < j; col++){       printf("%d t ", sub[row][col]);       printf("%d t ", mul[row][col]);       printf("%.2f t ", div[row][col]);       printf("%d t ", mod[row][col]);    } int main(){    int i, j, row, col,A[20][20], B[20][20];    int add[10][10], sub[10][10], mul[10][10], mod[10][10];    float div[10][10];    scanf("%d %d", &i, &j);    for(row= 0; row < i; row++){       for(col = 0;col < j;col++){          scanf("%d", &A[row][col]);       }    }    for(row = 0; row < i; row++){       for(col = 0;col < j;col++){          scanf("%d", &B[row][col]);       }    }    for(row = 0; row < i; row++){       for(col = 0;col < j;col++){          add[row][col] = A[row][col] + B[row][col];          sub[row][col] = A[row][col] - B[row][col];          mul[row][col] = A[row][col] * B[row][col];          div[row][col] = A[row][col] / B[row][col];          mod[row][col] = A[row][col] % B[row][col];       }    }    for(row = 0; row < i; row++){       for(col = 0; col < j; col++){          printf("%d t ", sub[row][col]);          printf("%d t ", mul[row][col]);          printf("%.2f t ", div[row][col]);          printf("%d t ", mod[row][col]);       }    }    return 0; } Output

When the above program is executed, it produces the following result −

enter no: of rows and columns: 3 4 enter elements of 1st array: 1 2 4 5 6 7 3 8 3 2 1 8 enter elements of 2nd array: 1 2 1 2 1 3 4 2 1 2 1 1 Add   Sub  Mul  Div  Mod ------------------------------- 2     0    1   1.00  0 4     0    4   1.00  0 5     3    4   4.00  0 7     3    10  2.00  1 7     5    6   6.00  0 10    4    21  2.00   1 7    -1    12  0.00   3 10    6    16   4.00  0 4    2     3    3.00  0 4    0    4    1.00   0 2    0    1    1.00   0 9    7    8    8.00    0

You're reading How To Perform Arithmetic Operations On Two

## How To Change Your Two

Having the two-step verification system set up on your Telegram account is a great way to keep it safe. It lowers the probabilities of you losing your account. But, it does require that you introduce a pin you should have memorized. But, sometimes you forget what it is, or you want to change it to one that’s easier to remember.

Please keep reading to see how you can change your two-step verification pin when you know what your current pin is and when you’ve forgotten it. So, there’s no need to panic if you forgot your pin since it’s possible to recover it.

How to Create a New Two-Step Verification Pin on Telegram

To create your new pin, tap on the three-lined menu at the top left of your display. Once you’re in Setting, swipe down to the Settings section and tap on the Privacy and Security option.

On the next page, towards the bottom, you should see the Two-Step Verification option. Type the current password, and you’ll have access to three options: Change Password, Turn Password Off and Change Recovery Email.

Tap on the change password option, and you’ll be asked to enter the new password twice. Once you complete those steps, you’ll see a cute celebration emoji letting you know that you’re done. That’s all you have to do to change your two-step verification password.

If you disable the password, you turn off the two-step verification altogether. The next time you want to enable it again, you’ll have to start over.

You’ll be asked to enter info such as your new password (twice to confirm), Recovery Email, and enter the code sent to your recovery email. If you happen to forget your password, here’s where your recovery email comes in handy. Telegram will send you a recovery code to the email you added when you first added the two-step verification.

Enter that code where Telegram indicates, and you’re good to go. If what you need to do is change your Telegram passcode lock, that’s a whole different story.

How to Create and Change a Passcode Lock on Telegram

As long as we’re on the topic of Telegram security, adding a passcode lock to your Telegram account is a good idea. That way, you’ll prevent anyone you haven’t given permission to from seeing your conversations. To protect your Telegram account with a passcode, tap on the three-lined menu option at the top left.

Once you’re in settings, tap on Privacy and Security. Under the Security section, tap on the Passcode Lock option.

If it’s your first time setting it up, you’ll be asked to introduce a pin you’ll use to access Telegram. If what you want to do is change it, in that case, you’ll need to tap on the Change Passcode option.

You’ll be asked to enter your new pin twice, and you also get a celebrating emoji at the end. As long as you’re in the Passcode lock settings, there are other changes you can make. For example, if you ever want to take a break from having to enter a passcode, you can disable it, or you can unlock it with your fingerprint.

You can also decide how much time needs to pass before auto-lock kicks in and if you want to show the app’s content in Task Switcher.

Conclusion

The more security you can add to any account, the better. You never know when that security setting might actually save it. By enabling two-step verification and locking your Telegram account with a passcode, you’ll have one less thing to worry about.

## How To Set Up Two

Two-factor authentication may not be as sexy as the latest Android phone, but the technology is capturing news headlines, and deservedly so. Last week, Microsoft began rolling out this security tool for its some 700 million Microsoft Account users. Tuesday Wired reported Twitter is working on two-factor authentication as well.

It’s a security feature that could have stopped hackers at the gate before they seized control of the Associated Press Twitter account, and it’s something you should be using to protect your own online accounts, wherever it’s available.

So how does two-factor authentication work? In a nutshell, it requires not one but two pieces of privileged information before granting access to an online account.

If two-factor authentication sounds like kind of a pain, well, it is. Turning on this feature is a really easy way to make life harder for yourself, as you’ll need to spend extra time to prove your identity every time you log into a protected account from a new piece of hardware. Nonetheless, this level of authentication makes it much harder for hackers to seize control of your accounts.

Do you have a Google account and a smartphone? Then you should have two-factor authentication enabled.

Getting started also requires a little legwork on your part. Most major sites and services offer two-factor authentication as an optional security feature, so you need to log into your various accounts and dig around in the security settings to find it.

Google and Facebook have offered two-factor authentication as an optional security measure since 2011. Dropbox started offering it last year, and Apple iCloud got two-factor authentication in March. Microsoft is late to the party but now has it, and Twitter’s version of the technology can’t come soon enough.

For the sake of brevity I’m going to run down the two-factor set-up process for the Big Three social networks as well as my favorite remote storage services. But you should duplicate this process across every site and service you use that offers two-factor authentication. And if it seems like a lot of different systems to manage, don’t worry—there’s an app for that.

Google offers a plethora of services across multiple devices, so it’s apropos that it offers a similar plethora of options for configuring two-factor login authentication.

You can also generate one-time use codes that you can write down and save for times when you want to log into Google in the absence of cell service. Generate five or ten of these codes, and keep them in your wallet for emergencies. Also consider downloading the Google Authenticator app for iOS and Android if you don’t want Google sending you text messages every time you check your mail from a new computer.

It’s simple to use, and can generate codes for any authentication service that employs the TOTP (Time-based One-Time Password) algorithm, including Facebook and Dropbox. I recommend setting it up to do so if you’re going to be enabling two-factor authentication on other services, but be aware that this will make it very difficult for you to log into those services without your phone. If your phone is lost or stolen—or if you just accidentally delete the authenticator app—it’s possible to download a fresh version and re-authenticate across every service you use, but it’s a real pain.

What we call two-factor authentication Facebook calls Login Approvals, and it works great.

To get that code you’ll need to either download a mobile authenticator app that generates codes every time you log in, or give Facebook your cellphone number so it can send you authentication codes via SMS. I recommend going the authenticator app route. It’s simple to use, and you don’t have to wait for Facebook’s servers to text you your code. Plus, you can also add a cellphone number as an additional backup if the app fails to work.

In its mobile app, Facebook built in a neat Code Generator feature that generates TOTP codes for your account, but you can use any old TOTP authenticator app if you’re willing to subvert Facebook’s setup process. If you’re using Google’s mobile authenticator app to manage two-factor authentication across multiple services, for example—which is a great idea—you can set it up to provide authenticator codes for your Facebook account too.

Microsoft is finally catching up

Scan this blob of code with your authenticator app and you’ll be able to generate authentication codes with your phone no matter where you are.

For simplicity’s sake, I recommend using the aforementioned Google Authenticator app on iOS and Android. Use the app to scan the barcode that Microsoft provides you during the two-factor authentication process and it will generate codes for your Microsoft account as well.

And you don’t need to stop there—I expect Twitter will have its two-factor authentication system in place before summer rolls around, and there are plenty of other sites and services that already offer similar security systems. Dropbox, LastPass, Box, and even Amazon Web Services support two-factor, as do many banking services. Locking these accounts up with two-factor authentication adds another layer of security to your digital life, one that can be unlocked only with the smartphone in your pocket.

## How To Compare Two Dates With Javascript?

In this tutorial, we will learn to compare two dates with JavaScript. The date is also one of the data types in JavaScript, and most developer works with it while developing applications.

Let’s understand the need to compare the date with a real-life example. Most of you are using the internet data, and the company sends a message like “2 days left for your data pack validity.” Also, users can see the same notification in the application of network provides. This all happens due to the date comparison.

Here, we have two various approaches to make a comparison between the two dates.

Comparing the Total Millisecond of Two Dates

When we create the new date using an object of the Date() class. We use the getTime() method to get time in milliseconds. The getTime() method returns the total number of milliseconds from the 1st Jan 1970, when the Unix epoch started. We can compare the total number of milliseconds and decide whether the date is the same.

Syntax

Users can follow the syntax below to compare the total milliseconds of two dates.

let date1 = new Date(); let date2 = new Date(2012, 11, 21); if ( date1.getTime() < date2.getTime() ) { } else { } Example

In the example below, we have implemented the above approach. We have created the two new objects of the Date() class and compared the total number of milliseconds using the if-else statement. Users can see the result of the comparison between various dates in the output.

let

output

=

document

.

getElementById

(

“output”

)

;

function

compareDates

(

date1

,

date2

)

{

if

(

date1

.

getTime

(

)

<

date2

.

getTime

(

)

)

{

}

else

{

}

}

let

date1

=

new

Date

(

)

;

let

date2

=

new

Date

(

2012

,

11

,

21

)

;

compareDates

(

date1

,

date2

)

;

date2

=

new

Date

(

)

;

compareDates

(

date1

,

date2

)

;

Compare two dates using chúng tôi diff() method

JavaScript contains various libraries; one of them is chúng tôi which is used to manage the date and time. chúng tôi has a diff() method, which gives the difference between two dates in years, months, days, hours, minutes, seconds, milliseconds, etc. We can use the second unit in our case to find the difference between the two dates.

Before using the chúng tôi methods, make sure to include chúng tôi or add CDN to the tag of the HTML code.

Syntax

You can follow the below syntax to use the diff() method of Moment.js.

let date1 = moment(); let date2 = moment("2024-11-21"); let difference = date1.diff( date2, "seconds" ); Parameters

date1 and date2 is the two date for which we need to make comparisons.

seconds − It is a unit of time in which we need the difference. Users can also use the minutes, hours, etc.

Example

In the example below, we have created the two date objects using the moment(). We have applied the diff() method to two objects to compare them and render the message in the output according to whether the difference is the same, positive, or negative.

integrity

=

“sha512-vFABRuf5oGUaztndx4KoAEUVQnOvAIFs59y4tO0DILGWhQiFnFHiR+ZJfxLDyJlXgeut9Z07Svuvm+1Jv89w5g==”

let

output

=

document

.

getElementById

(

“output”

)

;

function

compareDates

(

date1

,

date2

)

{

if

(

date1

.

diff

(

date2

,

“seconds”

)

<

0

)

{

}

else

{

}

}

let

date1

=

moment

(

)

;

let

date2

=

moment

(

“2024-11-21”

)

;

compareDates

(

date1

,

date2

)

;

date2

=

moment

(

)

;

compareDates

(

date1

,

date2

)

;

We have used the default Date() class to compare the dates in the first section of the tutorial. Also, we have used the chúng tôi library method to make a comparison. The moment makes it easy for the developer to play with the dates.

## How To Easily Compare The Specifications Of Two Phones

Google Pixel or Samsung Galaxy S7? Motorola Moto G 3rd Generation or iPhone 6? For a newcomer to the smartphone world or an expert that can’t remember every detail of every phone on the market, finding the right smartphone can be hard. Even worse, people will be attracted to different specifications of a phone. While some will favour huge processors and masses of RAM, others will want a smaller, sleeker phone to easily put into pockets and bags. Finding the details that correspond to what you want and making the correct purchase can be daunting.

Of course, there’s always the solution of visiting a manufacturer or distributor’s website and collating information about each phone you’re interested in. Given how big an industry smartphones and tablets are these days, however, you’ll find there are a lot of websites out there willing to trawl through all the boring details and pluck out the important parts. All you have to do is enter the phone names, and these websites will do all the hard work for you. Here are a few great examples we’ve found.

GSM Arena

GSM Arena is a very useful website when it comes to deciding which smartphone to buy. As well as comparing phone specifications for you, GSM Arena features articles that take new phones and pits them against one another over certain desirable attributes, such as camera quality. It’s also a good place to keep on top of new phone releases and check their specifications.

Phone Arena

Phone Arena has a similar name, but it’s good for its own merits. It, too, features news on the latest phones while also detailing important updates for very popular apps. You can look up the specifications of a particular phone where you can see if the phone has a fingerprint locking device, if it supports dual sim, or even if it’s deemed “lightweight” by Phone Arena.

If the size of the phone is a big factor for you, you can also use the size comparison tool. First, calibrate the website by selecting either a phone you already have or the “credit card” option. You then match your real-life item to the picture the website shows you. Once done, the website knows how to scale pictures to your monitor’s resolution. This means it can show you exactly how big each phone will be in real life. Very useful!

Sizing Up The Competition

With phones constantly being released, it can be very hard to keep on top of every phone’s specifications. Thankfully, these two websites will help you compare the phones you’re interested in so you can better find the phone that’s right for you.

Simon Batt

Simon Batt is a Computer Science graduate with a passion for cybersecurity.

Our latest tutorials delivered straight to your inbox

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

## Defining Eloquent Models With Crud Operations

What are the Laravel Models?

The Model corresponds to the letter ‘M’ in the MVC framework. The motive of Models in any Model view controller framework web application is to manage business logic. A Model is nothing but a class in the Laravel framework. This class is responsible to interact with underlying database tables. Laravel with Eloquent ORM is capable of handling the database more efficiently. ORM stands for ‘Object Relational Mapper’ and it is responsible for your swift interaction with the database. These Models provide you with an easy way to update, insert or retrieve data from the tables.

Start Your Free Software Development Course

Web development, programming languages, Software testing & others

Firstly, we need to make a connection to the database using ‘config/database.php’. Now we will delve into Laravel Model creation as follows.

Defining Eloquent Models

Let’s see how to create a model. We will tell you the simplest way of model instance creation using Artisan command. You simply need to write make:model command whose syntax goes like this:

Let’s take a simple example of the Model as follows:

<?php namespace App; use IlluminateDatabaseEloquentModel; class Teacher extends Model { }

This Model will be used by us to store as well as retrieve information from the Teachers database.

Here, it may be noted that Eloquent automatically assumes that the records are stored in the ‘Teachers’ table as evidently the plural form of class is taken as the table name until and unless you specify it explicitly.

If you want to specify it explicitly, it can be done as follows:

<?php namespace App; use IlluminateDatabaseEloquentModel; class Teacher extends Model { /** * table to store teachers records. */ protected \$table = 'my_teachers'; }

If you wish to generate model and database migration at the same time, this can be done by using either of –m or – migration option.

php artisan make:model Teacher --m php artisan make:model Teacher -migration

By convention, column ‘id’ is the primary key of every table. Similar to specifying the table name explicitly, we can also specify the primary key as follows:

<?php namespace App; use IlluminateDatabaseEloquentModel; class Teacher extends Model { /** * Primary key. */ protected \$primaryKey = 'teacher_id'; }

By default, the primary key is always assumed as an ‘int’ value which is always incrementing. Incrementing and type property can also be customized by setting the ‘incrementing’ property and ‘keyType’ property respectively as follows:

<?php class Teacher extends Model { /* * Defines incrementing or non-incrementing. * * @var bool */ public \$incrementing = false; protected \$keyType = 'string'; }

Now let’s see how we can perform various operations on our database as ahead.

Eloquent and CRUD Operations

Eloquent ORM constitutes of CRUD operations which makes it simpler for users to interact with various databases. Various database operations and mapping of tables to object models are performed with it. All the interactions with the database which are required to perform CRUD operations are handled by it.

Let’s understand all of these operations one by one as ahead.

1. Creation of Records

Steps to create a new record in your database:

Model instance creation

Setting attributes

Call ‘save’ function

<?php namespace AppHttpControllers; use AppTeacher; use IlluminateHttpRequest; use AppHttpControllersController; class TeacherController extends Controller { /** * teacher instance creation **/ public function storage(Request \$request) { \$teacher = new Teacher; } } 2. Retrieval of Records

As discussed earlier, finding or retrieving information from the database is fairly easy with the help of Eloquent ORM. You can simply query your database and get the needed records.

Various methods can be used to retrieve data some of which are as below:

get()

If you want a number of records, then get() method can be used. It will get you an array of results as an output.

This code will get you the array of teachers with a rank of less than 4.

first()

Unlike the get() method, this method will produce only one result as an output.

Example:

This code will find a specific teacher depending on the attributes provided.

all()

This method will yield all the records of a table.

Example:

\$teacher = Teachers::all();

This code will yield all the teachers records.

find()

find() method returns all the matching records depending upon the parameter passed in query/code.

Example:

\$teacher = Teachers::find(2);

This code will yield a specific teacher’s record by id.

3. Updation of Records

Find and retrieve the record

Set attributes

Call save() method

Updating records is as easy as other operations discussed above. You just have to retrieve the record to be updated, set the desired attributes and call save() method.

Let’s understand this with an example as follows:

This code will change the teacher rank level of Carol Duff to 4. Here first we have found and retrieved the particular teacher’s record which was needed to be updated. Secondly, we have set the desired attributes and then save() method is called.

4. Deletion of Records

Steps to delete a record:

Retrieve record to be deleted

Call delete() method

OR

Call destroy() method

Deleting is as simple as other database operations. Firstly you have to find the record to be deleted, pull out the record and then call delete() method.

Example:

\$teacher = Teachers::find(2);

Or you can simply call destroy() method as shown below:

To delete one record:

Teachers::destroy(2);

To delete multiple records:

Teachers::destroy(2, 3, 4);

Here it is to be noted that you can pass any column of a database table in delete() method whereas only the primary key column can be passed in destroy() method.

Conclusion – Laravel Models

Laravel, when it includes Eloquent ORM, becomes a powerful and robust framework that provides you with a competitive edge. It can be used very efficiently in order to manage and handle database and its interactions for your web application development. It lets you interact with different tables in your database using simple queries.

Recommended Articles

This is a guide to Laravel Models. Here we discuss the eloquent models along with eloquent and crud operations with examples. You may also look at the following articles to learn more –

Update the detailed information about How To Perform Arithmetic Operations On Two on the Hatcungthantuong.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!