Answer :
Answer:
The programming language is not stated; I'll answer this question using C++ programming language;
Another thing to note is that; the sample run is quite different from the illustration in the question; So, I'll assume the program to print "Youth is a wonderful thing. Enjoy.", if and only if age is less than or equal to 21
The program is as follows
#include<iostream>
using namespace std;
int main() {
int age;
int i =1;
start:
cout<<"Sample run: "<<i<<endl;
cout<<"You entered: ";
cin>>age;
if(age<=21) {
cout<<"Youth is a wonderful thing. Enjoy."<<endl; }
cout<<"Age is a state of mind"<<endl;
i++;
cout<<"Run another? (Y/N): ";
char resp;
cin>>resp;
if(resp=='Y')
{
goto start;
}
return 0;
}
Explanation:
Line 4 of the program declares age as integer
Line 5 declares and initializes a counter variable, i to 1
Line 6 is used as a label to start another sample run
Line 7 prints the Sample run in the following format;
Sample run 1, during the first iteration
Sample run 2, during the second iteration; and so on...
Line 8 prompts the user to supply details for age
Line 9 stores user input in variable age
Line 10 checks if age is less than or equal to 21
If true, the program outputs Youth is a wonderful thing. Enjoy., then it continues execution on line 23
Otherwise, it jumps directly to line 23 and outputs Age is a state of mind
The counter is increased by 1 on line 24
The program asks if the user wants to take another sample run on line 25
The response is saved in a char variable on line 27
If the user response is Y, the program goes to the label on line 6 to begin another iteration
Otherwise, the program is terminated.
See attachment for source file