Difference Between Sum of Squares and Square of Sum of First N Natural Numbers

Mahesh Parahar
Updated on 16-May-2020 14:45:24

976 Views

Problem StatementWith a given number n, write a program to find the difference between sum of the squares of and square of sum first n natural numbers.Examplen = 3 Squares of first three numbers = 3x3 + 2x2 + 1x1 = 9 + 4 + 1 = 14 Squares of sum of first three numbers = (3 + 2 + 1)x(3 + 2 + 1) = 6x6 = 36 Difference = 36 - 14 = 22Example Live DemoFollowing is the program in Java to find the required difference.public class JavaTester {    public static int difference(int n){   ... Read More

Difference Between Strong Entity and Weak Entity

Mahesh Parahar
Updated on 16-May-2020 14:36:04

15K+ Views

Strong EntityStrong Entity is independent to any other entity in the schema. A strong entity always have a primary key. In ER diagram, a strong entity is represented by rectangle. Relationship between two strong entities is represented by a diamond. A set of strong entities is known as strong entity set.Weak EntityWeak entity is dependent on strong entity and cannot exists without a corresponding strong. It has a foreign key which relates it to a strong entity. A weak entity is represented by double rectangle. Relationship between a strong entity and a weak entity is represented by double diamond. The ... Read More

Difference Between out and ref Keyword in C#

Mahesh Parahar
Updated on 16-May-2020 14:16:00

19K+ Views

out keywordout keyword is used to pass arguments to method as a reference type and is primary used when a method has to return multiple values. ref keyword is also used to pass arguments to method as reference type and is used when existing variable is to be modified in a method. Following is the valid usage of ref and out keywords in C#.Example Live Demousing System.IO; using System; public class Program {    public static void update(out int a){       a = 10;    }    public static void change(ref int d){       d = 11; ... Read More

Difference Between readonly and const Keyword in C#

Mahesh Parahar
Updated on 16-May-2020 14:14:55

12K+ Views

readonly keywordreadonly keyword is used to define a variable which can be assigned once after declaration either during declaration or in constructor. const keyword is used to define a constant to be used in the program. Following is the valid usage of a readonly and const keywords in C#.Example Live Demousing System.IO; using System; public class Program {    public const int VALUE = 10;    public readonly int value1;    Program(int value){       value1 = value;    }    public static void Main() {       Console.WriteLine(VALUE);       Program p1 = new Program(11); ... Read More

Difference Between Relational Algebra and Relational Calculus

Mahesh Parahar
Updated on 16-May-2020 14:13:49

20K+ Views

Relational AlgebraRelational algebra is a procedural query language, which takes instances of relations as input and yields instances of relations as output. It uses operators to perform queries. An operator can be either unary or binary. They accept relations as their input and yield relations as their output. Relational algebra is performed recursively on a relation and intermediate results are also considered relations.The fundamental operations of relational algebra are as follows -SelectProjectUnionSet differentCartesian productRenameRelational CalculusIn contrast to Relational Algebra, Relational Calculus is a non-procedural query language, that is, it tells what to do but never explains how to do it.Relational ... Read More

Differences Between Data Paths

Mahesh Parahar
Updated on 16-May-2020 11:35:42

1K+ Views

Data PathsCPU has two sections, data section and control section. Data section is also called data paths. Registers, ALU and interconnection bus collectively constitutes a data path. Data paths are of three types:Single CycleMultiple CyclePipelineFollowing are some of the important differences between Single Cycle, Multiple Cycle and Pipeline data paths.Sr. No.KeySingle CycleMultiple CyclePipeline1CycleSingle Cycle has one CPI (Clock Cycle Per Instruction).Multiple Cycle has variable CPIs.Pipeline has fixed no. of CPIs.2Instruction divisionIn single cycle, instruction is not divided per CPI.In multiple cycle, an instruction can be divided in arbitrary steps.In pipline, an instruction is divided one step per pipeline stage.3Instruction divisionIn ... Read More

Difference Between Traits and Abstract Classes in Scala

Mahesh Parahar
Updated on 16-May-2020 11:33:34

1K+ Views

TraitsTraits are similar to interfaces in Java and are created using trait keyword.Abstract ClassAbstract Class is similar to abstract classes in Java and are created using abstract keyword.Example Live DemoFollowing is the program in Scala to show the usage of Traits and Abstract Classes.trait SampleTrait {    // Abstract method    def test    // Non-Abstract method    def tutorials() {       println("Traits tutorials")    } } abstract class SampleAbstractClass {    // Abstract method    def test    // Non-abstract meythod    def tutorials() {       println("Abstract Class tutorial")    } } ... Read More

Difference Between Largest and Smallest Primes in an Array in Java

Mahesh Parahar
Updated on 16-May-2020 11:29:51

957 Views

Problem StatementWith a given array of integers where all elements are less than 1000000. Find the difference between the largest and the smallest primes in an array.ExampleArray: [ 1, 2, 3, 4, 5 ] Largest Prime Number = 5 Smallest Prime Number = 2 Difference = 5 - 3 = 2.SolutionUse Sieve of Eratosthenes approach, which is an efficient way to find out all prime numbers smaller than a given number. Then we will figure out the largest and smallest prime number to get the required difference.Example Live DemoFollowing is the program in Java to find the required output.public ... Read More

Secure Password Encryption with PowerShell

Chirag Nagrekar
Updated on 16-May-2020 10:59:37

459 Views

Many times we need to use passwords in PowerShell and need to pass it to the credential parameter and a password should be always a secure string, not a plain text. There are few methods to encrypt the password as mentioned below.a) Get-Credential FormatWe have one method where we can store the username and password is through cmdlet Get-Credential. It will provide a GUI prompt. You can store this password into a variable and use it later in the command.$cred = Get-CredentialCredentials are stored into $cred variable. Here is the value of the variable. output below.PS C:\WINDOWS\system32> $cred UserName   ... Read More

Insert String at the Beginning of All Items in a List in Python

Mohd Mohtashim
Updated on 16-May-2020 10:50:38

314 Views

In this post we need to enter the string at the beginning of all items in a list. For ex: We're given string = "Tutorials_Point" and List contains multiple element such as "1", "2" etc. So in this we need to add Tutorials_Point in front of "1", "2" and so on.ExampleAproach 1 Live Demosample_list = [1, 2, 3] print(['Tutorials_Point{0}'.format(i) for i in sample_list])Output//['Tutorials_Point1', 'Tutorials_Point2', 'Tutorials_Point3']Approach 2 Live Demosample_list = [1, 2, 3] sample_str = 'Tutorials_Point' sample_str += '{0}' sample_list = ((map(sample_str.format, sample_list))) print(sample_list)Output//['Tutorials_Point1', 'Tutorials_Point2', 'Tutorials_Point3']Read More

Advertisements