Skip to main content

Print the following series using for loop:- 1,8,27,64,125,216,......n JS

Copy to Clipboard console.log("Print the following series using for loop:- 1,8,27,64,125,216,......n"); let n ; function cubeseriesloop(n){ for(let i=0; i =0){ console.log(cubei); }else{ break; } } } console.log(cubeseriesloop(9));

Write a program to return the reverse of a number Input n=123 output 321(Javascript)

Write a program to return the reverse of a number Input n=123 output 321



console.log("Reverse Number");
let rn = 1235;
let temps = rn;
function reverse_number(rn) {
  let rev_num = 0;
  while (rn > 0) {
    rev_num = rev_num * 10 + (rn % 10);
    rn = Math.floor(rn / 10);
  }
  return rev_num;
}

console.log(reverse_number(rn));

Comments

Popular posts from this blog

Screen Recorder Tool

Screen Recorder Tool Start Recording Stop Recording This the demo of the source code click above buttons to recording the screens, enjoy and download it   Creating a complete responsive screen recorder tool using the RecordRTC library involves multiple steps, including HTML, CSS, and JavaScript. Below is a simplified example to give you an idea of how you can implement this. Please note that this example might not cover all possible edge cases, and you might need to adapt and extend it for your specific needs.  First, make sure you include the RecordRTC library in your HTML. You can include it using a script tag in the <head> section of your HTML document: If you want the source code for it see the below video:

Write a program to sort given elements using bubble sort , insertion sort, and selection sort.

Program: #include <stdio.h> #include <stdlib.h> void bubble() { int n; printf("Enter Size of Array to Create : "); scanf("%d", &n); int a[n]; printf("Enter Elements of Array : "); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } printf("Unsorted Array : "); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } for (int i = 0; i < n; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] > a[j + 1]) { int tmp = a[j]; a[j] = a[j + 1]; a[j + 1] = tmp; } } } printf("\nSorted Array : "); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } } void insertion() { int n; printf("Enter Size of Array to Create : "); scanf("%d", &n); int a[n]; printf("Enter Elements of Array : "); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } printf("Unsorted Array : "); for (int i = 0; i < n; i++) { printf("%d ", a[i]...