Connect to

facebook google Email you tube you tube you tube
Theme images by MichaelJay. Powered by Blogger.

Projects

7.3.17

How To Create a Loading Screen in C++


Let us Learn how to create a loading Screen in C++.

Firstly I would like to tell you that it works on simple and logical loops.
Also the outputs like : 
  • Creating Temporary files
  • Accessing Main Memory
  • Accessing Cache
are also based on the counter in these loops.

So here is the Source Code:

#include<iostream.h>
#include<conio.h>
#include<dos.h>

 void main()
 {
   clrscr();
     for(int i=1;i<=50;i++)
      { clrscr();
 cout<<"\n\n\n\n\t\t\t\t   Loading "<<'\n'<<'\t'<<'\t';
for(int j=1;j<=i;j++)
 cout<<"²";
 cout<<"\n\n\t "<<2*i<<"%";
if( i > 1 && i < 20)
 cout<<"\n\n\tCreating Temporary files";
else if( i > 20 && i<40)
 cout<<"\n\n\tAccessing Main Memory";
else if(i >40 && i<48)
 cout<<"\n\n\tAccessing Cache";
else cout<<"\n\n\tComplete. Press Enter to Continue ";
 delay(150 - i*3);
      }
 getch();
 }
So basically there are 2 loops, the outer and the inner.
The outer loop starts from 1 goes till 50. the reason for taking the end point as 50 is that in the inner loop the counter has been used to determine the % loaded and the variable is multiplied by 2.
The delay function is used so as to make the loading screen look realistic by making it faster as the loading % increases. The formula derived in it is based on the output statement being used ie cout<<"ASCII 219";. You can do it by pressing and holding the left Ctrl key an typing 219 and leaving the key.


OUTPUT :



5 comments:
Write comments
  1. On code blocks don't working

    ReplyDelete
    Replies
    1. can you mail me the code file at r.sachdev1111@gmail.com

      Delete
  2. delay is not declared, how can it be working?

    ReplyDelete
    Replies
    1. Make sure that you have included dos.h

      Delete
    2. i did it.. but, its still not declared.
      i wrote it on DevC++

      Delete

Interested in our works and services?
Get more of our update !