Skip to content

1. Basics

Madhav Anand edited this page Nov 3, 2021 · 2 revisions

Introduction

The best way to get started is by "Faith Based Learning"
Getting started with a language is learning Input-Output, Variable-Datatype, Condition-Loop

PrintZ

  1. Given two tools, println & print
  2. Try to print in single line.

Variables

You should name a variable using the same care with which you name a first-born child.

  1. A variable is a named location in memory.(Don't forget Diagram)
  2. Printing & appending values.
  3. Arithmetic Operations * + /
  4. Priority is Precedence and Same Priority is Associativity

Conditionals

  1. Controls the flow of statements execution.
  2. Program. If Even or Odd.

Grading System

  1. Understand the flow of statements execution.

Loops

  1. To repeat some set of statements.
  2. Three elements Initialization, Condition, Increment

Increment Operators

  1. Visualize the box.

Input

  1. java.util.Scanner
  2. Only String nextLine(), Only Int nextInt()
  3. Together Integer.parseInt(scn.nextLine()), int-enter-string
  4. Without this int-space-string

Is a Number Prime

  1. Go with boolean function approach and ternary for result.
  2. Optimize for time complexity - t x n = 10^4 x 10^9 = 10^13 but computers are generally 3 GHz - 3 x 10^9
  3. At the end, optimization is t x (n)^1/2 = 10^4 x 10^5 = 10^9

Primes till N

  1. Similar to above.

Fibonacci Till N

  1. See another approach along with visualization of moving(a, b) that down.

Count the digits

  1. Divide till 0 & count it.

Print Digits

  1. Default is reverse printing.
Clone this wiki locally