Menu

[solved]-Write Complete C Program Define Structure Type Elementt Represent One Element Periodictabl Q39088309

Write a complete C program.

Define a structure type element_t to represent one element fromthe periodictable of elements. Components should include the atomicnumber (aninteger); the name, chemical symbol, and class (strings);a numeric field forthe atomic weight; and a seven-element array ofintegers for the number ofelectrons in each shell. The followingare the components of an element_t

structure for sodium.11 Sodium Na alkali_metal 22.9898 2 8 1 0 00 0

Have the user enter the data for one element and then displaythat data on the screen.

—————————————–example—————————————————————

#include <stdio.h>#include <math.h>struct point{ float x; float y;};typedef struct point POINT;POINT input_POINT();void print_POINT(POINT);POINT calc_midPOINT(POINT,POINT);float calc_distance(POINT,POINT);float calc_slope(POINT,POINT);void determine_quadrant(POINT);int main(){ POINT a,b,mid; float distance,slope; printf(“This program allows you to entern”); printf(“two Cartesian coordinate pointsn”); printf(“and will then analyze them!nn”); printf(“It is time to enter your first pointn”); a=input_POINT(); printf(“n”); printf(“It is time to enter your second pointn”); b=input_POINT(); printf(“nn”); printf(“First point entered:”); print_POINT(a); printf(“n”); determine_quadrant(a); printf(“n”); printf(“Second point entered:”); print_POINT(b); printf(“n”); determine_quadrant(b); printf(“n”); mid = calc_midPOINT(a,b); printf(“Midpoint:”); print_POINT(mid); printf(“n”); distance = calc_distance(a,b); printf(“The distance between the points is: %8.2fn”,distance); printf(“n”); if(a.x == b.x) printf(“The slope is undefinedn”); else { slope = calc_slope(a,b); printf(“The slope is: %8.2fn”,slope); } return 0;}void determine_quadrant(POINT p){ if(p.x==0 && p.y==0) printf(“Point is on the originn”); else if (p.x > 0 && p.y >0) printf(“Point is in Quadrant In”); else if (p.x < 0 && p.y >0) printf(“Point is in Quadrant IIn”); else if (p.x<0 && p.y <0) printf(“Point is in Quadrant IIIn”); else if (p.x>0 && p.y < 0) printf(“Point is in Quadrant IVn”); else if(p.y==0 && p.x!=0) printf(“Point is on X-axisn”); else printf(“Point is on Y-axisn”); }float calc_slope(POINT a, POINT b){ float temp; temp = (b.y – a.y)/(b.x – a.x); return temp; }float calc_distance(POINT a, POINT b){ float temp; temp = sqrt(pow(b.x – a.x,2) + pow(b.y – a.y,2)); return temp; }POINT calc_midPOINT(POINT a, POINT b){ POINT temp; temp.x = (a.x + b.x)/2; temp.y = (a.y + b.y)/2; return temp;}void print_POINT(POINT p){ printf(“(%6.2f,%6.2f)n”,p.x,p.y);}POINT input_POINT(){ POINT temp; printf(“Enter the x coordinate of your pointn”); scanf(“%f”,&temp.x); printf(“Enter the y coordinate of your pointn”); scanf(“%f”,&temp.y); return temp;}

—————————————–example—————————————————————

Expert Answer


Answer to Write a complete C program. Define a structure type element_t to represent one element from the periodictable of element… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *