Computer Science, asked by amansharma17, 1 year ago

write a visual basic program to print your scbool name 10 times

Answers

Answered by sushmita
8
.....


So, I've been stuck in a while in this exercise and decided to make a thread using the answers I've found at the trends.


Does anyone knows how to solve it only using what was teached during the lessons?
I'm contacting Sasha for some help, anyway.
Looks like the trick to work with strings in loop is to turn your variable into the letter "i", wich works just like a number (wich I suppose is related to imaginary numbers).
But how we do that?


1 - Declare your variable before the loop

2 - Set the loop using the letter "i" instead of your variable. I don't know how it works, but the program understands that "i" is your variable.

3 - Set the "start" part to i = 0, since we want the loop to begin from the very first time that the variable is printed.

4 - Set the "stop" part to i <= 10, since we want it to stop at the tenth repetition.

5 - Set the last part to "i = i + 1", by doing so, the program adds a "counter" to your variable each times it does a loop, so it will know when to stop working.

Note: you can use "i++" instead of "i = i + 1", it's the same thing.
I'll put the code below using my name, just in case. Good luck!
// for (start; stop; how much to change each time)
var counter = "Stennio";
for (var i = 0; i <= 10; i = i + 1)
{
// Everything in the code block starting with '{' and
// ending with '}' will run once each time through the loop
console.log(counter);
} How to print your name ten times [solved]
Similar questions