This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = require('async') | |
async function f() { | |
let promise = new Promise((resolve, reject) => { | |
setTimeout(() => resolve("done!"), 1000) | |
}); | |
let result = await promise; // wait till the promise resolves (*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I/P: How many rows: 5 | |
O/P: | |
@ 1 1 1 1 | |
2 @ 2 2 2 | |
3 3 @ 3 3 | |
4 4 4 @ 4 | |
5 5 5 5 @ | |
//Logic | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
//#include<conio.h> | |
int main( ) | |
{ | |
int r,c,askey,sp,num; | |
printf("\n\n\tC PROGRAM TO PRINT REVERSE PYRAMID OF ALPHABETS \n"); | |
printf("\nEnter the number of rows you want to show in your reverse pyramid : "); | |
scanf("%d",&num); | |
printf("\n\n\n"); | |
for( r=num; r>=1; r-- ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void main() | |
{ | |
int i,j,askey; | |
printf("\n\nPrint the 3*3 matrix from i to j\n"); | |
printf("---------------------------------\n"); | |
askey=105; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void main() | |
{ | |
int rows,starNo,spaceNo; | |
printf("Enter Rows:\n"); | |
scanf("%d",&rows); | |
for(int i=1;i<=rows;i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Input | |
var arr1 = [1,3,2,4,0,9,3,5]; | |
var arr2 = [0,9,2,2,7,5]; | |
//output | |
var outputData = [ 2, 0, 9, 5 ]; | |
//Answer | |
//1st way | |
var answer2 =[]; | |
for(var num in arr1){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class pattern { | |
public static void printTriagle(int n) | |
{ | |
int temp = n; | |
for(int i=0;i<n;i++) { | |
for(int j=0;j<n*2;j++) { | |
if(i==0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Input Value : Any number n = 5; | |
Output: | |
5555555555 | |
4444**4444 | |
333****333 | |
22******22 | |
1********1 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Swap "1-st Array elements to last" and "Last element of array to 1-st" | |
var array = [33,535,5,345,3,4,5,3,5,34,5,435]; | |
console.log("Before Swapping : " , array); | |
if(array.length != 0){ | |
var last = array.pop(); | |
var first = array[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In switch statements if you are not add break statements | |
// after the end of case statements then all cases are executed by defaults | |
var number = 3; | |
switch(number){ | |
case 1: | |
console.log("The number is one"); | |
break; | |
case 2: |
NewerOlder