Archive for 2014-01-26

C++ program to do linear search in Array



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

void main()
{
 clrscr();
 int a[20],n,x,i,flag=0;
 cout<<"How many Elements?";
 cin>>n;
 cout<<"\nEnter Elements of the Array\n";

 for(i=0;i<n;++i)
  cin>>a[i];
 cout<<"\nEnter Element to search:";
 cin>>x;

 for(i=0;i<n;++i)
 {
  if(a[i]==x)
  {
   flag=1;
   break;
  }
 }

 if(flag)
  cout<<"\nElement is Found at position "<<i+1;
 else
  cout<<"\nElement not found";
 getch();
}
Posted by Unknown

C++ program to create a loading bar




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

void main()
{
int x=170,i,gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"c:\\tc\\bgi");
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(170,180,"LOADING,PLEASE WAIT");

for(i=0;i<300;++i)
{
delay(30);
line(x,200,x,220);
x++;
}
getch();
closegraph();
}

Posted by Unknown

How to Format an Unformattable Pendrive













Sometimes when you format your pendrive an error message is shown. This error is 

shown because your pendrive is affected by viruses. You try hard to format your pendrive but you fail in doing so. In this post i am telling you a trick by which you can format an unformatable pendrive easily. I use this method most of the time on my computer.

Instructions to format a Pendrive

1. Insert you pendrive in the usb port.

2. Now open run from the start menu and type cmd and hit enter.

3. A black screen will open. Now Write format and your drive letter (example: format h:) and pressenter, as shown in above image.

4. Your device is ready to format now press enter.

5. Now pendrive is formated, label your pendrive by a name that you like and press enter.
Posted by Unknown

C++ Program to Print Numbers From 1 to n Without Using Loops, Recursion or Go to Statement




#include<iostream>


using namespace std;

class Num
{
    public:
    static int i;
    Num()
    {
        cout<<i++<<" ";
    }
};

int Num::i=1;

int main()
{
    int n;
    cout<<"Enter value on n:";
    cin>>n;
    Num obj[n];
    return 0;
}
Posted by Unknown

© Information Technology