icon




logo




pre-paid card system

d card system

#include"stdio.h"

#include"conio.h"

int main(void)


{


int n,pcn=12345;


printf("Enter your pre-paid card number : ");


scanf("%d",&n);


if(n==pcn)


{


printf("your balance is : 300 BDT\n\n");


}


else if(n!=pcn)


{


printf("Enter your pre-paid card number Again : ");


scanf("%d",&n);
if(n==pcn)
{
printf("your balance is : 300 BDT\n\n");


}


if(n!=pcn)


{
printf("Enter your pre-paid card number Again : ");


scanf("%d",&n);
if(n==pcn)
{
printf("your balance is : 300 BDT\n\n");


}


else
{
printf("\nyour card number is invalid!!!!\n\nYou can insert card number After 6 Hours\n\n");


}


}


}


return 0;


}




student class tests

#include"stdio.h"
#include"conio.h"

void main()
{
int marks[40][4];
float avg_mrk[4];
int sum,min_mrk;

printf("Enter class test marks: \n");

for(int i=0;i<40;++i)
{
printf("serial No %d :\n",i+1);
for(int j=0;j<4;j++)
{
scanf("%d",&marks[i][j]);
}
sum=0;
min_mrk=marks[i][0];
for(j=0;j<4;j++)
{
sum=sum+marks[i][j];
if(min_mrk>marks[i][j])
min_mrk=marks[i][j];
}
avg_mrk[i]=float(sum-min_mrk)/3;
}
printf("Average marks : \n");
for(i=0;i<40;i++)
{
printf("serial No %d :\t",i+1);
printf("%.2f: \n ",avg_mrk[i]);
}


}

/* OUTPUT
Enter class test marks:
serial No 1 :
17 18 19 17
serial No 2 :
18 18 19 17
serial No 3 :
18 16 15 13
serial No 4 :
10 08 19 20
..........
serial No 40 :
18 18 19 17
Average marks :
serial No 1 : 18.00:
serial No 2 : 18.33:
serial No 3 : 16.33:
serial No 4 : 16.33:
..................
serial No 40 : 18.33:




*/

Arrange in link list

#include"stdio.h"
#include"iostream.h>
#include"conio.h"
struct node
{
int data;
node *next;
};
class linklist
{
node *list,*nptr,*tptr;
public:
linklist()
{
list=NULL;
}
void newnode(int item);
void link();
void showdata();
void sort(int item);
};
void linklist::newnode(int item)
{
nptr =new(node);
nptr->data=item;
nptr->next=NULL;
//link();
}
void linklist::link()
{
if(list==NULL)
{
list=nptr;
tptr=nptr;
}
else
{
tptr->next=nptr;
tptr=nptr;
}
}

void linklist::showdata()
{
node *curptr;
curptr=list;
while(curptr !=NULL)
{
cout<<" "<data;
curptr=curptr->next;
}
//cout<<" "<data;
}
void linklist::sort(int item)
{
node *pptr,*fptr;
pptr=list;
while(pptr !=NULL)
{
fptr=pptr->next;
while(fptr !=NULL)
{
if(pptr->data>fptr->data)
{
int temp;
temp=pptr->data;
pptr->data=fptr->data;
fptr->data=temp;
}
fptr=fptr->next;
}
pptr=pptr->next;

}
}

