Tuesday, April 2, 2013

How To Create Time Delay in Your C++ Program

By Unknown   Posted at  2:30 AM   C++ Programming No comments

//Sometimes we Want to Print our Name or any Statement on Screen word by Word
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
void mydelay(int sec);  //Declaring Delay Function
//sec will b parameter        
void mydelay(int sec)            // Defining Delay Function
{
     int w,e;
     for(w=0; w<sec; w++)    // Making Nested Loop for More Time Consuming
     {
              for(e=0; e<1000000; e++)  // 1000000 for making time(printing) speed slow
              {
              }
     }
 }

int main()       // for Turbo Cplus plus write "void main( )"
{
   
    char name[] = "My Name is Matee ur Rehman....";
    char web[] = "www.gcuftimes.blogspot.com";
    int t=0;
    int get = strlen(name); // taking Length of String using "strlen( )" function
    int ln=strlen(web);
    cout << endl;
    cout<<"\n\t";
    while(t!=get)
    {                  
                        mydelay(35);
                        cout << name[t];
                        t++;
           }
           cout<<"\n\t";
           int i=0;
           while(i!=ln)
    {                  
                        mydelay(20);  // 20 will be passed to sec variable
                        cout << web[i];
                        i++;
           }
           cout<<endl;
    cin.get();           
    system("pause");
}
// for implementing it in T.C remove 4th and  last line
                                                 // THANX
                                                  // Matee ur Rehman

About the Author

Nulla sagittis convallis arcu. Sed sed nunc. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.
View all posts by: BT9

0 comments:

Back to top ↑
Connect with Us

    What's Trending in Videoism

    Total Pageviews

    Copy of any Post is Not Allowed. All Rights Reserved with Matee ur Rehman (Author). Powered by Blogger.

    Advertisements

    Follow us on FaceBook

What they says

© 2013 GC Study Timez. WP Daily Quranand Hadith Converted by Matee Gojra
Blogger templates. Proudly Powered by Blogger.