List of Data Conversion Functions In C

List of Data Conversion Functions In C


atof = Converts string to float
atoi=Converts string to int
atol=Converts string to long
ecvt=Converts double to string
fcvt=Converts double to string
gcvt=Converts double to string
itoa=Converts int to string
ltoa=Converts long to string
strtod=Converts string to double
strtol==Converts string to long integer
strtoul=Converts string to an unsigned long integer
ultoa=Converts unsigned long to string

Related Links :

List of Arithmetic Functions In C

List of Arithmetic Functions In C


abs Returns the absolute value of an integer
cos Calculates cosine
cosh Calculates hyperbolic cosine
exp Raises the exponential e to the xth power
fabs Finds absolute value
floor Finds largest integer less than or equal to argument
fmod Finds floating-point remainder
hypot Calculates hypotenuse of right triangle
log Calculates natural logarithm
log10 Calculates base 10 logarithm
modf Breaks down argument into integer and fractional parts
pow Calculates a value raised to a power
sin Calculates sine
sinh Calculates hyperbolic sine
sqrt Finds square root
tan Calculates tangent
tanh Calculates hyperbolic tangent

Related Links :

Distinguish between library functions (Pre defined) and user defined functions.

Library Function User Defined Functions
  • LF(library functions) are Predefined functions.
  • UDF(user defined functions) are the function which r created by user as per his own requirements.
  • UDF are part of the program which compile runtime
  • LF are part of header file
    (such as MATH.h) which is called runtime.
  • In UDF the name of function id decided by user
  • in LF it is given by developers.
  • in UDF name of function can be changed any time
  • LF Name of function can't be
    changed.
Example : SIN, COS, Power Example : fibo, mergeme

Related Links :

Program to Create a 10 element array of integers and count the number of odd and even values in it.




/* Create a 10 element array of integers and
count the number of odd and even values in it. */

#include

int main(void)
{
int arr[10], i, odd, even;

printf("\nEnter ten integer values : ");
for(i = 0 ; i < 10; i++)
scanf("%d", &arr[i]);

for(odd = even = i = 0; i < 10; i++)
{
if(arr[i] % 2 == 0) even++;
else odd++;
}

printf("\nTotal even values is %d\nTotal odd values is %d", even, odd);

return 0;
}

Related Links :

Program to find out the highest and lowest marks obtained in a class of 10 students.



/* Write a program to find out the highest and lowest
marks obtained in a class of 10 students. */

#include

int main(void)
{
int marks[10], i, high, low;

for(i = 0 ; i < 10 ; i++)
{
printf("\nMarks %d :", i + 1);
scanf("%d", &marks[i]);
}

high = low = marks[0];

for(i = 0 ; i < 10 ; i++)
{
if(marks[i] > high) high = marks[i];
if(marks[i] < low) low = marks[i];
}

printf("\nHighest marks is %d\nLowest marks is %d", high, low);

return 0;
}

Related Links :

Program to show implementation of singly linkedlist



/* implementation of singly linkedlist */
#include
#include
#include "linklist.h"

void release(linkedlist *lp)
{
while(lp -> count > 0)
del(lp, lp -> count);
}

node **goto_node(linkedlist *lp, int pos)
{
node *n = lp -> base, **curr = &(lp -> base);
if(pos < 0 || pos > lp -> count)
return NULL;

while(pos > 0)
{
curr = &(n -> next);
n = n -> next;
pos--;
}
return curr;
}

int append(linkedlist *lp, char *data)
{
node **curr = goto_node(lp, lp -> count);
*curr = (node *) malloc(sizeof(node));
if(*curr == NULL)
return FALSE;

strcpy((*curr) -> name, data);
(*curr) -> next = NULL;
lp -> count++;
return TRUE;
}

int insert(linkedlist *lp, int pos, char *data)
{
node **curr = goto_node(lp, pos - 1), *tmp;
if(curr == NULL)
return FALSE;
tmp = *curr;
*curr = (node *) malloc(sizeof(node));
if(*curr == NULL)
return FALSE;

strcpy((*curr) -> name, data);
(*curr) -> next = tmp;
lp -> count++;
return TRUE;
}

int del(linkedlist *lp, int pos)
{
node **curr = goto_node(lp, pos - 1), *tmp;
if(curr == NULL)
return FALSE;
tmp = *curr;
free(*curr);
*curr = tmp -> next;
lp -> count--;
return TRUE;
}

