0

How to draw stars in R?

You need to create a function that takes a number X as its parameter and outputs X stars using the asterisk symbol *. Sample Input 4 Sample Output [1] "*" [1] "*" [1] "*" [1] "*"

1st Dec 2021, 4:15 PM
Nitesh
3 odpowiedzi
+ 3
Use loop to print *
1st Dec 2021, 4:23 PM
A͢J
A͢J - avatar
0
x <- readLines('stdin') x <- as.integer(x[1]) #define the function stars<- function(x) { for (i in 1:x) print('*') } stars(x)
4th May 2022, 2:43 AM
Asmaa Nasr
0
#Create a function that takes a number X as its parameter and outputs X stars using the asterisk symbol astric <- function(x){ y<-as.integer(0) while (y!=x){ print("*") y<-y+1 } } astric(5)
17th Oct 2022, 8:33 AM
Yash Mishra
Yash Mishra - avatar