How to use prefix increment decrement in c language

program to use prefix increment decrement in c language


#include<stdio.h>
int main()
{
    int a=6;
    printf("a=%d\t",a);
    printf("a=%d\t",++a);
    printf("a=%d\t",a);
    printf("a=%d\t",--a);
    printf("a=%d\n",a);
    return 0;
}

output


a=6     a=7     a=7     a=6     a=6

Steps Description

  1. Declare integer variable a=6
  2. Initialize in integer variable a=6
  3. printf inbuild function to display value of variable a in decimal placeholder %d a = 6 for
    formatting tab separator \t is used
  4. printf inbuild function to display prefix increment values variable a in decimal placeholder
    %d a = 7 for formatting tab separator \t is used
  5. printf inbuild function to display value of variable a in decimal placeholder %d a = 7 for
    formatting tab separator \t is used
  6. printf inbuild function to display prefix decrement values variable a in decimal placeholder %d a = 6 for formatting tab separator \t is used
  7. printf inbuild function to display value of variable a in decimal placeholder %d a = 6 for
    formatting tab separator \t is used

Ternary Operator in JavaScript Language

Program to use Ternary Operator JavaScript Language


let a = 10;
let b = 20;
let max;
max = a > b ? a : b;
console.log("Max Number is =", max);

Output


Max Number is = 20

Steps Description

  1. Declare three variables a, b and max
  2. Initialize three variables with value of 10, 20 respectively a=10, b=20 and max
  3. Ternary operator works like if else
  4. condition is checked first value is true expression1 displayed condition is false expression2 displayed
  5. console.log inbuild function to display max variable number

How to find Even or Odd Numbers in JavaScript

Program to use Even and Odd Numbers in JavaScript Language


let a = 13;
if (a % 2 == 0) {
    console.log("Number is Even");
} else {
    console.log("Number is Odd");
}

Output


Number is Odd

Steps Description

  1. Declare variable a
  2. Initialize variable with value of 13 a=13
  3. if statement a Modulus 2 equal to 0 is even number
  4. else statement is odd number
  5. console.log inbuild function to display a variable

How to find largest of three numbers in JavaScript

Find largest of three numbers in JavaScript program


let a = 10;
let b = 20;
let c = 5;
if (a > b && a > c) {
    console.log("a is Big ", a);
}

if (b > a && b > c) {
    console.log("b is Big ", b);
}

if (c > a && c > b) {
    console.log("c is Big ", c);
}

Output


b is Big  20

Steps Description

  1. Declare three variables a, b and c
  2. Initialize three variables with value of 10, 20 and 5 respectively a=5, b=10 and c=5
  3. if statement a greater b && operator a greater c check the condition a is big
  4. if statement b greater a && operator b greater c check the condition b is big
  5. if statement c greater a && operator c greater b check the condition c is big
  6. console.log inbuild function to display big variable number

Logical Operators in JavaScript Language

Program to use Logical AND ( && ) Operators JavaScript Language


let a = 5;
let b = 10;
console.log(true && false);
console.log(true && true);
console.log(false && false);
console.log((a < b) && (a > b));

Output


false
true
false
false

Steps Description

  1. Declare two variables a and b
  2. Initialize both variables with value of 5 and 10 respectively a=5, b=10
  3. The function of the Logical AND && operator is to check two values, if both the values are true then it returns true otherwise it returns false.
  4. The values of a and b variables are displayed with the help of console.log inbuilt function

Program to use Logical OR ( || ) Operators JavaScript Language


let c = 10;
let d = 20;
console.log(true || false);
console.log(true || true);
console.log(false || false);
console.log((c < d) || (c > d));

Output


true
true
false
true

Steps Description

  1. Declare two variables c and d
  2. Initialize both variables with value of 10 and 20 respectively c=10, d=20
  3. The function of the logical OR || operator is to check two values, if either value is true, it will return true otherwise it will return false.
  4. The values of c and d variables are displayed with the help of console.log inbuilt function

Program to use Logical NOT ( ! ) Operators JavaScript Language


let e = 50;
let f = 100;
console.log(!(e == f));
console.log(!(e < f));
console.log(!true > true);
console.log(!false > false);
console.log(!true > false);

Output


true
false
false
true
false

Steps Description

  1. Declare two variables e and f
  2. Initialize both variables with value of 50 and 100 respectively e=50, f=100
  3. The function of Logical NOT ! operator is to check two values if the value is true then it will be false and if it is false then the value will be true.
  4. The values of e and f variables are displayed with the help of console.log inbuilt function

How to use arithmetic operators in c language

program to use arithmetic operators in c language