void show(linkedlist *lp)
{
node *n = lp -> base;
while(n != NULL)
{
printf("\n%s", n -> name);
n = n -> next;
}
}

int main(void)
{
int choice, pos;
char value[80];
linkedlist l = { NULL, 0 };
do
{
printf("\n ** SINGLE LINKED LIST **");
printf("\n1. Add\n2. Insert\n3. Remove\n4. Show\n5. Exit\nOption [1 - 5] ? ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\nName :");
fflush(stdin);
gets(value);
if(!append(&l, value))
printf( "\nNode creation failed" );
else
printf( "\nNew node created successfully" );
break;
case 2:
printf("\nInsert position ? " );
scanf( "%d", &pos );
printf("\nEnter value :");
fflush(stdin);
gets(value);
if(!insert(&l, pos, value))
printf( "\nNode insertion failed" );
else
printf( "\nNode inserted successfully" );
break;
case 3:
printf("\nDelete position ? " );
scanf( "%d", &pos );
if(!del( &l, pos ))
printf( "\nNode removal failed" );
else
printf("\nNode removed successfully");
break;
case 4:
show(&l);
break;
case 5:
release(&l);
break;
}
}while(choice != 5);

return SUCCESS;
}

Related Links :

Program to create a 10 element array of integers and search for a value in it.



/* Write a program to create a 10 element array of
integers and search for a value in it. */

#include

int main(void)
{
int arr[10], i, val, n;

printf("\nEnter ten integer values : ");
for(i = 0 ; i < 10 ; i++ )
scanf("%d", &arr[i]);

printf("\nEnter value to search : ");
scanf("%d", &val);

/* Search the value in the array */
n = 0;
for(i = 0 ; i < 10 ; i++)
{
n++;
if(arr[i] == val)
break;
}
if(i == 10)
{
printf("\n%d not found in the array", val);
printf("\nNo of attempts = %d", n);
}
else
{
printf("\n%d found in the array", val);
printf("\nNo of attempts = %d", n);
}

return 0;
}




Related Links :

Program to Take input into a string and count the number of capital letters, small letters, digits and special symbols in it.



/* Take input into a string and count the number of capital letters,
small letters, digits and special symbols in it. */

#include

int main(void)
{
char str[80];
int x, cap, small, dig, sym;

printf("\nEnter a string : ");
gets(str);

x = cap = small = dig = sym = 0;

for( ; str[x] != '\0' ; x++)
{
if(str[x] >= 'A' && str[x] <= 'Z') cap++;
else if(str[x] >= 'a' && str[x] <= 'z') small++;
else if(str[x] >= '0' && str[x] <= '9') dig++;
else sym++;

}

printf("\nCapital letters %d\nSmall letters %d", cap, small);
printf("\nDigits %d\nSpecial symbols %d", dig, sym);

return 0;
}

Related Links :

Program to Find the absolute value of an integer taken as input.



/* Find the absolute value of an integer taken as input. */

#include

int main(void)
{
int num;

printf("\nEnter a number : ");
scanf("%d" ,&num);

if(num < 0)
{
printf("\nAbsolute value of %d is %d" ,num ,-num);
}
else
{
printf("\nAbsolute value of %d is %d" ,num ,num);
}


return 0;
}

Related Links :

Program to show BINARY, Octal & CONVERSION


#include
#include
int c,r,f,i[16],j,rw,cl;
void main(void)


