How to use interchange comma operator in c language

program to use interchange comma operator in c language


 #include<stdio.h>
int main()
{
    int c=5,d=6,temp;
    printf("c=%d, d=%d\n",c,d);
    temp=c,c=d,d=temp;
    printf("c=%d, d=%d\n",c,d);
    return 0;
}

output


c=5, d=6
c=6, d=5

Steps Description

  1. Declare integer three variable c , d and temp
  2. initialize in integer variable c = 5 , d =6
  3. printf inbuild function display variable c and d with decimal placeholder %d
  4. Assign temp variable with variable c value
  5. Assign variable d value with temp variable
  6. printf inbuild function display variable c and variable d with decimal placeholder %d

How to use comma operators in c language

program to use comma operators in c language


#include<stdio.h>
int main()
{
    int e,f,g,sum;
    sum = (e=6,f=4,g=12,a+b+c);
    printf("sum=%d\n",sum);
    return 0;
}

output


sum=24

Steps Description

  1. Declare integer four variables e , f and g and sum
  2. initialize in integer variables e , f and g
  3. Assign sum variable with sum of variables e and f and g
  4. printf inbuild function display sum variable with decimal placeholder %d

How to use Arithmetic operators in C Language

  • Program to use Arithmetic operators in C Language

    
    #include <stdio.h>
    int main()
    {
        int a = 17, b = 4;
        printf("sum=%d\n", a + b);
        printf("defference=%d\n", a - b);
        printf("proudct=%d\n", a * b);
        printf("quotient=%d\n", a / b);
        printf("remainder=%d\n", a % b);
        return 0;
    }
    

    output

    
    sum=21
    difference=13
    product=68
    quotient=4
    remainder=1
    

    Step / Description

    1. Declare integer variable a and b
    2. Initialize int integer variable a = 17, b = 4
    3. printf inbuild function to display sum of variable a and b with decimal place holder %d
    4. printf inbuild function to display difference of variable a and b with decimal place holder%d
    5. printf inbuild function to display product of variable a and b with decimal place holder %d
    6. printf inbuild function to display quotient of variable a and b with place holder %d
    7. printf inbuild function to display remainder of variable a and b with decimal place holder %d
  • How to use a number even or odd in c language

    program to use a number even or odd in c language

    
    #include<stdio.h>
    int main()
    {
        int num;
        printf("Enter a number : ");
        scanf("%d",&num);
        if(num%2 == 0)
        printf("Number is even\n");
        else
        {
            printf("Number is odd\n");
            num*=2;
            printf("Now the number is %d\n",num);
    
        }
        return 0;
    }
    

    output

    
    Enter a number : 24
    Number is even
    

    Steps Description

    1. declare integer variable num
    2. printf inbuild function to display enter variable a number
    3. The value you will put in scanf
    4. going into the is statement will divide by 2
    5. printf inbuild function to display is divide by two then even

    program to use a number even or odd is c longuage

    
    #include<stdio.h>
    int main()
    {
        int num;
        printf("Enter a number : ");
        scanf("%d",&num);
        if(num%2 == 0)
        printf("Number is even\n");
        else
        {
            printf("Number is odd\n");
            num*=2;
            printf("Now the number is %d\n",num);
    
        }
        return 0;
    }
    

    output

    
    Enter a number : 13
    Number is odd
    Now the number is 26
    

    Steps Description

    1. Declare integer variable num
    2. printf inbuild function to display enter variable a number
    3. The value you will put in scanf

    How to use String Operators JavaScript Language

    Program to use String Operator JavaScript Language

    
    let a = "JavaScript Program";
    console.log(a);
    

    Output

    
    JavaScript Program
    

    Steps Description

    1. Declare variable a
    2. Initialize variable with value of "JavaScript Program" a = "JavaScript Program"
    3. Strig Operaters This is a sequence of letters Strings are written inside single or double quotes.
    4. The value of a variable is displayed with the help of console.log inbuilt function

    String methods JavaScript

    JavaScript String .length

    
    let v = "Hello World".length;
    console.log('v =',v);
    

    Output

    
    v = 11
    

    Steps Description

    1. Declare variable v
    2. Initialize variable v with value of string v = "Hello World".length
    3. String .length Calculates the length of a string by counting its characters and output it as a number.
    4. The value of v variable is displayed with the help of console.log inbuilt function

    JavaScript String .concat() Method

    
    let b = "Hello".concat(" ","World");
    console.log('b =',b);
    

    Output

    
    b = Hello World
    

    Steps Description

    1. Declare variable b
    2. Initialize variable b with value of three string b = "Hello".concat(" ","World")
    3. Multiple strings are concatenated to the first string by the concat() method.
    4. The value of b variable is displayed with the help of console.log inbuilt function

    JavaScript String .replace() Method

    
    let l = "Python is best language".replace('Python','JavaScript');
    console.log('l =',l);
    

    Output

    
    l = JavaScript is best language
    

    Steps Description

    1. Declare variable l
    2. Initialize variable l with value of string l = "Python is best language".replace('Python','JavaScritp')
    3. replace() method if a word or character is found in the string after searching, then it works to replace that word or character.
    4. The value of l variable is displayed with the help of console.log inbuilt function

    JavaScript String .charAt() Method

    
    let a = "Hello".charAt(4);
    console.log('a =',a);
    

    Output

    
    a = o
    

    Steps Description

    1. Declare variable a
    2. Initialize variable a with value of string a="Hello"
    3. The charAt() method returns the character of the given string.
    4. The value of a variable is displayed with the help of console.log inbuilt function

    JavaScript String .search() Method

    
    let m = "Hello World".search('r');
    console.log('m =',m);
    

    Output

    
    m = 8
    

    Steps Description

    1. Declare variable m
    2. Initialize variable m with value of string m = "Hello World".search('r')
    3. search() method is used to search a string Will print the index number of a word or character if found in the given string word or character
    4. The value of m variable is displayed with the help of console.log inbuilt function

    JavaScript String .indexOf() Method

    
    let f = "Hello World".indexOf("World");
    console.log('f =',f);
    

    Output

    
    f = 6
    

    Steps Description

    1. Declare variable f
    2. Initialize variable f with value of string f = "Hello World".indexOf("World")
    3. indexOf() method will print the number of the index if the word or character is found in the string. will print -1 if not found
    4. The value of f variable is displayed with the help of console.log inbuilt function

    JavaScript String .lastIndexOf() Method

    
    let g = "Hello in World in JavaScript".lastIndexOf("in");
    console.log('g =',g);
    

    Output

    
    g = 15
    

    Steps Description

    1. Declare variable g
    2. Initialize variable g with value of string g = "Hello in World in JavaScript".lastIndexOf("in")
    3. lastIndexOf() method is used to find a word or letter from the end of the string. When searching for a word or character in a string, if the word or character is found, its index number will be printed. will print -1 if not found
    4. The value of g variable is displayed with the help of console.log inbuilt function

    JavaScript String .includes() Method

    
    let e = "Hello World".includes("World");
    console.log('e =',e);
    

    Output

    
    e = true
    

    Steps Description

    1. Declare variable e
    2. Initialize variable e with value of string "Hello World".includes("World")
    3. includes() method is used to search in a string. Returns true if the word or letter is found in the given string, otherwise false.
    4. The value of e variable is displayed as a return boolean value with the help of console.log inbuilt function

    JavaScript String .startsWith() Method

    
    let c = "Hello my friend".startsWith("My");
    console.log('c =',c);
    

    Output

    
    c = false
    

    Steps Description

    1. Declare variable c
    2. Initialize variable c with value of string "Hello".startsWith("e")
    3. startsWith() method is used to find the first word or character of a string. returns boolean value
    4. The value of c variable is displayed with the help of console.log inbuilt function

    JavaScript String .endsWith() Method

    
    let d = "World".endsWith("d");
    console.log('d =',d);
    

    Output

    
    d = true
    

    Steps Description

    1. Declare variable d
    2. Initialize variable d with value of string d = "World".endsWith("d")
    3. endsWith() method is used to find the last word or character of a string. returns boolean value
    4. The value of d variable is displayed with the help of console.log inbuilt function

    JavaScript String .trim() Method

    
    let s = "  Hello World   ".trim();
    console.log('s =',s);
    

    Output

    
    s = Hello World
    

    Steps Description

    1. Declare variable s
    2. Initialize variable s with value of string s = " Hello World ".trim()
    3. trim() Method If there is one or more spaces between the first and last of the string, the trim method works to remove it.
    4. The value of s variable is displayed with the help of console.log inbuilt function

    JavaScript String .trimStart() Method

    
    let t = "  Hello World   ".trimStart();
    console.log('t =',t);
    

    Output

    
    t = Hello World 
    

    Steps Description

    1. Declare variable t
    2. Initialize variable t with value of string t = " Hello World ".trimStart()
    3. trimStart() Method If a string contains one or more spaces at the beginning, the trimStart method serves to remove it.
    4. The value of t variable is displayed with the help of console.log inbuilt function

    JavaScript String .trimEnd() Method

    
    let u = "  Hello World   ".trimEnd();
    console.log('u =',u);
    

    Output

    
    u =   Hello World
    

    Steps Description

    1. Declare variable u
    2. Initialize variable u with value of string u = " Hello World ".trimEnd()
    3. trimEnd() Method If a string contains one or more spaces at the end, the trimEnd method serves to remove it.
    4. The value of u variable is displayed with the help of console.log inbuilt function

    JavaScript String .padStart() Method

    
    let i = "Hello World".padStart(12,"1");
    console.log('i =',i);
    

    Output

    
    i = 1Hello World
    

    Steps Description

    1. Declare variable i
    2. Initialize variable i with value of string i = "Hello World".padStart(12,"1")
    3. padStart() method can add a character, number, or symbol to the beginning of a string.
    4. The value of i variable is displayed with the help of console.log inbuilt function

    JavaScript String .padEnd() Method

    
    let j = "Hello World JavaScript".padEnd(23,"|");
    console.log('j =',j);
    

    Output

    
    j = Hello World JavaScript|
    

    Steps Description

    1. Declare variable j
    2. Initialize variable j with value of string j = "Hello World JavaScript".padEnd(23,"|")
    3. padEnd() method adds a character, number, or symbol to the end of a string.
    4. The value of i variable is displayed with the help of console.log inbuilt function

    JavaScript String .toUpperCase() Method

    
    let r = "Hello World".toUpperCase();
    console.log('r =',r);
    

    Output

    
    r = HELLO WORLD
    

    Steps Description

    1. Declare variable r
    2. Initialize variable r with value of string r = "Hello World".toUpperCase()
    3. toUpperCase() method converts all words or characters in a string to uppercase.
    4. The value of r variable is displayed with the help of console.log inbuilt function

    JavaScript String .toLowerCase() Method

    
    let q = "Hello World".toLowerCase();
    console.log('q =',q);
    

    Output

    
    q = hello world
    

    Steps Description

    1. Declare variable q
    2. Initialize variable q with value of string q = "Hello World".toLowerCase()
    3. toLowerCase() method Converts all words or characters in a string to lowercase.
    4. The value of q variable is displayed with the help of console.log inbuilt function

    JavaScript String .slice() Method

    
    let n = "Hello World JavaScript Language".slice(1,5);
    console.log('n =',n);
    

    Output

    
    n = ello
    

    Steps Description

    1. Declare variable n
    2. Initialize variable n with value of string n = "Hello World JavaScript Language".slice(1,5)
    3. slice() method can pick up words, letters, or words from one set position to another set position in a string.
    4. The value of n variable is displayed with the help of console.log inbuilt function

    JavaScript String .split() Method

    
    let o = "Hello World JavaScript Language".split("World");
    console.log('o =',o);
    

    Output

    
    o = [ 'Hello ', ' JavaScript Language' ]
    

    Steps Description

    1. Declare variable o
    2. Initialize variable o with value of string o = "Hello World JavaScript Language".split("World")
    3. split() method will search for a given word, character, or symbol in a string and convert it into an array of commas.
    4. The value of o variable is displayed with the help of console.log inbuilt function

    JavaScript String .substring() Method

    
    let p = "Hello World".substring(1,7);
    console.log('p =',p);
    

    Output

    
    p = ello W
    

    Steps Description

    1. Declare variable p
    2. Initialize variable p with value of string p = "Hello World".substring(1,7)
    3. substring() Method method can pick up words, letters, or words from one set position to another set position in a string
    4. The value of p variable is displayed with the help of console.log inbuilt function

    JavaScript String .match() Method

    
    let h = "Hello World in JavaScript Hello World".match(/World/g);
    console.log('h =',h);
    

    Output

    
    h = [ 'World', 'World' ]
    

    Steps Description

    1. Declare variable h
    2. Initialize variable h with value of string h = "Hello World in JavaScript Hello World".match(/World/g)
    3. If a word or character is found in the string, the match() method will create an array.
      else will print null
    4. The value of h variable is displayed with the help of console.log inbuilt function

    JavaScript String .repeat() Method

    
    let k = "Hello World ".repeat(3);
    console.log('k =',k);
    

    Output

    
    k = Hello World Hello World Hello World
    

    Steps Description

    1. Declare variable k
    2. Initialize variable k with value of string k = "Hello World ".repeat(3)
    3. repeat() Method Whatever words or letters are written in the string, they can be repeated again and again.
    4. The value of k variable is displayed with the help of console.log inbuilt function

    JavaScript String .charCodeAt() Method

    
    let w = "Hello World".charCodeAt(4);
    console.log('w =',w);
    

    Output

    
    w = 111
    

    Steps Description

    1. Declare variable w
    2. Initialize variable w with value of string w = "Hello World".charCodeAt(4)
    3. charCodeAt() method returns the ascii value of the character at the index of the character in the string.
    4. The value of w variable is displayed with the help of console.log inbuilt function

    JavaScript String fromCharCode() Method

    
    let x = String.fromCharCode(65,120)
    console.log('x =',x);
    

    Output

    
    x = Ax
    

    Steps Description

    1. Declare variable x
    2. Initialize variable x with value of number x = String.fromCharCode(65,120)
    3. String fromCharCode() method prints the given ascii number in character
    4. The value of x variable is displayed with the help of console.log inbuilt function

    Simple Loop In JavaScript Program

    Simple For Loop

    
    //  index   0   1   2   3   4
    let arr = [23, 12, 53, 34, 54];
    // Defined variable arr and initialize value
    
    for (var i = 0; i < arr.length; i++) {
    // Defined variable i initialize start value is 0 and
    // run up to end of index value in help of  arr.length
    
      console.log("arr =", [i], arr[i]);
    }
    

    Output

    
    arr = [ 0 ] 23
    arr = [ 1 ] 12
    arr = [ 2 ] 53
    arr = [ 3 ] 34
    arr = [ 4 ] 54
    

    Simple While Loop

    
    //  index  0   1   2   3   4 
    let arr = [23, 12, 53, 34, 54];
    // Defined variable arr and initialize value
    
    let j = 0;
    // Defined variable j
    
    while (j < arr.length) {
    // Defined variable j and run up to end 
    // of index value in help of  arr.length
    
      console.log("arr =", [j], arr[j]);
      j++;
    }
    

    Output

    
    arr = [ 0 ] 23
    arr = [ 1 ] 12
    arr = [ 2 ] 53
    arr = [ 3 ] 34
    arr = [ 4 ] 54
    

    Simple Do While loop

    
    //  index  0   1   2   3   4 
    let arr = [23, 12, 53, 34, 54];
    // Defined variable arr and initialize value
    
    let j = 0;
    // Defined variable j
    
    do {
      console.log("arr =", [j], arr[j]);
      j++;
    } while (j < arr.length);
    // run up to end of index value in help of arr.length
    
    

    Output

    
    arr = [ 0 ] 23
    arr = [ 1 ] 12
    arr = [ 2 ] 53
    arr = [ 3 ] 34
    arr = [ 4 ] 54
    

    Assignment Operators JavaScript

    Program to use Assignment Operators ( = ) JavaScript Language

    
    let a = 5;
    console.log('a =', a);
    

    Output

    
    a = 5
    

    Steps Description

    1. Declare variable a
    2. Initialize variable with value of a=5
    3. console.log inbuilt function की मदद्द से a variable की value को display किया गया हैं

    Program to use Subtraction Assignment ( -= ) JavaScript Language

    
    let b = 10
    b -= 2;
    console.log('b =', b);
    

    Output

    
    b = 8
    

    Steps Description

    1. Declare variable b
    2. Initialise variable b with value of 10 b=10 with the help of assignment operator =
    3. value of variable b is subtracted with 2 and assigned using (-=) Subtraction Assignment
    4. console.log inbuilt function की मदद्द से b variable की value को display किया गया हैं

    Program to use Addition Assignment ( += ) JavaScript Language

    
    let c = 5;
    c += 10;
    console.log('c =', c);
    

    Output

    
    c = 15
    

    Steps Description

    1. Declare variable c
    2. Initialise variable c with value of 5 c=5 with the help of assignment operator =
    3. value of variable c is sum with 10 and assigned using (+=) Addition Assignment
    4. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use Multiplication Assignment ( *= ) JavaScript Language

    
    let d = 10;
    d *= 5;
    console.log('d =', d);
    

    Output

    
    d = 50
    

    Steps Description

    1. Declare variable d
    2. Initialise variable d with value of 10 d=10 with the help of assignment operator =
    3. value of variable d is multiplied with 5 and assigned using (*=) Multiplication Assignment
    4. console.log inbuilt function की मदद्द से d variable की value को display किया गया हैं

    Program to use Division Assignment ( /= ) JavaScript Language

    
    let e = 20;
    e /= 5;
    console.log('e =',e);
    

    Output

    
    e = 4
    

    Steps Description

    1. Declare variable e
    2. Initialise variable e with value of 20 e=20 with the help of assignment operator =
    3. value of variable e is divide with 5 and assigned using (/=) Division Assignment
    4. console.log inbuilt function की मदद्द से e variable की value को display किया गया हैं

    Program to use Remainder Assignment ( %= ) JavaScript Language

    
    let f = 10;
    f %= 3;
    console.log('f =',f);
    

    Output

    
    f = 1
    

    Steps Description

    1. Declare variable f
    2. Initialise variable f with value of 10 f=10 with the help of assignment operator =
    3. value of variable f is Remainder with 3 and assigned using (%=) Remainder Assignment
    4. console.log inbuilt function की मदद्द से f variable की value को display किया गया हैं

    Program to use Exponentiation Assignment ( **= ) JavaScript Language

    
    let g = 5;
    g **= 3;
    console.log('g =',g);
    

    Output

    
    g = 125
    

    Steps Description

    1. Declare variable g
    2. Initialise variable g with value of 5 g=5 with the help of assignment operator =
    3. value of variable g is Exponentiation with 3 and assigned using (**=) Exponentiation Assignment
    4. console.log inbuilt function की मदद्द से g variable की value को display किया गया हैं

    How to use Arithmetic Operators JavaScript Language

    Program to use ( + ) Addition Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a + b;
    console.log('c = ', c);
    

    Output

    
    c = 8
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the sum/Addition value of variables a and b
    4. a, b variables की value को (+) Addition Operators ki सहयता से a+b numbers को sum/Addition किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( - ) Subtraction Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a - b;
    console.log('c = ', c);
    

    Output

    
    c = 2
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the subtraction/minus value of variables a and b
    4. a, b variables की value को (-) Subtraction Operators ki सहयता से a-b numbers को subtraction/minus किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( * ) Multiplication Operator JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a * b;
    console.log('c = ', c);
    

    Output

    
    c = 15
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the multiplie/गुड़ा value of variables a and b
    4. a, b variables की value को (*) Multiplication Operators ki सहयता से a*b numbers को multiplie/गुड़ा किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( / )Division Operator JavaScript Language

    
    let a = 15;
    let b = 3;
    let c;
    c = a / b;
    console.log('c = ', c);
    

    Output

    
    c = 5
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 15 and 3 respectively a=15, b=3
    3. Assign c variable with Assignment Operators (=) with the divides/भाग value of variables a and b
    4. a, b variables की value को (/) Division Operators ki सहयता से a/b numbers को divides/भाग किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( % ) Modulus/Remainder Operator JavaScript Language

    
    let a = 10;
    let b = 3;
    let c;
    c = a % b;
    console.log('c = ', c);
    

    Output

    
    c = 1
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 10 and 3 respectively a=10, b=3
    3. Assign c variable with Assignment Operators (=) with the modulus/remainder value of variables a and b
    4. a, b variables की value को (%) Modulus/Remainder Operators ki सहयता से a%b numbers को modulus/remainder किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं

    Program to use ( ++ ) Increment Operators JavaScript Language

    
    let b = 3;
    console.log('b = ',b)
    console.log('++b = ',++b)
    console.log('b++ = ',b++)
    

    Output

    
    b = 3 , ++b = 4 , b++ = 4
    

    Steps Description

    1. Declare variable b
    2. Initialize variable with value of 3 respectively b=3
    3. console.log inbuilt function की मदद्द से b variable की value को display किया गया हैं
    4. console.log inbuilt function की मदद्द से (++) Increment Operators की सहयता से (++b) prefix Increment numbers किया और b variable की value को display किया गया हैं
    5. console.log inbuilt function की मदद्द से (++) Increment Operators ki सहयता से (b++) postfix Increment numbers किया और b variable की value को display किया गया हैं

    Program to use ( -- ) Decrement Operators JavaScript Language

    
    let a = 5;
    console.log('a = ',a)
    console.log('--a = ',--a)
    console.log('a-- = ',a--)
    

    Output

    
    a =  5 , --a = 4 , a-- = 4
    

    Steps Description

    1. Declare variable a
    2. Initialize variable with value of 5 respectively a=5
    3. console.log inbuilt function की मदद्द से a variable की value को display किया गया हैं
    4. console.log inbuilt function की मदद्द से (--) Decrement Operators की सहयता से (--a) prefix Decrement numbers किया और a variable की value को display किया गया हैं
    5. console.log inbuilt function की मदद्द से (--) Decrement Operators ki सहयता से (a--) postfix Decrement numbers किया और a variable की value को display किया गया हैं

    Program to use ( ** ) Exponentiation Operators JavaScript Language

    
    let a = 5;
    let b = 3;
    let c;
    c = a ** b;
    console.log('c = ', c);
    

    Output

    
    c = 125
    

    Steps Description

    1. Declare three variables a, b and c
    2. Initialize both variables with value of 5 and 3 respectively a=5, b=3
    3. Assign c variable with Assignment Operators (=) with the Exponentiation value of variables a and b
    4. a, b variables की value को (**) Exponentiation Operators ki सहयता से a*b numbers को Exponentiation (5**3 / 5*5*5 = 125) किया गया हैं
    5. console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं