We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Draw The Triangle 1
Draw The Triangle 1
Sort by
recency
|
1182 Discussions
|
Please Login in order to post a comment
SET SERVEROUTPUT ON; DECLARE v_var NUMBER := 20; BEGIN -----block WHILE v_var > 0 LOOP DBMS_OUTPUT.PUT_LINE(LPAD('* ', v_var * 2, '* ')); ---print v_var := v_var - 1; END LOOP; END; /
DELIMITER //
CREATE PROCEDURE PrintStars() BEGIN DECLARE count INT DEFAULT 20;
END //
DELIMITER ;
-- To execute the procedure: CALL PrintStars();
DELIMITER // CREATE PROCEDURE pattern() BEGIN DECLARE count INT; set count = 20;
END // DELIMITER ;
CALL pattern();
MySQL
WITH RECURSIVE numbers AS ( SELECT 20 AS n UNION ALL SELECT n - 1 FROM numbers WHERE n > 1 ) SELECT REPEAT('* ', n) AS pattern FROM numbers;
declare @pointer int set @pointer = 20 while (@pointer <> 0) begin select(replicate('* ', @pointer)) set @pointer = @pointer-1 end