Question

Please answer the following question. Thank you! For this assignment you must write the following functions...

Please answer the following question. Thank you!

For this assignment you must write the following functions in Scheme:


1.2 Write a function called countdown that takes a positive integer and uses a do expression to display a sequence of numbers counting down to 1, each on its own line, then displaying the string "Blastoff!".
> (countdown 5)

5

4

3

2

1

Blastoff!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#code in scheme

(define (countdown n)
(if(= n 0)
display("Blastoff!"))
(else (display n) (countdown (- n 1))))

the call (countdown 5)

#code in c language

#include<stdio.h>
void countdown(int n)
{
   if(n==0)
   {
       printf("Blastoff!");
   }
   else
   {
       printf("%d\n",n);
       countdown(n-1);
   }
}
int main()
{
   int num;
   printf("enter the number\n");
   scanf("%d",&num);
   countdown(num);
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Please answer the following question. Thank you! For this assignment you must write the following functions...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this interactive assignment, you will continue to utilize loops and functions and write a Python...

    For this interactive assignment, you will continue to utilize loops and functions and write a Python program that asks the user for an integer (number) greater than 1. Once the user enters an integer, it should then allow the user to CHOOSE between the following two options: If 1 is entered, a countdown from that number to zero is printed. If 2 is entered, the factorial of the number is printed. If the user inputs a number less than 1,...

  • Given the incomplete program below, write two functions, one called integer and another called decimal. You...

    Given the incomplete program below, write two functions, one called integer and another called decimal. You can use following incomplete program. Your assignment is to supply the necessary missing code: #include #include using namespace std; int integer (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER (A DOUBLE) //WRITE HERE THE CODE TO EXTRACT THE INTEGER AND RETURN IT } double decimal (….) { //REPLACE THE … WITH THE REQUIRED PARAMETER //WRITE HERE THE CODE TO EXTRACT THE DECIMAL PORTION,...

  • Please help me to do my assignment it should be python. Thank you Write a menu-driven...

    Please help me to do my assignment it should be python. Thank you Write a menu-driven program for Food Court. (You need to use functions!) Display the food menu to a user (Just show the 5 options' names and prices - No need to show the Combos or the details!) Ask the user what he/she wants and how many of it. (Check the user inputs) AND Use strip() function to strip your inputs. Keep asking the user until he/she chooses...

  • Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a...

    Please write the code in a text editor and explain thank you! 1. LINKED-LIST: Implement a function that finds if a given value is present in a linked-list. The function should look for the first occurrence of the value and return a true if the value is present or false if it is not present in the list. Your code should work on a linked-list of any size including an empty list. Your solution must be RECURSIVE. Non-recursive solutions will...

  • Please help with this exercises in c++ language Thanks Lab Activity #5-More Functions/FILES Exercise# Write a...

    Please help with this exercises in c++ language Thanks Lab Activity #5-More Functions/FILES Exercise# Write a program that will generate 1000 random numbers (all of which are between 10 and 20) and then write all of the even numbers (from those 1000 numbers) to a new file called "myEvenRandoms.txt Exercise #2 (DO ONLY IF WE COVERED ARRAYS OF CHARACT Write a program that will ask the user to enter a sentence. Then create a separate function that will count the...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Either know this is just a homework assignment please if you dont know the answer or...

    Either know this is just a homework assignment please if you dont know the answer or if you dont check that its right please dont work on this serious answers only please and thank you and no java only visual studio c++ please. Q1 : Classes and Objects 1. Create a class definition for an object called Account. Add a constructor and destructor to it. 2. Add 2 internal data member of char or string type which should be named...

  • Functions can return a string, not just an int or a float. Write a function called...

    Functions can return a string, not just an int or a float. Write a function called everOrOdd which takes an integer parameter and returns either "Even" or "Odd" based on the value passed. In main, prompt the user for a number, called num, then pass num to evenOrOdd and display the returned value on the screen. Keep doing this until the user enters a zero. Use the following run as an example: Enter a number: 11 Odd Enter a number:...

  • Objective To program using the functional programming paradigm Assignment: Write the following functions using Scheme (or...

    Objective To program using the functional programming paradigm Assignment: Write the following functions using Scheme (or LISP if you prefer) . A function (binomial N k) that returns the binomial coefficients C(N, k), defined recursively as: C(NO) = 1, C(N, N) = 1, and, for 0<k < N E(N, k) = C(N-1, k) + C(N-1, k-1) 2. A function (mod N M) that returns the modulus remainder when dividing N by M 3. A function (binaryToDecimal b) that takes a...

  • write a Matlab program ( solve the three questions). please use array and create your own...

    write a Matlab program ( solve the three questions). please use array and create your own function to check primality Question 1 : [10 points) Write a MATLAB program that will store all the first 1000 prime numbers in an array variable named arr_of_primes. Please note that a prime number is a positive integer that is bigger than or equal to 2 which is divisible only by 1 and itself. Examples of the first 8 primes are: 2, 3, 5,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT