Friday, May 03, 2013

program to get ip address in C++


#include<stdlib.h>
main()
{
   system("C:\\Windows\\System32\\ipconfig");
   system("pause");
   return 0;
}

searching in linked list in C++


#include <iostream>
using namespace std;
struct node{
int data;
node *link;
};
int main(){
node *start,*temp,*prev;
int lim,item;
cout<<"enter the linked list limited :";
cin>>lim;
cout<<"ente item to find :";
cin>>item;
start=new node;
prev=start;
cout<<"enter char for location 1 :";
cin>>start->data;
start->link=NULL;
for(int i=2;i<=lim;i++){
temp=new node;
cout<<"enter char for location"<<i<<" : ";
cin>>temp->data;
temp->link=NULL;
prev->link=temp;
prev=temp;                    
}
node* ptr;
ptr=start;
while(ptr!=NULL)
{  if (item=ptr->data) {
cout<<"Item is found location of the item is "<<ptr->link;
return 0;
}
ptr=ptr->link;
}
}

General Linked list integer program in C++


#include <iostream>
using namespace std;
struct node{
int data;
node *link;
};
int main(){
node *start,*temp,*prev;
int lim;
cout<<"enter the linked list limited :";
cin>>lim;
start=new node;
prev=start;
cout<<"enter char for location 1 :";
cin>>start->data;
start->link=NULL;
for(int i=2;i<=lim;i++){
temp=new node;
cout<<"enter char for location"<<i<<" : ";
cin>>temp->data;
temp->link=NULL;
prev->link=temp;
prev=temp;                    
}
node* ptr;
ptr=start;
while(ptr!=NULL)
{  cout<<ptr->data<<endl;
      ptr=ptr->link;
}
}

General Linked list character program in C++


#include <iostream>
using namespace std;
struct node{
char data;
node *link;
};
int main(){
node *start,*temp,*prev;
int lim;
cout<<"enter the linked list limited :";
cin>>lim;
start=new node;
prev=start;
cout<<"enter char for location 1 :";
cin>>start->data;
start->link=NULL;
for(int i=2;i<=lim;i++){
temp=new node;
cout<<"enter char for location "<<i<<" : ";
cin>>temp->data;
temp->link=NULL;
prev->link=temp;
prev=temp;                    
}
node* ptr;
ptr=start;
while(ptr!=NULL)
{  cout<<ptr->data<<endl;
      ptr=ptr->link;
}
}


Friday, April 26, 2013

number in pyramid before space in C++


#include <iostream>
using namespace std;
int main(){

int a;
int b;
cout<<"enter the number pyramid limit:";
cin>>b;
int nPyramid = 1;

int k=b;
for(a=1;a<=k;a++)
{


for(int i=0;i<b;i++)
{                   //for the spaces
cout<<nPyramid<<"\t";

nPyramid++;         //Increase the pyramid value by 1
}

nPyramid--; //Remove this line and see the effect
cout<<endl; //Next line
for(int i=1;i<=a;i++)
{ cout<<"\t";
}
b--;
}
}
output:-

number in pyramid space after in C++


#include <iostream>
using namespace std;
int main(){
int a;
int b;
cout<<"enter the number pyramid limit:";
cin>>b;
int nPyramid = 1;
int k=b;
for(a=1;a<=k;a++)
{
for(int i=0;i<b;i++)
{                   //for the spaces
cout<<"\t"<<nPyramid;

nPyramid++;         //Increase the pyramid value by 1
}

nPyramid--;                 //Remove this line and see the effect
cout<<endl;               //Next line
b--;
}
}

Wednesday, March 20, 2013

displayind odd numbers upto 100 in C++

#include <iostream.h>
#include <conio.h>
int main()
{
int i;
for(int i=1;i <= 100 ;i++)
{

 if(i%2==1)
cout<<i<<endl;
}
getch();
return 0;

}