Lab 2/ HW 2 (9/4)

void setup() {
  pinMode(10,OUTPUT);  //Initialize Pin
  pinMode(9,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(6,OUTPUT);
}
void loop() {
  digitalWrite(10,HIGH);   //Set the LED On
  delay(50);                        //Wait for 50 ms
  digitalWrite(10,LOW);   //Set the LED Off
  delay(50);                       //Wait for 50 ms

  digitalWrite(9,HIGH);
  delay(50);
  digitalWrite(9,LOW);
  delay(50);

  digitalWrite(7,HIGH);
  delay(50);
  digitalWrite(7,LOW);
  delay(50);

  digitalWrite(6,HIGH);
  delay(50);
  digitalWrite(6,LOW);
  delay(50);

  digitalWrite(7,HIGH);
  delay(50);
  digitalWrite(7,LOW);
  delay(50);

  digitalWrite(9,HIGH);
  delay(50);
  digitalWrite(9,LOW);
  delay(50);
}



/* Estimate height of human */
#include <stdio.h>
#include <math.h>
int main(void)
{
/* Declare variables. */
double femur, femur_ht_f, femur_ht_m, humerus, humerus_ht_f,
humerus_ht_m, in_cm=2.54;


/* Get user input from the keyboard. */
printf("Enter Values in Inches. \n\n");
printf("Enter femur length: \n");
scanf("%lf",&femur);
printf("Enter humerus length: \n");
scanf("%lf",&humerus);


/* Compute height estimates. */
femur_ht_f = ((femur*in_cm)*1.94 + 28.7);
femur_ht_m = ((femur*in_cm)*1.88 + 32);
humerus_ht_f = ((humerus*in_cm)*2.8 + 28.2);
humerus_ht_m = ((humerus*in_cm)*2.9 + 27.9);


/* Print height estimates. */
printf("\nHeight Estimates in Centimeters \n\n");
printf("Femur Female Estimate: %5.1f \n",femur_ht_f);
printf("Femur Male Estimate: %5.1f \n",femur_ht_m);
printf("Humerus Female Estimate: %5.1f \n",humerus_ht_f);
printf("Humerus Male Estimate: %5.1f \n",humerus_ht_m);
/* Exit program. */
return 0;
}


/* Compute molecular weight of glycine */
#include <stdio.h>
#include <math.h>
int main(void) {
/* Declare variables. */
double Oxygen=15.9994, Carbon=12.011,Nitrogen=14.00674,
Sulfur=32.066, Hydrogen=1.00794, glycine_mw;


/* Calculations */
glycine_mw= (2*Oxygen)+(2*Carbon)+(1*Nitrogen)+(0*Sulfur)+
(5*Hydrogen);


/* Display molecular weights */
printf("Glycine's molecular weight: ""%6.2f g/mol \n",glycine_mw);


return 0;
}
















/* Compute molecular weight of glutamic & glutamine */
#include <stdio.h>
#include <math.h>
int main(void) {

/* Declare variables. */
double Oxygen=15.9994, Carbon=12.011,Nitrogen=14.00674,
Sulfur=32.066, Hydrogen=1.00794, glutamic_mw, glutamine_mw;

/* Calculations */
glutamic_mw= (4*Oxygen)+(5*Carbon)+(1*Nitrogen)+(0*Sulfur)+
(8*Hydrogen);
glutamine_mw= (3*Oxygen)+(5*Carbon)+(2*Nitrogen)+(0*Sulfur)+
(10*Hydrogen);

/* Display molecular weights */
printf("Glutamic's molecular weight: ""%6.2f g/mol \n\n",
glutamic_mw);
printf("Glutamine's molecular weight: ""%6.2f g/mol",
glutamine_mw);
return 0;

}















/* Molecular weight of amino acid w/ user input */
/* Alanine atoms used for testing: 89.09 g/mol */
#include <stdio.h>
#include <math.h>
int main(void) {
/* Declare variables. */
double O, Oxygen=15.9994, C, Carbon=12.011, N, Nitrogen=14.00674,
S, Sulfur=32.066, H, Hydrogen=1.00794, M_W;


/* User input */
printf("Enter # of following atoms of an amino acid \n\n");
printf("How many Oxygen");
scanf("%lf",&O);
printf("How many Carbon");
scanf("%lf",&C);
printf("How many Nitrogen");
scanf("%lf",&N);
printf("How many Sulfur");
scanf("%lf",&S);
printf("How many Hydrogen");
scanf("%lf",&H);


/* Calculation */
M_W=(O*Oxygen)+(C*Carbon)+(N*Nitrogen)+(S*Sulfur)+(H*Hydrogen);


/* Display Molecualr Weight */
printf("\n" "Molucular weight: %7.3f g/mol",M_W);
return 0;
}


/* average weight of an amino acid w/ user input */
/* Alanine atoms used for testing: 89.09 g/mol */
#include <stdio.h>
#include <math.h>
int main(void) {
/* Declare variables. */
double O, Oxygen=15.9994, C, Carbon=12.011, N, Nitrogen=14.00674,
S,Sulfur=32.066, H, Hydrogen=1.00794, M_W, Tot_atom, Avg_mw;


/* User input */
printf("Enter # of following atoms of an amino acid \n\n");
printf("How many Oxygen");
scanf("%lf",&O);
printf("How many Carbon");
scanf("%lf",&C);
printf("How many Nitrogen");
scanf("%lf",&N);
printf("How many Sulfur");
scanf("%lf",&S);
printf("How many Hydrogen");
scanf("%lf",&H);


/* Calculation */
M_W=(O*Oxygen)+(C*Carbon)+(N*Nitrogen)+(S*Sulfur)+(H*Hydrogen);
Tot_atom= (O+C+N+S+H);
Avg_mw= M_W/Tot_atom;


/* Display Molecualr Weight */
printf("\n" "Molucular weight: %7.3f g/mol \n",M_W);
printf("Average molecualr weight: ""%6.3f",Avg_mw);
return 0;
}






Comments

Popular posts from this blog

Lab 13/ HW 13

Lab 21/ HW 21