21. Write a JavaScript program to create a new string adding "Py" in front of a given string. If the given string begins with "Py" then return the original string.
function string_check(str1) {
if (str1 === null str1 === undefined str1.substring(0, 2) === 'Py')
{
return str1;
}
return "Py"+str1;
}
console.log(string_check("Python"));
console.log(string_check("thon"));
#sirfpadhai.in
#javascript
function string_check(str1) {
if (str1 === null
{
return str1;
}
return "Py"+str1;
}
console.log(string_check("Python"));
console.log(string_check("thon"));
#sirfpadhai.in
#javascript
Forwarded from Tech & code
2500+ Interview Questions (FREE)
β― JavaScript
interviewquestions.notion.site/JavaScript-Intβ¦
β― SQL
interviewquestions.notion.site/SQL-Interview-β¦
β― Python
interviewquestions.notion.site/Python-Interviβ¦
β― OOPs
interviewquestions.notion.site/OOPS-Interviewβ¦
β― DSA
interviewquestions.notion.site/DSA-Interview-β¦
β― HTML/CSS
interviewquestions.notion.site/HTML-CSS-Interβ¦
β― React
interviewquestions.notion.site/React-Intervieβ¦
β― Git
interviewquestions.notion.site/GIT-Interview-β¦
β― JavaScript
interviewquestions.notion.site/JavaScript-Intβ¦
β― SQL
interviewquestions.notion.site/SQL-Interview-β¦
β― Python
interviewquestions.notion.site/Python-Interviβ¦
β― OOPs
interviewquestions.notion.site/OOPS-Interviewβ¦
β― DSA
interviewquestions.notion.site/DSA-Interview-β¦
β― HTML/CSS
interviewquestions.notion.site/HTML-CSS-Interβ¦
β― React
interviewquestions.notion.site/React-Intervieβ¦
β― Git
interviewquestions.notion.site/GIT-Interview-β¦
22. Write a JavaScript program to remove a character at the specified position of a given string and return the new string.
function remove_character(str, char_pos)
{
part1 = str.substring(0, char_pos);
part2 = str.substring(char_pos + 1, str.length);
return (part1 + part2);
}
console.log(remove_character("Python",0));
console.log(remove_character("Python",3));
console.log(remove_character("Python",5));
#sirfpadhai.in
function remove_character(str, char_pos)
{
part1 = str.substring(0, char_pos);
part2 = str.substring(char_pos + 1, str.length);
return (part1 + part2);
}
console.log(remove_character("Python",0));
console.log(remove_character("Python",3));
console.log(remove_character("Python",5));
#sirfpadhai.in
Youtube Channel for CDAC CCAT Exams
Section A :
Quants and Aptitude :
Career Ride : https://www.youtube.com/watch?v=tnc9ojITRg4&list=PLpyc33gOcbVA4qXMoQ5vmhefTruk5t9lt
5 Minute Engineering : https://www.youtube.com/watch?v=eQN_sz2crc0&list=PLYwpaL_SFmcBpa1jwpCbEDespCRF3UPE5
Verbal Ability : https://www.youtube.com/watch?v=TNkq01wrqUg&list=PLpyc33gOcbVBbD8Vfy-gCbivjSSHbMpUX
Reasoning : https://www.youtube.com/watch?v=fgE9J2SR8L8&list=PL1zxEeUFe9leRBWC-g-ZkJkpbl4F3Hg0F
Section B :
C Programming :
Jenny's Lecture : https://www.youtube.com/watch?v=EjavYOFoJJ0&list=PLdo5W4Nhv31a8UcMN9-35ghv8qyFWD9_S
Apna College : https://www.youtube.com/watch?v=irqbmMNs2Bo&pp=ygUOQyBwcm9ncmFtbWluZyA%3D
Code with Harry : https://www.youtube.com/watch?v=7Dh73z3icd8&list=PLu0W_9lII9aiXlHcLx-mDH1Qul38wD3aR
Saurabh Shukla : https://www.youtube.com/watch?v=Bjzfag1zZPg&list=PLe_7x5eaUqtWp9fvsxhC4XIkoR3n5A-sF
C++ :
Code with Harry : https://www.youtube.com/watch?v=yGB9jhsEsr8&pp=ygUMYysrIHR1dG9yaWFs
Saurabh Shukla : https://www.youtube.com/watch?v=Iuo9PpGE04Y&list=PLLYz8uHU480j37APNXBdPz7YzAi4XlQUF
Neso Academy : https://www.youtube.com/watch?v=s0g4ty29Xgg&list=PLBlnK6fEyqRh6isJ01MBnbNpV3ZsktSyS
Love Babber : https://www.youtube.com/watch?v=i_5pvt7ag7E&pp=ygUOb29wcyB1c2luZyBjKys%3D
College Wallah : https://www.youtube.com/watch?v=9roJTTghZJI&pp=ygUOb29wcyB1c2luZyBjKys%3D
DSA :
Last Moment Tuitions : https://www.youtube.com/watch?v=5c4xxrEjlq8&list=PL0s3O6GgLL5c-NQuZLBlR000KWxGb8A5j&pp=gAQB
Code with Harry : https://www.youtube.com/watch?v=5_5oE5lgrhw&list=PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi
Jenny's Lectures : https://www.youtube.com/watch?v=AT14lCXuMKI&list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU
Operating System :
Gate Smasher : https://www.youtube.com/watch?v=bkSWJJZNgf8&list=PLxCzCOWd7aiGz9donHRrE9I3Mwn6XdP8p
Apna College : https://www.youtube.com/watch?v=ktP8QsPzKfs&pp=ygURb3BlcmF0aW5nIHN5c3RlbSA%3D
Big Data : https://www.youtube.com/watch?v=pqT4AgPuzZ0&list=PL6UwySlcwEYJ2hFuGIvr4VEHUAfl-GCNT
Artificial Intelligence :
Gate Smashers : https://www.youtube.com/watch?v=uB3i-qV6VdM&list=PLxCzCOWd7aiHGhOHV-nwb0HR5US5GFKFI
Section C :
Microprocess :
Bharat Acharya : https://www.youtube.com/watch?v=0M74z5jEAyA&list=PLfzBO7vcQZ1L1wE17y07ZR4Vxw0EHibTM&pp=iAQB
Last Moment Tuitions : https://www.youtube.com/watch?v=yXg1jGBzhl4&list=PL0s3O6GgLL5cN1svnyKJrGovdK2mkLZXE&pp=gAQB
Digital Electronics :
Neso Academy : https://www.youtube.com/watch?v=M0mx8S05v60&list=PLBlnK6fEyqRjMH3mWf6kwqiTbT798eAOm
Knowledge Gate : https://www.youtube.com/watch?v=ztkMRln_jDA&list=PLmXKhU9FNesSfX1PVt4VGm-wbIKfemUWK
Engineers ki Pathshala : https://www.youtube.com/watch?v=GH9LoyFPn2g&list=PL9RcWoqXmzaJN3LcyxBm2tLjUk8wvOYrv
Computer Architecture:
Last Moment Tuitions : https://www.youtube.com/watch?v=IfX4BT7HRNo&list=PL0s3O6GgLL5es3eh6-E4JVnymMqZKRAHH&pp=gAQB
Gate Smashers : https://www.youtube.com/watch?v=L9X7XXfHYdU&list=PLxCzCOWd7aiHMonh3G6QNKq53C6oNXGrX
Neso Academy : https://www.youtube.com/watch?v=Ol8D69VKX2k&list=PLBlnK6fEyqRgLLlzdgiTUKULKJPYc0A4q
Download LMT App for CCAT Exams Preparation : https://play.google.com/store/apps/details?id=co.jones.cjzgt
Regards
#sirfpadhai.in
Section A :
Quants and Aptitude :
Career Ride : https://www.youtube.com/watch?v=tnc9ojITRg4&list=PLpyc33gOcbVA4qXMoQ5vmhefTruk5t9lt
5 Minute Engineering : https://www.youtube.com/watch?v=eQN_sz2crc0&list=PLYwpaL_SFmcBpa1jwpCbEDespCRF3UPE5
Verbal Ability : https://www.youtube.com/watch?v=TNkq01wrqUg&list=PLpyc33gOcbVBbD8Vfy-gCbivjSSHbMpUX
Reasoning : https://www.youtube.com/watch?v=fgE9J2SR8L8&list=PL1zxEeUFe9leRBWC-g-ZkJkpbl4F3Hg0F
Section B :
C Programming :
Jenny's Lecture : https://www.youtube.com/watch?v=EjavYOFoJJ0&list=PLdo5W4Nhv31a8UcMN9-35ghv8qyFWD9_S
Apna College : https://www.youtube.com/watch?v=irqbmMNs2Bo&pp=ygUOQyBwcm9ncmFtbWluZyA%3D
Code with Harry : https://www.youtube.com/watch?v=7Dh73z3icd8&list=PLu0W_9lII9aiXlHcLx-mDH1Qul38wD3aR
Saurabh Shukla : https://www.youtube.com/watch?v=Bjzfag1zZPg&list=PLe_7x5eaUqtWp9fvsxhC4XIkoR3n5A-sF
C++ :
Code with Harry : https://www.youtube.com/watch?v=yGB9jhsEsr8&pp=ygUMYysrIHR1dG9yaWFs
Saurabh Shukla : https://www.youtube.com/watch?v=Iuo9PpGE04Y&list=PLLYz8uHU480j37APNXBdPz7YzAi4XlQUF
Neso Academy : https://www.youtube.com/watch?v=s0g4ty29Xgg&list=PLBlnK6fEyqRh6isJ01MBnbNpV3ZsktSyS
Love Babber : https://www.youtube.com/watch?v=i_5pvt7ag7E&pp=ygUOb29wcyB1c2luZyBjKys%3D
College Wallah : https://www.youtube.com/watch?v=9roJTTghZJI&pp=ygUOb29wcyB1c2luZyBjKys%3D
DSA :
Last Moment Tuitions : https://www.youtube.com/watch?v=5c4xxrEjlq8&list=PL0s3O6GgLL5c-NQuZLBlR000KWxGb8A5j&pp=gAQB
Code with Harry : https://www.youtube.com/watch?v=5_5oE5lgrhw&list=PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi
Jenny's Lectures : https://www.youtube.com/watch?v=AT14lCXuMKI&list=PLdo5W4Nhv31bbKJzrsKfMpo_grxuLl8LU
Operating System :
Gate Smasher : https://www.youtube.com/watch?v=bkSWJJZNgf8&list=PLxCzCOWd7aiGz9donHRrE9I3Mwn6XdP8p
Apna College : https://www.youtube.com/watch?v=ktP8QsPzKfs&pp=ygURb3BlcmF0aW5nIHN5c3RlbSA%3D
Big Data : https://www.youtube.com/watch?v=pqT4AgPuzZ0&list=PL6UwySlcwEYJ2hFuGIvr4VEHUAfl-GCNT
Artificial Intelligence :
Gate Smashers : https://www.youtube.com/watch?v=uB3i-qV6VdM&list=PLxCzCOWd7aiHGhOHV-nwb0HR5US5GFKFI
Section C :
Microprocess :
Bharat Acharya : https://www.youtube.com/watch?v=0M74z5jEAyA&list=PLfzBO7vcQZ1L1wE17y07ZR4Vxw0EHibTM&pp=iAQB
Last Moment Tuitions : https://www.youtube.com/watch?v=yXg1jGBzhl4&list=PL0s3O6GgLL5cN1svnyKJrGovdK2mkLZXE&pp=gAQB
Digital Electronics :
Neso Academy : https://www.youtube.com/watch?v=M0mx8S05v60&list=PLBlnK6fEyqRjMH3mWf6kwqiTbT798eAOm
Knowledge Gate : https://www.youtube.com/watch?v=ztkMRln_jDA&list=PLmXKhU9FNesSfX1PVt4VGm-wbIKfemUWK
Engineers ki Pathshala : https://www.youtube.com/watch?v=GH9LoyFPn2g&list=PL9RcWoqXmzaJN3LcyxBm2tLjUk8wvOYrv
Computer Architecture:
Last Moment Tuitions : https://www.youtube.com/watch?v=IfX4BT7HRNo&list=PL0s3O6GgLL5es3eh6-E4JVnymMqZKRAHH&pp=gAQB
Gate Smashers : https://www.youtube.com/watch?v=L9X7XXfHYdU&list=PLxCzCOWd7aiHMonh3G6QNKq53C6oNXGrX
Neso Academy : https://www.youtube.com/watch?v=Ol8D69VKX2k&list=PLBlnK6fEyqRgLLlzdgiTUKULKJPYc0A4q
Download LMT App for CCAT Exams Preparation : https://play.google.com/store/apps/details?id=co.jones.cjzgt
Regards
#sirfpadhai.in
YouTube
Fractions and Decimals - Shortcuts & Tricks for Placement Tests, Job Interviews & Exams
Crack the quantitative aptitude section of Placement Test or Job Interview at any company with shortcuts & tricks on Fractions and Decimals. Extremely helpful to crack entrance exams like MBA, Banking β IBPS, SBI, UPSC, SSC, Railways etc.
Our Websites:
β¦
Our Websites:
β¦
23. Write a JavaScript program to create a new string from a given string changing the position of first and last characters. The string length must be greater than or equal to 1.
function first_last(str1)
{
if (str1.length <= 1)
{
return str1;
}
mid_char = str1.substring(1, str1.length - 1);
return (str1.charAt(str1.length - 1)) + mid_char + str1.charAt(0);
}
console.log(first_last('a'));
console.log(first_last('ab'));
console.log(first_last('abc'));
#sirfpadhai.in
#javascript
function first_last(str1)
{
if (str1.length <= 1)
{
return str1;
}
mid_char = str1.substring(1, str1.length - 1);
return (str1.charAt(str1.length - 1)) + mid_char + str1.charAt(0);
}
console.log(first_last('a'));
console.log(first_last('ab'));
console.log(first_last('abc'));
#sirfpadhai.in
#javascript
12. Program to find the roots of a quadratic equation.
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a, b, c, discriminant, real;
double r1, r2, imag;
printf("Enter coefficients a, b and c: ");
scanf("%f%f%f", &a, &b, &c);
discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
r1 = (-b + sqrt(discriminant)) / (2 * a);
r2 = (-b - sqrt(discriminant)) / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2);
}
else if (discriminant == 0)
{
r1 = r2 = -b / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2)
}
else
{
real = -b / (2 * a);
imag = sqrt(-discriminant) / (2 * a);
printf("Roots : %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
}
getch();
}
#if_else
#sirfpadhai.in
#Clanguage
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a, b, c, discriminant, real;
double r1, r2, imag;
printf("Enter coefficients a, b and c: ");
scanf("%f%f%f", &a, &b, &c);
discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
r1 = (-b + sqrt(discriminant)) / (2 * a);
r2 = (-b - sqrt(discriminant)) / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2);
}
else if (discriminant == 0)
{
r1 = r2 = -b / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2)
}
else
{
real = -b / (2 * a);
imag = sqrt(-discriminant) / (2 * a);
printf("Roots : %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
}
getch();
}
#if_else
#sirfpadhai.in
#Clanguage
Which Programming Language Do You Use/Know?
Anonymous Poll
0%
Java
50%
Python
0%
C#
33%
C/C++
0%
Kotlin
0%
Swift
17%
React.js
0%
R
0%
Golang
0%
Ruby
13. Program to accept rollnumber and marks of three subjects from user and print total marks, average and grade.
#include<stdio.h>
#include<conio.h>
void main()
{
int RollNum, m1, m2, m3, total;
float avg;
clrscr();
printf("Enter Roll Number : ");
scanf("%d",&RollNum);
printf("Enter marks for three subjects : ");
scanf("%d %d %d", &m1, &m2, &m3);
total = m1 + m2 + m3;
avg = total / 3.0;
printf("\nTotal is : %d", total);
printf("\nAverage is : %5.2f", avg);
if(avg>80)
printf("\nGrade : A");
else if((avg>60)&&(avg<=80))
printf("\nGrade : B");
else if((avg>40)&&(avg<=60))
printf("\nGrade : C");
else if((avg>=33)&&(avg<=40)
printf("\nGrade : D");
else
printf("\nGrade : Fail");
getch();
}
#if_else
#Clanguage
#sirfpadhai.in
#include<stdio.h>
#include<conio.h>
void main()
{
int RollNum, m1, m2, m3, total;
float avg;
clrscr();
printf("Enter Roll Number : ");
scanf("%d",&RollNum);
printf("Enter marks for three subjects : ");
scanf("%d %d %d", &m1, &m2, &m3);
total = m1 + m2 + m3;
avg = total / 3.0;
printf("\nTotal is : %d", total);
printf("\nAverage is : %5.2f", avg);
if(avg>80)
printf("\nGrade : A");
else if((avg>60)&&(avg<=80))
printf("\nGrade : B");
else if((avg>40)&&(avg<=60))
printf("\nGrade : C");
else if((avg>=33)&&(avg<=40)
printf("\nGrade : D");
else
printf("\nGrade : Fail");
getch();
}
#if_else
#Clanguage
#sirfpadhai.in
π1
24. Write a JavaScript program to create a new string from a given string with the first character of the given string added at the front and back.
function front_back(str)
{
first = str.substring(0,1);
return first + str + first;
}
console.log(front_back('a'));
console.log(front_back('ab'));
console.log(front_back('abc'));
#javascript
#sirfpadhai.in
function front_back(str)
{
first = str.substring(0,1);
return first + str + first;
}
console.log(front_back('a'));
console.log(front_back('ab'));
console.log(front_back('abc'));
#javascript
#sirfpadhai.in
Forwarded from IT World
Learn Data science in your native language and earn upto 21 LPA!
Certified by IIT Madras Pravartak, this is a 3-5 month course that comes with assured job opportunities!
Click the link below to register now and start your career in data science
https://bit.ly/40Qjg7e
Certified by IIT Madras Pravartak, this is a 3-5 month course that comes with assured job opportunities!
Click the link below to register now and start your career in data science
https://bit.ly/40Qjg7e
Best YouTube Playlists to learn Programming:
πΈC
youtube.com/playlist?list=β¦
πΈC++
youtube.com/playlist?list=β¦
πΈ Python
youtube.com/playlist?list=β¦
πΈData Science
imp.i384100.net/1rq3Km
πΈ JavaScript
youtube.com/playlist?list=β¦
πΈJava
youtube.com/playlist?list=β¦
πΈData Structures and Algorithms
imp.i384100.net/jrogG0
πΈC#
youtube.com/playlist?list=β¦
πΈJavaScript
imp.i384100.net/XYDqvg
πΈSQL
youtube.com/playlist?list=β¦
πΈ Go
youtube.com/playlist?list=β¦
πΈPHP
youtube.com/playlist?list=β¦
πΈ Python
imp.i384100.net/21x3eQ
πΈSwift
youtube.com/playlist?list=β¦
πΈKotlin
youtube.com/playlist?list=β¦
πΈDart
youtube.com/playlist?list=β¦
πΈC and C++
imp.i384100.net/NkOVJ2
πΈRuby
youtube.com/playlist?list=β¦
πΈRust
youtube.com/playlist?list=β¦
πΈ Blockchain
imp.i384100.net/LXbG1M
πΈTypeScript
youtube.com/playlist?list=β¦
πΈR
youtube.com/playlist?list=β¦
πΈReact
youtube.com/playlist?list=β¦
πΈNext.js
youtube.com/playlist?list=β¦
πΈNode.js
youtube.com/playlist?list=β¦
πΈJava
imp.i384100.net/QymgX3
πΈHTML/CSS
youtube.com/playlist?list=β¦
πΈMachine Learning
youtube.com/playlist?list=β¦
πΈDeep Learning
youtube.com/playlist?list=β¦
πΈDSA
youtube.com/playlist?list=β¦
πΈAI
imp.i384100.net/jrog40
πΈC
youtube.com/playlist?list=β¦
πΈC++
youtube.com/playlist?list=β¦
πΈ Python
youtube.com/playlist?list=β¦
πΈData Science
imp.i384100.net/1rq3Km
πΈ JavaScript
youtube.com/playlist?list=β¦
πΈJava
youtube.com/playlist?list=β¦
πΈData Structures and Algorithms
imp.i384100.net/jrogG0
πΈC#
youtube.com/playlist?list=β¦
πΈJavaScript
imp.i384100.net/XYDqvg
πΈSQL
youtube.com/playlist?list=β¦
πΈ Go
youtube.com/playlist?list=β¦
πΈPHP
youtube.com/playlist?list=β¦
πΈ Python
imp.i384100.net/21x3eQ
πΈSwift
youtube.com/playlist?list=β¦
πΈKotlin
youtube.com/playlist?list=β¦
πΈDart
youtube.com/playlist?list=β¦
πΈC and C++
imp.i384100.net/NkOVJ2
πΈRuby
youtube.com/playlist?list=β¦
πΈRust
youtube.com/playlist?list=β¦
πΈ Blockchain
imp.i384100.net/LXbG1M
πΈTypeScript
youtube.com/playlist?list=β¦
πΈR
youtube.com/playlist?list=β¦
πΈReact
youtube.com/playlist?list=β¦
πΈNext.js
youtube.com/playlist?list=β¦
πΈNode.js
youtube.com/playlist?list=β¦
πΈJava
imp.i384100.net/QymgX3
πΈHTML/CSS
youtube.com/playlist?list=β¦
πΈMachine Learning
youtube.com/playlist?list=β¦
πΈDeep Learning
youtube.com/playlist?list=β¦
πΈDSA
youtube.com/playlist?list=β¦
πΈAI
imp.i384100.net/jrog40
Coursera
Python for Data Science, AI & Development
Offered by IBM. Kickstart your Python journey with this ... Enroll for free.
β
*Java Control Statements* π§ β
1οΈβ£ *if Statement*
Executes a block if the condition is true.
2οΈβ£ *if-else Statement*
Gives two paths: true or false.
3οΈβ£ *else-if Ladder*
Checks multiple conditions one by one.
4οΈβ£ *switch Statement*
Best for multiple fixed values.
5οΈβ£ *for Loop*
Repeats a block a fixed number of times.
6οΈβ£ *while Loop*
Runs while the condition is true.
7οΈβ£ *do-while Loop*
Runs once even if the condition is false.
8οΈβ£ *break Statement*
Exits from loop or switch early.
9οΈβ£ *continue Statement*
Skips to the next iteration.
π *return Statement*
Ends method execution and optionally returns a value.
π¬ *Tap β€οΈ for more!*
1οΈβ£ *if Statement*
Executes a block if the condition is true.
if (age > 18) { System.out.println("Adult"); }
2οΈβ£ *if-else Statement*
Gives two paths: true or false.
if (marks >= 40) { ... } else { ... }
3οΈβ£ *else-if Ladder*
Checks multiple conditions one by one.
if (...) { } else if (...) { } else { }
4οΈβ£ *switch Statement*
Best for multiple fixed values.
switch(day) {
case 1: System.out.println("Monday"); break;
...
}
5οΈβ£ *for Loop*
Repeats a block a fixed number of times.
for (int i = 0; i < 5; i++) { ... }
6οΈβ£ *while Loop*
Runs while the condition is true.
while (count < 5) { ... }
7οΈβ£ *do-while Loop*
Runs once even if the condition is false.
do { ... } while (condition);
8οΈβ£ *break Statement*
Exits from loop or switch early.
if (x == 5) break;
9οΈβ£ *continue Statement*
Skips to the next iteration.
if (x == 3) continue;
π *return Statement*
Ends method execution and optionally returns a value.
π¬ *Tap β€οΈ for more!*