You are working on periodic function
 
search
 


Contents:


swap function:
Swapping two values to change their addresses.
a

max function:

The largest number among two.
a

absolute value function:

The positive value of a number.
a

sorting function:

How to sort an array.
a

bisection function:

Bissection method used to solve equations by computing, example of cable strung ..
a

Newton-Raphson function:

To solve equations numerically, example of free fall motion ..
a

Secant function:

To solve equations numerically, example of free fall motion ..
a

isPrime function:

This function tests whether an integer is prime..
a

abundant function:

This function tests whether an integer is abundant..
a

factorial function:

Factorial of an integer..
a

quadratic function:

solving a quadratic equation ..
a

even_odd function:

To know if an integer is even or odd ..
a

mean value function:

To calculate the arithmetic mean of some values..
a

reverse function:

To reverse an integer and to know whether a string is palindrome..
a

least squares function :

To calculate the slope and the y_intercept of a linear equation ..
a

Monte Carlo method:

To calculate integrales or probabilities using Monte Carlo technique ..
a

2 and 3 equations systems solving :

To solve the 2 and 3 equations systems with 2 and 3 variables ..
a

Interpolation and Extrapolation :

To solve for lacking values in graphs or tables ..
a

Integer divisors :

Gives the divisors fo an integer and tests whether it is prime ..
a

Amicable pair :

Gives, if it exists, the amicable number of a given integer ..
a

Perfect numbers :

Tests whether a positive integer is perfect, and more ..
a

Periodic table of elements:

Periodic table of elements in C language, and more ..
a

Playing TicTacToe

Using some Fortran90 language funtionalities, and more ..
a


a
home

   Periodic table of elemnts

	
	

Periodic table of elements functions

