Follow us on FB

Showing posts with label Cpp. Show all posts
Showing posts with label Cpp. Show all posts

Sunday, March 2, 2014

how to create time delay in C++

Time delay in C++ means :
                                     Which you enter or gives input using Turbo C++  or dev , after compiling shows result as :
             
             Print Single letter then delay of few seconds and again show next letter of the word .
              The Uper Step do again and again till the string or pragraph end.
This is Very Simple and Easy mathod to create a time delay in C++ .
Every Step is explaned completely below .
Advantage :
There are few advantage of creating time delay in C++ as :
You can create introduction view in a uniqe style .

Creating game this is a very charming look .
After compiling print your result slow .
And many others .....................

Code of the Program :

#include <iostream>
#include <conio.h>
#include <string.h>
using namespace std;

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 Haseeb Jaffur....";
    char web[] = "www.placeoflearn.blogspot.com and www.greatmasti4u.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(55);
                        cout << name[t];
                        t++;
           }
           cout<<"\n\t";
           int i=0;
           while(i!=ln)
    {                  
                        mydelay(45);  // 45 will be passed to sec variable
                        cout << web[i];
                        i++;
           }
           cout<<endl;
    cin.get();           
    return 0;
}
// for implementing it in T.C remove 4th and  last line
                                                 // THANKS For Visiting ...
                                                  // by Haseeb Jaffur


If you face any Problem show in comment , i am try my best to resolve this problem .......

Saturday, March 1, 2014

Count Words in a String using dev/C++

Now i am trying to count the No of words in a string  using C++ or dev .  You can use this code to count the words . which you enter . this is a simple and easy article , which would help you to learn C++ complicated coding with explanations . 
I am write every code line explanation in front of that line.
after coding running you can get out put as............


Code for this program is below . but ..........
this Code in dev , if you use Turbo C++ then do some Changing...
remove using namespace std;
remove int main  and use void main in turbo C++ .
remove return and use getch() int Turboo C++ .

Code of Programe :

#include <iostream>
#include <conio.h>             //for getche()
using namespace std;
enum itsaWord { NO, YES };     //NO=0, YES=1
int main()
{
itsaWord isWord = NO;       //YES when in a word,
//NO when in whitespace
char ch = 'a';              //character read from keyboard
int wordcount = 0;          //number of words read
cout << "Enter a phrase:\n";
do {
ch = getche();           //get character
if(ch==' ' || ch=='\r')  //if white space,
{
if( isWord == YES )   //and doing a word,
{                  //then it’s end of word
wordcount++;       //count the word
isWord = NO;       //reset flag
}
}                     //otherwise, it’s
else                     //normal character
if( isWord == NO )    //if start of word,
isWord = YES;      //then set flag
} while( ch != '\r' );   //quit on Enter key
cout <<endl<< "---Word count is " << wordcount << "---\n";

return 0;

}


If you feel any problem in program running then post in comment ,
i try my best to resolve this problem ,,,,,,,,,,,
Thanks for Visiting.

Thursday, June 27, 2013

how we minus the distances

#include<iostream>
using namespace std;
     class Distance
                        {
      private:
              int feet;
              float inches;
      public:
             Distance()
                        {
                       feet=0;
                       inches=0;
                       }

 

Copyright @ 2013 placeoflearn.