When you start programming
Do learn :
1) : Constant
2): Keywords
3): Variables
1): Constant :
Not changing or varying; uniform; regular; invariable: All conditions during the three experiments were constant. continuing without pause or letup; unceasing: constant noise. regularly recurrent; continual; persistent: He found it impossible to work with constant interruption.
Example of constant in Java
import java.util.Scanner;
public class ConstantExample1.
{
//declaring constant.
private static final double PRICE=234.90;
public static void main(String[] args)
{
int unit;
2): Keywords :
In the Java programming language, a keyword is any one of 52 reserved words that have a predefined meaning in the language; because of this, programmers cannot use keywords as names for variables, methods, classes, or as any other identifier.
Examples of keywords are the primitive types, int and boolean; the control flow statements for and if; access modifiers such as public, and special words which mark the declaration and definition of Java classes, packages, and interfaces: class, package, interface.
3): Variables
A variable is a name given to a memory location. ... The value stored in a variable can be changed during program execution. A variable is only a name given to a memory location, all the operations done on the variable effects that memory location. In Java, all the variables must be declared before use.
String - stores text, such as "Hello". ...
int - stores integers (whole numbers), without decimals, such as 123 or -123.
float - stores floating-point numbers, with decimals, such as 19.99 or -19.99.
char - stores single characters, such as 'a' or 'B'.
Extensive parts of programming languages are followings:
Programming Environment
Data Types
- Variables
Variables are the very essential part of a program.
An example of C program:
#include<stdio.h>
void main()
{
int i;
// here 'i' itself is a variable that can be declared any number and it can be changed with the program
for(i=10; I<=10 i++){
printf("%d", i);
}
}
- Keywords
Keywords are the very essential part of a program.
There are 32 keywords in C language like : int, char, float, void,
An example of C program:
#include<stdio.h>
void main()
{
int i;
// here 'int' itself is a keyword in the program that declares the type of constant that cannot be changed
for(i=10; I<=10 i++){
printf("%d", i);
}
}
- Logical and Arithmetical Operators
Arithmetic Operators: These are the operators used to perform arithmetic/mathematical operations on operands. Examples: (+, -, *, /, %,++,–). The arithmetic operator is of two types: Unary Operators: Operators that operate or work with a single operand are unary operators.
- If else conditions
An if statement can be seen in the C program
- #include<stdio.h>
- int main(){
- int number=0;
- printf("enter a number:");
- scanf("%d",&number);
- if(number==10){
- printf("number is equals to 10");
- }
- Loops
Two major types of loops are FOR LOOPS and WHILE LOOPS. A For loop will run a preset number of times whereas a While loop will run a variable number of times. For loops are used when you know how many times you want to run an algorithm before stopping.
- Numbers, Characters, and Arrays
1- In C Language:
The example:
2- In Java Language:
A char array can be initialized by conferring to it a default size. char [] JavaCharArray = new char [ 4 ]; This assigns to it an instance with size 4
Example
- Functions
Type of Function
- Input and Output Operations
Examples
0 Comments