1. Preface: This program written in C language, displays: 1. The list of all elements 2. The noble gases 3. The Halogens 4. The Alkali 5. The Alkaline Earth 6. The Metalloids 7. The Non Metals 8. The Transition Metals 9. The Rare Earth 10. The Other Metals, and 11. Search for an element in the list, in which are stored the data: periodic.txt. 2. The program in C language: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <ctype.h> #define max_atoms 112 #define W_NAME 18 #define W_ELECTRONIC 25 //enum BOOLEAN { false, true }bool; //THE SRUCURE:Periodic Table of the Elements typedef struct { int Number; char Symbol[3]; char Name [W_NAME]; float Weight; char State[4]; float Density; char Electronic[W_ELECTRONIC]; } atoms; atoms atom[max_atoms]; int nb_atoms ; void open_read (atoms atom[], int * P) { FILE * p_elements ; int n = 0 ; p_elements = fopen("periodicas.txt", "r"); while (!feof(p_elements)) { fscanf(p_elements,"%d", &atom[n].Number); fgets(atom[n].Symbol,3, p_elements); fgets(atom[n].Name,W_NAME, p_elements), fscanf(p_elements,"%f", &atom[n].Weight); fgets(atom[n].State,4, p_elements); fscanf(p_elements,"%f", &atom[n].Density); fgets(atom[n].Electronic, W_ELECTRONIC+1, p_elements); n++; } fclose(p_elements); *P = n ; } void display ( atoms * P, int nombre ) { printf("n"); int i; for (i = 0 ; i < nombre ; i++){ printf(" %3d)%3d %s %s %7.2f %s %7.2f %sn", i+1,(P+i)->Number,(P+i)->Symbol, (P+i)->Name, (P+i)->Weight, (P+i)->State ,(P+i)->Density , (P+i)->Electronic); } } int display_one ( atoms * P, int z) { printf(" %3d %s %s %7.2f %s %7.2f %sn",(P+z) ->Number, (P+z)->Symbol, (P+z)->Name, (P+z )->Weight, (P+z )->State , (P+z)->Density , (P+z)->Electronic); return 0; } int PrintColumn() { printf ("Number Symbol Name Weight State Density Electron Configuration n"); return 0; } /* Just to continue: -------------------------- */ void KeepOn() { printf("nn Hit Enter "); fflush(stdin); getchar(); } // List of the Noble gas: int NobleGas(atoms *P, int nombre) { printf("n The six noble gases are present in group 18 of the periodic table.n "); printf("n The number of electrons in their outer shell (2 for Helium, 8 for alln "); printf("n others), makes them stable. They Noble Gases are:n n "); //PrintColumn(); int Noble [] = {2, 10, 18, 36, 54,86}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<6; n++) { if ((P + i)->Number == Noble[n]) display_one (atom,i ); } } return 0; } // ---------------------------------------- // List of the Halogenes: int Halogens(atoms *P, int nombre) { printf("nt The halogens are the five NonMetallic elements in the group VIIAn"); printf("t of the periodic table. They have 7 electrons in their outer shells;n"); printf("t then an oxidation number of -1. They are:nn"); //PrintColumn(); int Halogens [5] = {9, 17, 35, 53, 85}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<5; n++) { if ((P + i)->Number == Halogens[n]) display_one (atom,i ); } } return 0; } //------------------------------- // List of the alkali metals: int Alkali (atoms *P, int nombre) { printf("nt The alkali metals are in group 1A of the periodic table. They have onen "); printf("t electron in their outer shell. They are reactive and good conductors of n"); printf("t heat and electricity. They are softer (malleable, ductile) than most other metals.n"); printf("t They are:nn"); //PrintColumn(); int Alkali [7] = {3, 11, 19, 37, 55, 87}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<6; n++) { if ((P + i)->Number == Alkali[n]) display_one (atom,i ); } } return 0; } //------------------------------------------ //The alkaline earth elements: int AlkalineEarth (atoms *P, int nombre) { printf("nt The alkaline earth elements are metallic elements present in then "); printf("t second group of the periodic table. They have an oxidation number of +2,n "); printf("t then very reactive. They are: n n "); //PrintColumn(); int AlkalineE[7] = {4, 12, 20, 38, 56, 88}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<6; n++) { if ((P + i)->Number == AlkalineE[n]) display_one (atom,i ); } } return 0; } // ------------------------------------------------- int Metalloids (atoms *P, int nombre) { printf("nt Metalloids have properties of both metals and NonMetals. The Silicon n"); printf("t and Germanium, are semi-conductors.n"); printf("t They are:nn"); //PrintColumn(); int Metalloids[8] = {5, 14, 32, 33, 51, 52, 84}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<7; n++) { if ((P + i)->Number == Metalloids[n]) display_one (atom,i ); } } return 0; } // ------------------------------------------- int NonMetals (atoms *P, int nombre) { printf("nt The NonMetals are Hydrogen ( Group IA) and and the others in groups n"); printf("t 14-16 of the periodic table.they don't conduct electricity or heat very well.n"); printf("t They do not reflect light. They are:nn"); //PrintColumn(); int NonMetals[8] = {1, 6, 7, 8, 15, 16, 34}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<7; n++) { if ((P + i)->Number == NonMetals[n]) display_one (atom,i ); } } return 0; } //------------------------------------------ int TransitionMetals (atoms *P, int nombre) { //List of The transition metals: printf("nt The transition metals are the 38 elements in groups : 3 through n"); printf("t 12 of the periodic table. As with all metals,they are malleable, and n"); printf("t and conduct electricity and heat. The transition metals family contains n"); printf("t Iron, Cobalt and Nickel : the only elements known to produce a magnetic n"); printf("t field. They are:nn"); //PrintColumn(); int i; int n; int m; int s; for (i = 0 ; i < nombre ; i++) { for( n = 21; n<49; n++) { if ((P + i)->Number == n) display_one (atom,i ); } for( m = 72; m<81; m++) { if ((P + i)->Number == m) display_one (atom,i ); } for( s = 104; s<112; s++) { if ((P + i)->Number == s) display_one (atom,i ); } } return 0; } // ------------------------------ //List of the rare earth elements int RareEarth (atoms *P, int nombre) { printf("nt The thirty rare earth elements are made up of the lanthanide n"); printf("t and actinide series. They are found in group 3 of the periodic table, and n"); printf("t the 6th and 7th periods. They are:n"); //PrintColumn(); int i; int n; int m; printf("nt 1- The lanthanide series:nn"); for (i = 0 ; i < nombre ; i++) { for( n = 57; n<72; n++) { if ((P + i)->Number == n) display_one (atom,i ); } } printf("nt 2- The actinide series:nn"); for (i = 0 ; i < nombre ; i++) { for( m = 89; m<105; m++) { if ((P + i)->Number == m) display_one (atom,i ); } } return 0; } // ------------------------------------------ //The Other Metals: int OtherMetals (atoms *P, int nombre) { printf("nt The Other metals are the 7 elements located in groups 13, 14, and 15.n"); printf("t They are:nn"); //PrintColumn(); int OtherMetal[8] = {13, 31, 49, 50, 81, 82, 83}; int i; int n; for (i = 0 ; i < nombre-1 ; i++) { for( n = 0; n<7; n++) { if ((P + i)->Number == OtherMetal[n]) display_one (atom,i ); } } return 0; } // ------------------------------------------------ //Search for an element in the list: void Search (atoms *P, int nombre) { char Response; do { int s_number; printf("nt Enter the Number of the atom you are searching for: --> "); scanf("%d", &s_number); int i; int success = 0; for (i = 0 ; i < nombre ; i++) { if ((P + i)->Number == s_number) { success = 1; printf("n"); display_one (atom,i); i = nombre; } else success =0; } if (success == 0) { printf("nt This atom is not in the table.n"); } printf("nt Do you want to try again ? Y : N --> "); scanf("%s", &Response); Response = toupper (Response); } while ( Response =='Y'); } // ----------------------------------------------- char The_Menu (char * C) { char Choose ; int Flag ; /* Yes or No the choice is valid */ printf("n Hit :n"); printf(" - L to list all the elements n"); printf(" - G Noble Gasesn"); printf(" - H Halogensn"); printf(" - A Alkalin"); printf(" - E Alkaline Earthn"); printf(" - M Metalloids n"); printf(" - N Non Metals n"); printf(" - T Transition Metals n"); printf(" - R Rare Earth n"); printf(" - O Other Metals n"); printf(" - S to searchn"); printf(" - Q to quitn"); do { printf("n Choose among L, ,N, H, A, S, R, T or Q : --> "); fflush(stdin); Choose = toupper(getchar()); Flag = ( Choose == 'L' || Choose == 'G' ||Choose == 'H' || Choose == 'A' || Choose == 'E' || Choose == 'M' || Choose == 'N' || Choose == 'T' || Choose == 'R' || Choose == 'O' || Choose == 'S' ||Choose == 'Q' ); if (!Flag) printf(" The choice is not valid . Try again ! "); } while (!Choose); *C = Choose ; return Choose; } void cases(char Choose) { int Flag = 0 ; /* False at first*/ do { The_Menu (&Choose); switch (Choose) { case 'L': display(atom, nb_atoms); break; case 'H': Halogens(atom, nb_atoms); break ; case 'G': NobleGas(atom, nb_atoms); break; case 'A': Alkali(atom, nb_atoms); break; case 'E': AlkalineEarth (atom, nb_atoms); break; case 'M': Metalloids (atom, nb_atoms); break; case 'N': NonMetals(atom, nb_atoms); break; case 'T': TransitionMetals (atom, nb_atoms); break; case 'R': RareEarth (atom, nb_atoms); break; case 'O': OtherMetals (atom, nb_atoms); break; case 'S': Search (atom, nb_atoms); break; } } while (Choose != 'Q'); } // ------------------------------------------ int main() { char Choose = 'Q' ; open_read (atom, &nb_atoms); printf("nn"); cases (Choose); return 0; }


Custom Search


© 2007. The scientificsentence . All rights reserved.