#include<stdio.h>
int main()
{
    int a=12,b=6,res;
    res=a + b;
    printf("sum : %d\n", res);
    res=a-b;
    printf("difference : %d\n", res);
    res=a*b;
    printf("product : %d\n", res);
    res=a/b;
    printf("quotient : %d\n", res);
    res=a%b;
    printf("remainder : %d\n", res);
    return 0;
}

output


sum : 18
difference : 6
product : 72
quotient : 2
remainder : 0

Steps Description

  1. Declare integer three variable a,b and res
  2. Initialize in integer variable a=12, b=6
  3. Assign res variable with sum of variable a and b
  4. printf inbuild function display res variable with decimal placeholder %d
  5. Assign res variable with difference of variable a and b
  6. printf inbuild function display res variable with decimal placeholder %d
  7. Assign res variable with product of variable a and b
  8. printf inbuild function display res variable with decimal placeholder %d
  9. Assign res variable with quotient of variable a and b
  10. printf inbuild function display res variable with decimal placeholder %d
  11. Assign res variable with remainder of variable a and b
  12. printf inbuild function display res variable with decimal placeholder %d

Comparison Operators in JavaScript Language

Program to use Equal ( == ) Comparison Operators JavaScript Language


let a = 10;
let b = 10;
console.log(a == b);

Output


true

Steps Description

  1. Declare two variables a and b
  2. Initialize both variables with value of 10 and 10 respectively a=10, b=10
  3. Equal == comparison operator checks the condition that both a and b have the same value
  4. The values of a and b variables are displayed with the help of console.log inbuilt function

Program to use strict equality ( === ) Comparison Operators JavaScript Language


let c = 10;
let d = 10;
console.log(c === d);

Output


true

Steps Description

  1. Declare two variables c and d
  2. Initialize both variables with value of 10 and 10 respectively c=10, d=10
  3. Equality === comparison operator checks the condition that both c and d have the same value and data type
  4. The values of c and d variables are displayed with the help of console.log inbuilt function

Program to use not equal ( != ) Comparison Operators JavaScript Language


let e = 10;
let f = '5';
console.log(e != f);

Output


true

Steps Description

  1. Declare two variables e and f
  2. Initialize both variables with value of 10 and '5' respectively e=10, f='5'
  3. Not equal != comparison operator checks for the condition that both e and f values are not equal
  4. The values of e and f variables are displayed with the help of console.log inbuilt function

Program to use Strict inequality ( !== ) Comparison Operators JavaScript Language


let g = '5';
let h = 5;
console.log(g !== h);

Output


true

Steps Description

  1. Declare two variables g and h
  2. Initialize both variables with value of '5' and 5 respectively g='5', h=5
  3. strict inequality !== comparison operator conditions that both the value and the data type of g and h are not the same
  4. The values of g and h variables are displayed with the help of console.log inbuilt function

Program to use Greater than ( > ) Comparison Operators JavaScript Language


let i = 10;
let j = 5;
console.log(i > j);

Output


true

Steps Description

  1. Declare two variables i and j
  2. Initialize both variables with value of 10 and 5 respectively i=10, j=5
  3. Greater than > comparison operator checks whether the value of i is greater than that of j
  4. The values of i and j variables are displayed with the help of console.log inbuilt function

Program to use Less than ( < ) Comparison Operators JavaScript Language


let k = 10;
let l = 5;
console.log(k < l);

Output


false

Steps Description

  1. Declare two variables k and l
  2. Initialize both variables with value of 10 and 5 respectively k=10, l=5
  3. Less-than < comparison operator checks whether the value of k is less than l
  4. The values of k and l variables are displayed with the help of console.log inbuilt function

Program to use Greater than or equal to ( >= ) Comparison Operators JavaScript Language


let m = 10;
let n = 10;
console.log(m >= n);
console.log(5 >= 10);

Output


true
false

Steps Description

  1. Declare two variables m and n
  2. Initialize both variables with value of 10 and 10 respectively m=10, n=10
  3. Greater than-or-equal >= comparison operator checks the condition that the value of m is greater than and equal to n
  4. The values of m and n variables are displayed with the help of console.log inbuilt function

Program to use Less than or equal to ( <= ) Comparison Operators JavaScript Language


let s = 10;
let t = 5;
console.log(s <= t);

Output


false

Steps Description

  1. Declare two variables s and t
  2. Initialize both variables with value of 10 and 5 respectively s=10, t=5
  3. Less than or equal to <= comparison operators check the condition that the value of s is less than and equal to t
  4. The values of s and t variables are displayed with the help of console.log inbuilt function