CTSD Project PDF
CTSD Project PDF
On
SUBMITTED BY:
2100030565 GANESH.V
2100030572 MANIKUMAR.V
2100030587 JAYANTH.V
2100030592 MEGHANA.G.V
AZMIIRA KRISHNA
(M.TECH,IISC)
(ASSISTANT PROFFESOR,KLU)
KL UNIVERSITY
Green fields, Vaddeswaram – 522 502
Guntur Dt., AP, India.
DEPARTMENT OF BASIC ENGINEERING SCIENCES
CERTIFICATE
I express the sincere gratitude to our Director Dr. A. Jagdeesh for his
administration towards our academic growth.
Name: Ganesh.V
This project will help you to understand file handling in C i.e. creating a file
and accessing the stored data in the file, modifying and removing the
stored data. It will also help you to understand the use of functions as well
as different parameters of C programming language. The Modern Periodic
Table project is a simple console application built without the use of
graphics. It is developed using the C programming language for the
purpose of storing name, symbol, atomic number, atomic weight, and some
important properties as well as to display them as per requirement of the
user.
INDEX
S.NO TITLE PAGE NO
1 Introduction (A)
5 Implementation (6-34)
8 Conclusion (36)
(page A)
INTRODUCTION
This project will help you to understand file handling in C i.e. creating a
file and accessing the stored data in the file, modifying and removing the
stored data. It will also help you to understand the use of functions as well
as different parameters of C programming language.
The main functions used in designing the Modern Periodic Table project
are:
The key features of Modern Periodic Table mini project in C are briefly
described below:
AIM
Advantages:-
Disadvantages:-
Future enhancements:-
SOFTWARE REQUIREMENTS:
The major software requirements of the project are as follows:
Language : Turbo-C
Operating system: Windows Xp or later.
HARDWARE REQUIREMENTS:
The hardware requirements that map towards the software are as
follows:
Processor : 64BIT-PROCESSOR
(page 3)
ALGORITHM
STEP 1 :- Declare any character , for example ch or c .
STEP 2 :- Now assign some size to this character (ch[80]).
STEP 3 :- Now this size is useful to read strings from user .
STEP 4 :- Read strings from user .
STEP 5 :- Initially Store chemical information in a separate
file.
STEP 6 :- if (ch[80]==”Add New element information “)
6.1 :- It will add any chemical information and stores
in a file.
STEP 7 :- if (ch[80]==”Explore”)
7.1 :- It will take us to new screen to search for new
element .
7.2 :- if (ch[80]==”Seach by name”)
7.2.1 :- Enter name to search chemical info
7.3 :- if (ch[80]==”Search by symbol”)
7.3.1 :- Enter symbol of chemical to search in file.
7.4 :- if (ch[80]==”Search by atomic number”)
7.4.1 :- Enter specifc atomic number of chemical
to search in file.
7.5 :- if (ch[80]==”Search by atomic weight”)
(page 5)
IMPLEMENTATION
PROJECT CODE :-
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
struct element
{
char name[20] ;
char sb[5] ;
int atm;
float atms;
char block;
char atc[20];
char prop[250];
(page 7)
}p,q ;
int rw , cl ;
FILE*fp;
void add ();
void explor();
void print ();
void mainscreen ();
void main ()
{
int a,i,n,y;
char c,d ;
char date[15],date2[15],string1[20];
unsigned int tsz ;
clrscr();
mainscreen();
label1:
textcolor(15);
gotoxy(22,15);textcolor(14);
(page 8)
}
case '3' :
{
clrscr();
mainscreen();
textcolor(14);gotoxy(30,24);
cprintf ("THANK U");gotoxy(30,26);
cprintf ("BYE.........");
getch();
exit (1);
break;
}
default :
{
clrscr();
mainscreen();
textcolor(12+128);gotoxy(22,11);
(page 10)
}
clrscr();
mainscreen();
goto label1;
}
void mainscreen()
{
int i,j;
clrscr ();
for (i=2,j=2;i<rw;j++)
{
(page 11)
if(j>15)
j=2;
textcolor(j);
gotoxy(i,2);
cprintf ("%c",'*');
gotoxy(i,cl-1);
cprintf ("%c",'*');
i++;
}
for (i=1,j=2;i<cl;i++,j++)
{
if(j>15)
j=2;
textcolor(j);
gotoxy(2,i);
cprintf("%c",'*');
gotoxy(rw-1,i);
(page 12)
cprintf("%c",'*');
}
gotoxy(30,4);textcolor(3);
cprintf ("Modern Periodic Table");
gotoxy(37,6);textcolor(6);
cprintf ("Digital");
gotoxy(35,7);textcolor(15);
cprintf ("-----------");
}
void add()
{
char ch ;
label1:
clrscr();
mainscreen();
gotoxy(15,14);textcolor(10);
cprintf ("Enter the Information of Elements:");
(page 13)
gotoxy(15,16);
cprintf ("Name:");
gotoxy(15,18);
cprintf ("Symbol:");
gotoxy(15,20);
cprintf ("Atomic no:");
gotoxy(15,22);
cprintf("Atomic wt:");
gotoxy(15,24);
cprintf ("Atomic Config:");
gotoxy(15,26);
cprintf ("Block:");
gotoxy(15,28);
cprintf ("Properties:");
textcolor(15);
fflush(stdin);
gotoxy(20,16);
scanf ("%[^\n]",p.name);
(page 14)
p.name[0]=toupper(p.name[0]);
fflush(stdin);
gotoxy(23,18);
scanf("%[^n]",p.sb);
p.sb[0]=toupper(p.sb[0]);
fflush(stdin);
gotoxy(25,20);
scanf ("%f",&p.atms);
fflush(stdin);
gotoxy(29,24);
scanf (" %[^n]",p.atc);
fflush(stdin);
gotoxy(21,26);
scanf ("%c" ,&p.block);
p.block=touper(p.block);
if(p.block!='S'&&p.block!='P'&&p.block!='D'&&p.bloc
k!='F')
p.block=' ';
(page 15)
fflush(stdin);
gotoxy(26,28);
scanf ("%[^n]",p.prop);
p.prop[0]=toupper(p.prop[0]);
if((fp=fopen("data","ab+"))==NULL)
{
printf ("Cannot open the file f1");
getch();
exit(1);
}
fwrite(&p,sizeof(p),1,fp);
fclose(fp);
printf ("\n\n\n\t\tEnter 'y' for next record(y/n):");
ch=getch();
if(ch=='y')
{
goto label1 ;
}
(page 16)
}
void explor()
{
char d,c ;
FILE *f;
int given_atmic_mass;
int flag ;
char string[20];
//startofexplore;
clrscr();
mainscreen ();
label6:
gotoxy(22,15);textcolor(12);
cprintf ("Enter the corresponding
no");gotoxy(22,19);textcolor(3);
cprintf ("1.Search by 'NAME'");gotoxy(22,21);
cprintf ("2.Search by SYMBOL");gotoxy(22,23);
cprintf ("3.Search by ATOMIC
NUMBER");gotoxy(22,25);
(page 17)
scanf ("%[^\]",string);
printf ("%s",string);
string[0]=toupper(string[0]);
if((fp=fopen("data","rb+"))==NULL)
{
clrscr();
printf ("\ncannot open the record file 1");
getch();
exit(1);
}
flag=1;
while(fread(&p,sizeof(p),1,fp))
{
if(strcmp(p.name,string)==0)
{
print();
flag=0;
break;
(page 19)
}
}
if(flag==1)
{
clrscr();
mainscreen();
gotoxy(25,25);
textcolor(12);
cprintf ("::No Element Available::");
}
fclose(fp);
getch();
break ;
}
case '2' :
{
mainscreen();
gotoxy(22,15);
(page 20)
textcolor(12);
cprintf ("Enter the Symbol :");
textcolor(3);
fflush(stdin);
scanf ("%[^n]",string);
string[0]=toupper(string[0]);
if ((fp=fopen("data","rb+"))==NULL)
{
printf ("\n cannot open the record file 1");
getch();
exit(1);
}
flag=1;
while(fread(&p,sizeof(p),1,fp))
{
if(strcmp(p.sb,string)==0)
{
print();
(page 21)
flag=0;
break;
}
if(flag==1)
{
mainscreen();
gotoxy(25,25);
textcolor(12);
printf ("::No Element Available");
}
fclose(fp);
getch();
break;
}
case '6' :
{
return ;
(page 22)
}
case '3' :
{
mainscreen();
gotoxy(15,25);
textcolor(12);
printf ("Enter the Atomic Number of the Element:");
textcolor(3);
fflush(stdin);
scanf("%d",&given_atomic_no);
if((fp=fopen("data","rb+"))==NULL)
{
clrscr();
printf ("\ncannot open the record file 1);
getch();
exit(1);
}
flag=1;
(page 23)
while(fread(&p,sizeof(p),1,fp))
{
if(p.atm==given_atomic_no)
{
print();
flag=0;
break;
}
}
if(flag=1)
{
mainscreen();
gotoxy(25,25);
textcolor(12);
cprintf ("::No Element Availabe");
}
fclose(fp);
getch();
(page 24)
break;
}
case '4' :
{
mainscreen();
gotoxy(15,22);
textcolor (12);
printf ("Enter the Atomic Mass of Element:");
textcolor(3);
fflush(stdin);
scanf ("%f",&given_atomic_mass);
if((fp=fopen("data","rb+"))==NULL)
{
clrscr();
printf ("\ncannot open the record file 1");
getch();
exit(1);
}
(page 25)
flag=1;
while(fread(&p,sizeof(p),1,fp))
{
if(p.atms==given_atmic_mass)
{
print();
flag=0;
break;
}
}
if(flag==1)
{
clrscr();
mainscreen();
gotoxy(25,25);
textcolor(12);
printf ("::No Element Available::");
}
(page 26)
fclose(fp);
getch();
break;
}
case '5' :
{
clrscr();
mainscreen();
gotoxy(15,25);
textcolor(12);
printf("Enter the Block:");
textcolor(3);
fflush(stdin);
scanf("%c",&c);
c=touper(c);
if((f=fopen("temp","wb+"))==NULL)
{
clrscr();
(page 27)
}
fclose(f);
fclose(fp);
if((f=fopen("temp","rb+"))==NULL)
{
printf ("Cannot open the File");
getch();
exit(1);
}
fseek(f,0,SEEK_END);
tsz=ftell(f);
n=(int)(tsz/sizeof(p));
for(i=0;i<(n-1);i++)
{
for (a=i+1;a<n;a++)
{
fseek(f,i*sizeof(p),SEEK_SET);
fread(&p,sizeof(p),1,f);
(page 29)
fseek(f,a*sizeof(p),SEEK_SET);
fread(&q,sizeof(p),1,f);
if((p.atm-q.atm)>0)
{
fseek(f,i*sizeof(p),SEEK_SET);
fwrite(&q,sizeof(p),1,f);
fseek(f,a*sizeof(p),SEEK_SET);
fflush(stdin);
fwrite(&p,sizeof(p),1,fp);
}
}
}
rewind(f);
while(fread(&p,sizeof(p),1,f))
{
print();
getch();
}
(page 30)
clrscr();
mainscreen();
gotoxy(25,25);
textcolor(12);
printf("::No Element Available::");
fclose(f);
getch();
break;
}
default :
{
clrscr();
mainscreen();
textcolor(12+128);gotoxy(22,11);
printf ("Wrong
Choice");gotoxy(22,13);textcolor(15);
printf ("Retype Choice");
goto label6 ;
(page 31)
}
}
goto startofexplore;
}
void print()
{
clrscr();
mainscreen();
gotoxy(15,16);
printf("Name:");
gotoxy(15,18);
printf ("Atomic No:");
gotoxy(15,22);
printf("Atomic Wt:");
gotoxy(15,24);
printf("Atomic Config:");
fflush(stdin);
(page 32)
gotoxy(15,26);
printf("Block:);
gotoxy(15,28);
printf("Properties:");
textcolor(6);
gotoxy(20,16);
print("%s",p.name);
gotoxy(23,18);
printf ("%s",p.sb);
fflush(stdin);
gotoxy(25,20);
printf("%d",p.atm);
fflush(stdin);
gotoxy(25,22);
printf ("%f",p.atms);
fflush(stdin);
gotoxy(29,24);
cprintf("%s",p.atc);
(page 33)
gotoxy(21,26);
cprintf("%c",p.block);
gotoxy(26,28);
cprintf("%s",p.prop);
}
(page 34)
CONCLUSION
THANK YOU