{
int num,a;
char ch;
void bin(int);
void hex(int);
void oct(int);
do

{
j=15; rw=0; cl=3;
for(f=0;fr="no%2;" ans="
for(f=" rw="=" cl="cl+4;">


Related Links :

Program to show use of pointer with array in c.


main()
{
int *p, sum=0, i=0;
int x[5]={3,4,7,8,5};
clrscr();
p=x;
printf("Element Value Address\n\n");
while(i<5)
{
printf(" x[%d] %d %u\n",i,*p,p);
sum=sum+*p;
i++, p++;
}
printf("\nSum: %d",sum);
printf("\n&x[0]: %u",&x[0]);
printf("\np: %u",p);
getch();
}

Related Links :

Program to show working of pointers.


main()
{
int x, *p, y;
clrscr();
x=10;
p=&x;
y=*p;
printf("Value of X: %d\nValue of P: %u\nValue of Y: %d",x,p,y);
printf("\nAddress of X: %u\nAddress of P: %u\nAddress of Y: %u",&x,&p,&y);
*p=20;
printf("\nNow Value of X: %d and Y: %d",x,y);
getch();
}

Related Links :

Program to show properties & use of global varilabels.



#include
int func1(void);
int func2(void);
int func3(void);
int x;
main()
{
x=10;
printf(“x= %d\n”, x);
prinf(“x= %d\n”, func1());
prinf(“x= %d\n”, func2());

prinf(“x= %d\n”, func3());
getch();
}
func1(void)
{
x+=10;
}
int func2(void)
{
int x;
x=1;
return(x);
}
func3(void)
{
x=x+10;
}

Related Links :

program to calculate ratio of numbers by using user define function


#include
float ratio(int x, int y, int z);
int difference(int x, int y);
main()
{
int a, b, c;
scanf(“%d %d %d”, &a, &b, &c);
printf(“%f \n”, ratio(a,b,c));
getch();
}

float ratio(int x, int y, int z)
{
if(difference(y,z))
return(x/(y-z));
else
return(0.0);
}

int difference(int p, int q)
{
if(p!=q)
return(1);
else
return(0);
}

Related Links :

Program that uses a function to sort an array of integers


#include
void sort(int m, int x[]);
main()
{
int i;
int marks[5]={40, 90, 73, 81, 35};
clrscr();
printf(“Marks before sorting\n”);
for(i=0; i<5;>
printf(“%4d”, marks[i]);
printf(“\n\n”);
sort(5,marks);
printf(“Marks after sorting\n”);
for(i=0; i<5;>
printf(“%4d”, marks[i]);
printf(“\n”);
getch();
}
void sort(int m, int x[])
{
int i, j, temp;
for(i=1; i<=m-1; i++)
{
for(j=1;j<=m-1;j++)
{
if(x[j-1]>=x[j]
{
temp=x[j-1];
x[j-1]=x[j];
x[j]=temp;
}
}
}
}


Related Links :

a program using a single-subscripted variable to evaluate the Equational expressions

Write a program using a single-subscripted variable to evaluate the following expressions:

Total=i=1∑10Xi2

#include
main()
{
int i;
float x[10], value, total;
clrscr();
printf("Enter 10 Real Numbers\n");
for(i=0; i<10;i++)
{
scanf(“%f”, &value);
x[i]=value;
}
total=0.0;
for(i=0;i<10;i++)
total+=x[i]*x[i];
printf(“\¬¬n”);
for(i=0;i<10;i++)
printf(“x[%2d] = %5.2f\n”, i+1, x[i]);
printf(“\nTotal = %.2f\n”, total);
getch();
}


Related Links :

A program to determine the range of values and the average cost of a personal computer (P.C.) in the market.


#include
main()
{ int count=0;
float value, high, low, sum=0, average, range;
clrscr();
printf("Enter numbers in a line: input a NEGAATIVE number to end\n");

input:
scanf("%f",&value);
if(value<0)
goto output;
count+=1;
if(count==1)
high=low=value;
else if(value>high)
high=value;
else if(value
low=value;
sum+=value;
goto input;

output:

average=sum/count;
range=high-low;
printf(“\n\n”);
printf(“Total values: %d\n”, count);
printf("Highest-value: %f\n Lowest-value: %f\n”, high, low);
printf(“Range : %f\nAverage : %f\n”, range, average);
getch();
}

Related Links :

Program to calculate Salary & loan Issue structure of an employee

An employee can apply for a loan at the beginning of every six months but he will be sanctioned the amount according to the following company rules:

Rule 1: An employee cannot enjoy more than two loans at any point of time.

Rule 2: Maximum permissible total loan is limited and depends upon the category of the employee.




#include
#define MAXLOAN 50000
main()
{
long int loan1, loan2, loan3, sancloan, sum23;
clrscr();
printf("Enter the values of previous two loans:\n");
scanf("%ld %ld", &loan1, &loan2);
printf("\nEnter the value for new loan:\n");
scanf("%ld", &loan3);
sum23=loan2+loan3;
sancloan=(loan1>0) ? 0 : ((sum23>MAXLOAN) ? MAXLOAN-loan2 : loan3);
printf("\n\n");
printf("Previous loans pending:\n%ld %ld\n", loan1, loan2);
printf("Loan requested = %ld\n", loan3);
printf("Loan sanctioned = %ld\n", sancloan);
getch();
}

Related Links :

A program to create executable link list.

A program to create executable link list.




/* single link list */
#include
#include
#include
#include

struct node
{
int data;
struct node *next;
};

typedef struct node node;

node *start=NULL;
void display();
void insertend();
void insertbeg();
void delend();
void delbeg();
void insertmid();
void delmid();
void modify();
void main()
{
int a;
clrscr();
printf(" THIS PROGRAM GIVES YOU THE CREATE EXCUTABLE LINKLIST\n");
do
{
printf("enter your choice\n");
printf("1.INSERT element at the END of linklist\n");
printf("2.INSERT element at the starting of linklist\n3.DELETE from");
printf("END\n4.DELETE from BEGINING\n5.INSERT at MIDDLE\n");
printf("6.DELETE from MIDDLE\n7.MODIFY any element\n8.EXIT\n");
fflush(stdin);
scanf("%d",&a);

switch(a)
{
case 1:
insertend();
display();
break;

case 2:
insertbeg();
display();
break;

case 3:
delend();
show();
break;

case 4:
delbeg();
show();
break;
case 5:
insertmid();
show();
break;
case 6:
delmid();
show();
break;
case 7:
modify();
show();
break;
case 8:
exit(0);
}
}
while(a!=8);
getch();
}
void insertend()
{
node *p,*q;
int item;
printf("enter your elements in the Group\n");
scanf("%d",&item);
p=(node *)malloc(sizeof(node));
p->data=item;
p->next=NULL;
if(start==NULL)
{
start=p;
}
else
{
q=start;
while(q->next!=NULL)
{
q=q->next;
}
q->next=p;
}
}
void show()
{
node *temp;
temp=start;
printf(" THE LINKLIST IS AS FOLLOWS :");
while(temp->next!=NULL)
{
printf("%d->",temp->data);
temp=temp->next;
}
printf("%d->\n",temp->data);
}
void delend()
{
node *q,*p,*k;
q=start;
if(start->data==0)

//if we write here if(start==NULL)then it will not print

{ //the line.As here the rest portion of delend func delete the
printf("THERE IS NO ELEMENT IN THE LIST\n");//last value and remains it zero
}
else if(start->next==NULL)
{
k=start;
start=NULL;
free(k);
}
else
{
while(q->next->next!=NULL)
{
q=q->next;
}
p=q->next->next;
q->next=NULL;
free(p);
}
}
void insertbeg()
{
int item;
node *p,*q;
printf("enter the value which do you want to insert at Starting\n");
scanf("%d",&item);
p=start;
q=(node *)malloc(sizeof(node));
q->data=item;
q->next=p;
start=q;
}
void delbeg()
{
if(start==NULL)
{
printf("THERE IS NO ELEMENT IN THE LIST\n");
}
node *p;
p=start;
start=p->next;
free(p);
}
void insertmid()
{
int item1,item2;
node *p,*q,*k;
printf("enter the previous value after which you want to insert a new element\n");
scanf("%d",&item1);
printf("enter the value of new node\n");
scanf("%d",&item2);
q=(node *)malloc(sizeof(node));
q->data=item2;
q->next=NULL;
p=start;
while(p->data!=item1)
{
p=p->next;
}
k=p->next;
p->next=q;
q->next=k;
}
void delmid()
{
int item;
node *p,*q,*k;
printf("enter the previous value of that value which you want to delete\n");
scanf("%d",&item);
p=start;
while(p->data!=item)
{
p=p->next;
}
q=p->next->next;
k=p->next;
p->next=q;
free(k);
}
void modify()
{
int item1,item2;
node *p,*q;
printf("enter the value you want to modify\n");
scanf("%d",&item1);
printf("enter the new value\n");
scanf("%d",&item2);
p=start;
while(p->data!=item1)
{
p=p->next;
}
p->data=item2;
}

Related Links :

Airline Reservation System Project In C Language



#include
#include
#include

main()
{
FILE*fp,*ft;
char another,choice;
char name[20];
int tmp,x,fr,amt;

struct bnk
{
char name [20];
char add[20],dob[20],date[20];
int fcode,cl,fare;
int acno,c,fno,st,amt;
float ob,tk;
};
struct bnk e;
struct flt
{
char fname[20];
int fno,tk;
};
struct flt f;
long int recsize,recsize1;

fp=fopen("bnk.DAT","rb+");
if(fp==NULL)
{
fp=fopen("bnk.DAT","wb+");
exit();
}

recsize=sizeof(e);
recsize1=sizeof(f);
while(1)
{
int gd=DETECT,gm,maxx,maxy,x,y,button;
initgraph(&gd,&gm,"i:\tc\bin");
setbkcolor(1);
clrscr();
settextstyle(4,0,6);
outtextxy(200,1," Airline Reservation System ");
outtextxy(200,1," By IGCT Computers");
line(600,10,400,10);

printf("\n\n 1.New Customer");
printf("\n 2.List records");
printf("\n 3.New Flight ");
printf("\n 4.View Flight");
printf("\n 5.Delete records");
printf("\n 0.Exit");
printf("\n\n PLEASE ENTER YOUR CHOICE...\n ");
fflush (stdin);
choice=getche();
switch(choice)
{
case '1':
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("\n Enter Customer Name...\n \t");
scanf("%s",&e.name);
printf("\n Enter Address...\n");
scanf("%s",&e.add);
printf("\n Enter DOB...\n");
scanf("%s",&e.dob);
printf("\nEnter Flight Code...\n");
scanf("%d",&e.fcode);
printf("\nEnter Date..\n");
scanf("%s",&e.date);
printf("\n Enter Class..\n");
scanf("%d",&e.cl);
printf("\nEnter Fare...\n");
scanf("%d",&fr);
printf("\n Enter Seats to Book..\n");
scanf("%d",&e.st);
if(e.cl==1)
{
e.fare=5000;
}
if(e.cl==2)
{
e.fare=3000;
}
else
{
e.fare=1000;
}
e.amt=e.fare+(e.st*fr)+(e.fare+.10);
printf("\n Total Payble amount with tax is %d",e.amt);
fwrite(&e,recsize,1,fp);
printf("\n Add Another Records(y/n)");
fflush(stdin);
another=getche();
}
break;

case '2':
printf("\nFCode\tName\tAddress\tDOB\tJ-Date\tClass\tSeats\tFare");
printf("\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
printf("\n%d\t%s\t%s\t%s\t%s\t%d\t%d\t%d",e.fcode,e.name,e.add,e.dob,e.date,e.cl,e.st,e.amt);
getch();
break;


case '3':
fp=fopen("flt.DAT","rb+");
if(fp==NULL)
{
fp=fopen("flt.DAT","wb+");
exit();
}
fseek(fp,0,SEEK_END);
another='y';
while(another=='y')
{
printf("Enter Flight name,FLNO,Fare...\n");
scanf("%s %d %d",&f.fname,&f.fno,&f.tk);
fwrite(&f,recsize1,1,fp);
printf("\n Add Another Records(y/n)");
fflush(stdin);
another=getche();
}
break;

case '4':
printf("\nFlight Code \t FName \t Fare");
printf("\n=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*");
rewind(fp);
while(fread(&f,recsize1,1,fp)==1)
printf("\n %d \t %s \t %d",f.fno,f.fname,f.tk);
getch();
break;

case '5':
another ='y';
while(another=='y')
{
printf("\n enter name of Person to delete...\n");
scanf("%s",&name);
ft=fopen("pop.DAT","wb");
rewind(fp);
while(fread(&e,recsize,1,fp)==1)
{
if(strcmp(e.name,name)!=0)
fwrite(&e,recsize,1,ft);
}
fclose(fp);
fclose(ft);
remove("bnk.DAT");
rename("pop.DAT","bnk.DAT");
fp=fopen("bnk.DAT","rb+");
printf("delete another record(y/n)");
fflush(stdin);
another=getche();
}
break;

case '0':
fclose(fp);
exit();
}
}
}

Related Links :

Program to sort a range of numbers with Insertion and Quicksort, check their sorting time and prompt the result on the screen



/* A program to sort a range of numbers with Insertion
and Quicksort, check their sorting time and prompt
the result on the screen */


/* use header file*/
#include
#include
#include
#include
#include
#include
#include

/* define variable */
const int max=29000;
int list[max];
FILE *fp;
clock_t start,end;
char any1[8];

/* Insertion sort module */
void insertion(int min1,int max1)
{
int a,b,v;

for(a=min1;a<=max1;a++)
{
v = list[a];
b = a;
do
{
list[b] = list[b-1];
b = b - 1;
} while(list[b-1] > v);
list[b] = v;
}
}

/* sort partitioning element */
void sorthree(int x,int y,int z)
{
int temp;

if (list[x] > list[y])
{
temp = list[x];
list[x] = list[y];
list[y] = temp;
}
if (list[z] < list[x])
{
temp = list[x];
list[x] = list[z];
list[z] = temp;
temp = list[y];
list[y] = list[z];
list[z] = temp;
}
if ((list[z] > list[x]) && (list[z] < list[y]))
{
temp = list[y];
list[y] = list[z];
list[z] = temp;
}
}

/* Quicksort module */
void quicksort(int min2,int max2)
{
int v,t,i,j,q;

if ((max2-min2) > 9)
{
int m = (max2-min2+1)/2;
sorthree(min2,m,max2);
max2=max2-1;
q = list[m];
list[m] = list[max2];
list[max2] = q;

v = list[max2];
i = min2+1;
j = max2-1;
do
{
do
{
i=i+1;
} while (list[i] < v);
do
{
j=j-1;
} while (list[j] > v);
t = list[i];
list[i] = list[j];
list[j] = t;
} while (i list[j]=list[i];
list[i]=list[max2];
list[max2]=t;
quicksort(min2,i-1);
quicksort(i+1,max2);
}
else
insertion(min2,max2);
}


/* main program */
void main()
{
int i,j,k,min,max1;
char any2[8];

clrscr();
cout << "Enter a file name to store data :";
cin >> any1; /* input data file name on */
cout << '\n' << "Generating file...waits\n\n";/* screen */

fp = fopen(any1,"w");
for(j=0;j {
for(i=0;i<200;i++) /* write random values to file */
{
k = rand();
fprintf(fp,"%d\n",k);
}
}
fclose(fp);

fp = fopen(any1,"r");
i = 0;
while(fscanf(fp,"%d\n",&k) != EOF)
{
list[i] = k; /* read values from file and assign to an array */
i = i + 1;
}
fclose(fp);
min = 0;
max1 = max;
max1=max1-1;
cout << "Sorting with Quicksort... waits" << '\n';
start = clock();
quicksort(min,max1); /* sort an unsorted list with quicksort */
end=clock();
float result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
<< " numbers in Quciksort is : " << result << " second(s)" << "\n\n";


cout << "Enter an output file for Quicksort : ";
cin >> any2;

fp = fopen(any2,"w");
for(i=0;i { /* write the output from quicksort and put them */
k = list[i]; /*to a file */
fprintf(fp,"%d\n",k);
}
fclose(fp);

fp = fopen(any1,"r");
i = 0;
while(fscanf(fp,"%d\n",&k) != EOF)
{
list[i] = k;
i = i + 1;
}
fclose(fp);
cout << "\nSorting with Insertion Sort... waits" << '\n';
start = clock();
insertion(0,max); /* sort an unsorted list with insertion sort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
<< " numbers in Insertion is : " << result << " second(s)" << "\n\n";

cout << "Sort an already sorted array again with Quicksort..." << '\n';
min = 0;
max1 = max;
max1=max1-1;
start = clock();
quicksort(min,max1); /* sort an already sort list with quicksort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
<< " numbers in Quicksort is : " << result << " second(s)" << "\n";

cout << "Sort an already sorted array again with Insertion sort..." << '\n';
start = clock();
insertion(0,max); /* sort an already list with insertion sort */
end=clock();
result = (end-start)/CLK_TCK;
cout << "The time needs to sort " << max
<< " numbers in Insertion sort is : " << result << " second(s)" << '\n';
}




Related Links :

what is Circular Linked List?


The linked lisis that we have seen so far are often known as linear linked lists. The elements of such a linked list can be accessed, first by setting up a pointer pointing to the first node in the list and then traversing the entire list using this pointer. Although a linear linked list is a useful data structure, it has several shortcomings. For example, given a pointer p to a node in a linear list, we cannot reach any of the nodes that precede the node to which p is pointing. This disadvantage can be overcome by making a small change to the structure of a linear list such that the link field in the last node contains a pointer back to the first node rather than a NULL. Such a list is called a circular linked list.

Related Links :

Ascending Order Linked List

Ascending Order Linked List

Now that we have understood how a linked list can be maintained how about ensuring that every element added to the linked list gets inserted at such a place that the linked list is always maintained in ascending order?




#include
class linklislt
{
private:
// slructure containing a data part and link pari struct node
{
int data;
node 'link;
}*Pi

pubic:

linklist();
void add (int num);
void display();
int count();
void del (int num):
Hinklist();
// initializes data member
hnWist::linklist()
{
p=NULL;
}

// adds node to an ascending order linked list

Related Links :


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!