Write a function, called dots, that prints a number of dots to the console using
ID: 3558024 • Letter: W
Question
Write a function, called dots, that prints a number of dots to the console using a for loop that counts down. The number of dots to print should be passed as an input parameter in the function call. Write a function, called dashes, that prints a number of dash characters to the console using a for loop that counts up. The number of dashes to print should be passed as an input parameter to the function. Write a function, called sendSOS that prints out three dots followed by three dashes followed by three dots again. Use the other two functions to print the dots and dashes. Print a newline or use endl to finish the line after printing the dots and dashes. Write a function to stall for time, called waitSeconds() that takes an integer for the number of seconds to wait. In Windows, include and then use the Sleep(msec) fiinction. On a Mac, include and use the sleep(sec) function. Make sure that the function waits for 5 seconds when called with an argument of 5 (not 5000). Write a fiinction c alled triangle() that takes an integer argument for the height of the triangle. Call the dots function, created earlier, to print the dots. When working the spaces function should print the following, when given the number 5: Write another function called slow'Triangle() that produces the same output as the previous function, but does not call any other functions (except the system sleep function). It should prints the same triangle, but very slowly, waiting a second before printing each dot. This will require a loop within a loop (instead of calling the dots function)! Write a function called distressCall() that takes no arguments and loops forever, calling sendSOS, then calling waitSeconds(l) and then repeating. In your main, call this function last, since it will never return. When testing your program, you can "interrupt" the program, which will otherwise run forever, by typing Ctrl-C.Explanation / Answer
// Requirements.cpp
#include <iostream>
#include <unistd.h>
//#include <windows.h>
void dots(int a);
void dashs(int a);
void sendSOS();
void waitSeconds(int a);
void Traingle(int a);
void slowTraingle(int a);
void distressCall();
using namespace std;
int main()
{
int input;
cout << "Enter input Value" << endl;
cin>>input;
cout<<"Dots count"<<endl;
dots(input);
cout<<"Dashs count"<<endl;
dashs(input);
sendSOS();
//waitSeconds(10);
Traingle(5);
slowTraingle(5);
distressCall();
return 0;
}
void dots(int a)
{
for(int i = a; i > 0; i--)
{
cout<<"* ";
}
cout<<endl;
}
void dashs(int a)
{
for(int i = a; i > 0; i--)
{
cout<<"- ";
}
cout<<endl;
}
void sendSOS()
{
cout<<"send SOS"<<endl;
dots(3);
dashs(3);
dots(3);
}
void waitSeconds(int a)
{
sleep(a);
}
void Traingle(int a)
{
cout<<"Traingle "<<endl;
for(int i = 1; i <= a; i++)
{
for(int j = 1; j <= i; j++ )
{
cout<<"* ";
}
cout<<endl;
}
}
void slowTraingle(int a)
{
cout<<"Slow Traingle "<<endl;
for(int i = 1; i <= a; i++)
{
for(int j = 1; j <= i; j++ )
{
cout<<"* ";
}
sleep(5);
cout<<endl;
}
}
void distressCall()
{
while(1)
{
sendSOS();
waitSeconds(1);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.