Q:

C++ program to demonstrate example of delay() function

0

C++ program to demonstrate example of delay() function

delay(unsigned int milliseconds)

delay() function is used to hold the program's execution for given number of milliseconds, it is declared in dos.h header file.

Syntax:

void delay(unsigned int milliseconds)

Here, void is the return type of the function that means delay() will not return any value, and unsigned int milliseconds is the number of milliseconds to hold the program, delay() function accept unsigned int type of value.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

This program is compiled and run on TurboC3 compiler, in this program: there are delays of 1000 milliseconds (1 second) between printing of "www.", "nerdutella." and ".com" then another delay to reach to getch() statement.

After that you will have to press any key to reach return 0; and program’s control will be returned (exit from program).

 

#include <iostream.h>
#include <dos.h> //for delay
#include <conio.h> //for getch()

int main()
{
	clrscr();
	
	cout<<" www.";
	delay(1000);
	cout<<"nerdutella";
	delay(1000);
	cout<<".com"<<endl;
	delay(1000);
	
	getch();
	return 0;
}

Output

www.nerdutella.com

There are 1 second (1000 milliseconds) delays between printing of "www.", "nerdutella." and ".com"

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Most popular and Searched C++ solved programs with Explanation and Output

Similar questions


need a help?


find thousands of online teachers now
Example of declaring and printing different consta... >>
<< C++ program to print your name randomly on the scr...