#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;
}
#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
declare integer variable num
printf inbuild function to display enter variable a number
The value you will put in scanf
going into the is statement will divide by 2
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
Declare integer variable num
printf inbuild function to display enter variable a number
let v = "Hello World".length;
console.log('v =',v);
Output
v = 11
Steps Description
Declare variable v
Initialize variable v with value of string v = "Hello World".length
String .length Calculates the length of a string by counting its characters and output it as a number.
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
Declare variable b
Initialize variable b with value of three string b = "Hello".concat(" ","World")
Multiple strings are concatenated to the first string by the concat() method.
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
Declare variable l
Initialize variable l with value of string l = "Python is best language".replace('Python','JavaScritp')
replace() method if a word or character is found in the string after searching, then it works to replace that word or character.
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
Declare variable a
Initialize variable a with value of string a="Hello"
The charAt() method returns the character of the given string.
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
Declare variable m
Initialize variable m with value of string m = "Hello World".search('r')
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
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
Declare variable f
Initialize variable f with value of string f = "Hello World".indexOf("World")
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
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
Declare variable g
Initialize variable g with value of string g = "Hello in World in JavaScript".lastIndexOf("in")
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
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
Declare variable e
Initialize variable e with value of string "Hello World".includes("World")
includes() method is used to search in a string. Returns true if the word or letter is found in the given string, otherwise false.
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
Declare variable c
Initialize variable c with value of string "Hello".startsWith("e")
startsWith() method is used to find the first word or character of a string. returns boolean value
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
Declare variable d
Initialize variable d with value of string d = "World".endsWith("d")
endsWith() method is used to find the last word or character of a string. returns boolean value
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
Declare variable s
Initialize variable s with value of string s = " Hello World ".trim()
trim() Method If there is one or more spaces between the first and last of the string, the trim method works to remove it.
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
Declare variable t
Initialize variable t with value of string t = " Hello World ".trimStart()
trimStart() Method If a string contains one or more spaces at the beginning, the trimStart method serves to remove it.
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
Declare variable u
Initialize variable u with value of string u = " Hello World ".trimEnd()
trimEnd() Method If a string contains one or more spaces at the end, the trimEnd method serves to remove it.
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
Declare variable i
Initialize variable i with value of string i = "Hello World".padStart(12,"1")
padStart() method can add a character, number, or symbol to the beginning of a string.
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
Declare variable j
Initialize variable j with value of string j = "Hello World JavaScript".padEnd(23,"|")
padEnd() method adds a character, number, or symbol to the end of a string.
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
Declare variable r
Initialize variable r with value of string r = "Hello World".toUpperCase()
toUpperCase() method converts all words or characters in a string to uppercase.
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
Declare variable q
Initialize variable q with value of string q = "Hello World".toLowerCase()
toLowerCase() method Converts all words or characters in a string to lowercase.
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
Declare variable n
Initialize variable n with value of string n = "Hello World JavaScript Language".slice(1,5)
slice() method can pick up words, letters, or words from one set position to another set position in a string.
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
Declare variable o
Initialize variable o with value of string o = "Hello World JavaScript Language".split("World")
split() method will search for a given word, character, or symbol in a string and convert it into an array of commas.
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
Declare variable p
Initialize variable p with value of string p = "Hello World".substring(1,7)
substring() Method method can pick up words, letters, or words from one set position to another set position in a string
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
Declare variable h
Initialize variable h with value of string h = "Hello World in JavaScript Hello World".match(/World/g)
If a word or character is found in the string, the match() method will create an array.
else will print null
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
Declare variable k
Initialize variable k with value of string k = "Hello World ".repeat(3)
repeat() Method Whatever words or letters are written in the string, they can be repeated again and again.
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
Declare variable w
Initialize variable w with value of string w = "Hello World".charCodeAt(4)
charCodeAt() method returns the ascii value of the character at the index of the character in the string.
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
Declare variable x
Initialize variable x with value of number x = String.fromCharCode(65,120)
String fromCharCode() method prints the given ascii number in character
The value of x variable is displayed with the help of console.log inbuilt function
// 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]);
}
// 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++;
}
// 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
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
Declare three variables a, b and c
Initialize both variables with value of 5 and 3 respectively a=5, b=3
Assign c variable with Assignment Operators (=) with the sum/Addition value of variables a and b
a, b variables की value को (+) Addition Operators ki सहयता से a+b numbers को sum/Addition किया गया हैं
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
Declare three variables a, b and c
Initialize both variables with value of 5 and 3 respectively a=5, b=3
Assign c variable with Assignment Operators (=) with the subtraction/minus value of variables a and b
a, b variables की value को (-) Subtraction Operators ki सहयता से a-b numbers को subtraction/minus किया गया हैं
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
Declare three variables a, b and c
Initialize both variables with value of 5 and 3 respectively a=5, b=3
Assign c variable with Assignment Operators (=) with the multiplie/गुड़ा value of variables a and b
a, b variables की value को (*) Multiplication Operators ki सहयता से a*b numbers को multiplie/गुड़ा किया गया हैं
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
Declare three variables a, b and c
Initialize both variables with value of 15 and 3 respectively a=15, b=3
Assign c variable with Assignment Operators (=) with the divides/भाग value of variables a and b
a, b variables की value को (/) Division Operators ki सहयता से a/b numbers को divides/भाग किया गया हैं
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
Declare three variables a, b and c
Initialize both variables with value of 10 and 3 respectively a=10, b=3
Assign c variable with Assignment Operators (=) with the modulus/remainder value of variables a and b
a, b variables की value को (%) Modulus/Remainder Operators ki सहयता से a%b numbers को modulus/remainder किया गया हैं
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
Declare variable b
Initialize variable with value of 3 respectively b=3
console.log inbuilt function की मदद्द से b variable की value को display किया गया हैं
console.log inbuilt function की मदद्द से (++) Increment Operators की सहयता से (++b) prefix Increment numbers किया और b variable की value को display किया गया हैं
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
Declare variable a
Initialize variable with value of 5 respectively a=5
console.log inbuilt function की मदद्द से a variable की value को display किया गया हैं
console.log inbuilt function की मदद्द से (--) Decrement Operators की सहयता से (--a) prefix Decrement numbers किया और a variable की value को display किया गया हैं
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
Declare three variables a, b and c
Initialize both variables with value of 5 and 3 respectively a=5, b=3
Assign c variable with Assignment Operators (=) with the Exponentiation value of variables a and b
a, b variables की value को (**) Exponentiation Operators ki सहयता से a*b numbers को Exponentiation (5**3 / 5*5*5 = 125) किया गया हैं
console.log inbuilt function की मदद्द से c variable की value को display किया गया हैं