int main()
{
int n,d;
linklist mylist;
cout<<"\n How many nodes you have ?\t";
cin>>n;
cout<<"\n Enter data for nodes :";
for(int i=0;i {
cin>>d;
mylist.newnode(d);
mylist.link();
}
cout<<"data in the list :";
mylist.showdata();
//mylist.sort();
//char ans;
/* cout<<"\nDo you want to sort the list ?(y for yes )\t";
cin>>ans;
if(ans=='y'|| ans=='Y')
{
//int x;
//cout<<"\n\n Enter the node value to be deleted: ";
//cin>>x;*/
mylist.sort(d);

cout<<"\n\nsort Data in the list: \t";
mylist.showdata();
cout<<"\n";




return 0;
}

double_link_list

#include"stdio.h"
#include"iostream.h"
#include"conio.h"
struct node
{
node *pre;
int data;
node *next;
};
class linklist
{
node *list,*nptr,*tptr;
public:
linklist()
{
list=NULL;
}
void newnode (int item);
void link(); //constructed
void showdata();
};
void linklist::newnode(int item)
{
nptr=new(node);
nptr->pre=NULL;
nptr->data=item;
nptr->next=NULL;
link();
}
void linklist::link()
{
if(list==NULL)
{
list=nptr;
tptr=nptr;
}
else
{
tptr->next=nptr;
nptr->pre=tptr;
tptr=nptr;
}
}
void linklist::showdata()
{
node *curptr;
curptr =list;
while(curptr->next !=NULL)
{
cout<<" " <data;
curptr=curptr->next;
}
cout<<" " <data;
//curptr=curptr-next
}


int main()
{
int n,d;


linklist mylist;

cout<<"how many node do you have?\t";
cin>>n;
cout<<"Enter data:"<<"\n";
for(int i=0;i {
cin>>d;
mylist.newnode(d);
}
cout<<"data in the list:";
mylist.showdata();


return 0;


}

deleting in link list

#include 'stdio.h'
#include 'iostream.h'
#include 'conio.h"
struct node
{
int data;
node *next;
};
class linklist
{
node *list,*nptr,*tptr;
public:
linklist()
{
list=NULL;
}
void newnode(int item);
void link();
void showdata();
void deletion(int item);
};
void linklist::newnode(int item)
{
nptr =new(node);
nptr->data=item;
nptr->next=NULL;
//link();
}
void linklist::link()
{
if(list==NULL)
{
list=nptr;
tptr=nptr;
}
else
{
tptr->next=nptr;
tptr=nptr;
}
}

void linklist::showdata()
{
node *curptr;
curptr=list;
while(curptr !=NULL)
{
cout<<" "<data;
curptr=curptr->next;
}
//cout<<" "<data;
}
void linklist::deletion(int item)
{
node *pptr;
tptr=list;
if(list->data!=item)
{
while(tptr->data!=item)
{
if(tptr==NULL)
{
cout<<"\nItem is not found in the list\n";
break;
}
pptr=tptr;
tptr=tptr->next;
}
pptr->next=tptr->next;
delete(tptr);
}
else
{
list =list->next;
delete(tptr);
}

}

int main()
{
int n,d;
linklist mylist;
cout<<"\n How many nodes you have ?\t";
cin>>n;
cout<<"\n Enter data for nodes :";
for(int i=0;i {
cin>>d;
mylist.newnode(d);
mylist.link();
}
cout<<"data in the list :";
mylist.showdata();

char ans;
cout<<"\nDo you want to delete a node ?(y for yes )\t";
cin>>ans;
if(ans=='y'|| ans=='Y')
{
int x;
cout<<"\n\n Enter the node value to be deleted: ";
cin>>x;
mylist.deletion(x);
cout< cout<<"\n\nUpdated Data in the list: \t";
mylist.showdata();
cout<<"\n";
}



return 0;
}

search link list

#include"stdio.h"
#include"iostream.h"
#include"conio.h"
struct node
{
int data;
node *next;
};
class linklist
{
node *list,*nptr,*tptr;
public:
linklist()
{
list=NULL;
}
void newnode(int item);
void link();
void showdata();
void search(int item);
};
void linklist::newnode(int item)
{
nptr =new(node);
nptr->data=item;
nptr->next=NULL;
//link();
}
void linklist::link()
{
if(list==NULL)
{
list=nptr;
tptr=nptr;
}
else
{
tptr->next=nptr;
tptr=nptr;
}
}
void linklist::search(int item)
{
tptr=list;
while(tptr !=NULL)
{
if(tptr->data==item)
{
cout<<"Data Found !\n"; break; } tptr=tptr->next;
if(tptr==NULL)
cout<<"Data is not in the list\n"; } } void linklist::showdata() { node *curptr; curptr=list; while(curptr !=NULL) { cout<<" "<data;
curptr=curptr->next;
}
//cout<<" "<data;
}

int main()
{
int n,d;
linklist mylist;
cout<<"\n How many nodes you have ?\t"; cin>>n;
cout<<"\n Enter data for nodes :"; for(int i=0;i>d;
mylist.newnode(d);
mylist.link();
}
cout<<"data in the list :"; mylist.showdata(); int item; cout<<"\n Enter the data to be found: "; cin>>item;
cout<<"\n Search Result: ";
mylist.search(item);



return 0;
}
http://www.google.com.bd/search?q=search+link+list&pov=100366784536684831572&usg=__l-bqafYvVrd4O1wVprEd-7Upvu0=&hl=en

Link list creation

#include"stdio.h"
#include"iostream.h"
#include"conio.h"
struct node
{
int data;
node *next;
};
class linklist
{
node *list,*nptr,*tptr;
public:
linklist()
{
list=NULL;
}
void newnode(int item);
void link();
void showdata();
};
void linklist::newnode(int item)
{
nptr =new(node);
nptr->data=item;
nptr->next=NULL;
//link();
}
void linklist::link()
{
if(list==NULL)
{
list=nptr;
tptr=nptr;
}
else
{
tptr->next=nptr;
tptr=nptr;
}
}
void linklist::showdata()
{
node *curptr;
curptr=list;
while(curptr !=NULL)
{
cout<<" "<data;
curptr=curptr->next;
}
//cout<<" "<data;
}

int main()
{
int n,d;
linklist mylist;
cout<<"\n How many nodes you have ?\t";
cin>>n;
cout<<"\n Enter data for nodes :";
for(int i=0;i {
cin>>d;
mylist.newnode(d);
mylist.link();
}
cout<<"data in the list : ";
mylist.showdata();
cout<<"\n";

// getch();
return 0;
}

largest Element in the array

Back
#include "stdio.h"
#include "conio.h"
void main()
{
int a[15],lar,I,n,odd,even;

printf("Enter the size of the array\n");
scanf("%d",&n);
printf("Enter the elements of the array\n");
for(I=0;Ilar)

lar=a[I];

}
printf("\n%d is largest Element in the array\n\n",lar);

for(I=0;I
{
if(a[I]%2!=0)
{
odd=a[I];
printf("%d : ",odd);
}
}
printf("are odd number \n\n");

for(I=0;I
{
if(a[I]%2==0)
{
even=a[I];
printf("%d : ",I);
}
}
printf("Even number position \n\n");

for(I=0;I
{
if(a[I]%2==0)
{
even=a[I];
printf("%d : ",even);
}
}
printf("are even number \n\n");


}



Array

Data Structure

leap year in c

include stdio.h
int main(void)
{
int n;
printf("enter year (like this 2005) :");
scanf("%d",&n);
if(n%4==0 && n%100 !=0 || n%400==0)
printf("%d is leap year \n",n);
else
printf("%d is not leap year\n ",n);
return 0;
}
There was an error in this gadget

Followers

About Me

Dhaka, Dhaka, Bangladesh
..