audino & weight calculator
below is a picture with the four led bulbs
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(10, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
pinMode(12, OUTPUT);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(10, HIGH);
delay(120);
digitalWrite(10, LOW);
delay(120);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(130);
digitalWrite(7, LOW);
delay(130);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
delay(140);
digitalWrite(2, LOW);
delay(140);
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(120);
digitalWrite(7, LOW);
delay(120);
digitalWrite(10, HIGH);
delay(110);
digitalWrite(10, LOW);
delay(110);
}
Homework Bone Heights
problem #1
#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;
/* input input. */
printf("Enter Value in Feet. \n");
printf("Enter Femur length: \n");
scanf("%lf",&femur);
printf("Enter humerus length: \n");
scanf("%lf",&humerus);
/*compute height estimates. */
femur_ht_f = femur*1.94 + 28.7;
femur_ht_m = femur*1.88 + 32;
humerus_ht_f = humerus*2.8 + 28.2;
humerus_ht_m = humerus*2.9 + 27.9;
/* compute height estimates. */
printf("\nHeight Estimate in Feet \n");
printf("Femur Female Estimate: %5.1f\n",femur_ht_f/12);
printf("Femur Male Estimate: %5.1f\n",femur_ht_m/12);
printf("Humerus Female Estimate: %5.1f\n",humerus_ht_f/12);
printf("Humerus Female Estimate: %5.1f\n",humerus_ht_f/12);
return 0;
}
problem#2
HOMEWORK Amino Acids
problem#1
#include <stdio.h>
#define O 15.994
#define C 12.011
#define N 14.00674
#define S 32.066
#define H 1.00794
int main(void)
{
double weight;
weight = O*2 + C*2 + N*1 + S*0 + H*5;
printf("molecular wight of glycine = %.5f \n",weight);
return 0;
}
problem#2
#include <stdio.h>
#define O 15.994
#define C 12.011
#define N 14.00674
#define S 32.066
#define H 1.00794
int main(void)
{
double weight;
double weight2;
weight = O*4 + C*5 + N*1 + S*0 + H*8;
weight2= O*3 + C*5 + N*2 + S*0 + H*10;
printf("molecular wight of glutamic = %.5f \n",weight);
printf("molecular wight of glutamine = %.5f \n",weight2);
return 0;
}
problem #3
#include <stdio.h>
#define O 15.994
#define C 12.011
#define N 14.00674
#define S 32.066
#define H 1.00794
int main(void)
{
int num_o, num_c, num_n, num_s ,num_h;
double weight;
printf("Enter number of oxygen atoms: \n");
scanf("%i",&num_o);
printf("Enter number of carbon atoms: \n");
scanf("%i",&num_c);
printf("Enter number of nitrogen atoms: \n");
scanf("%i",&num_n);
printf("Enter number of sulfer atoms: \n");
scanf("%i",&num_s);
printf("Enter number of hydrogen atoms: \n");
scanf("%i",&num_h);
weight = O*num_o + C*num_c + N*num_n + S*num_s + H*num_h;
printf("amino acid molecular weight = %.5f \n",weight);
return 0;
}

problem#4
#include <stdio.h>
#define O 15.994
#define C 12.011
#define N 14.00674
#define S 32.066
#define H 1.00794
int main(void)
{
int num_o, num_c, num_n, num_s ,num_h;
double weight;
printf("Enter number of oxygen atoms: \n");
scanf("%i",&num_o);
printf("Enter number of carbon atoms: \n");
scanf("%i",&num_c);
printf("Enter number of nitrogen atoms: \n");
scanf("%i",&num_n);
printf("Enter number of sulfer atoms: \n");
scanf("%i",&num_s);
printf("Enter number of hydrogen atoms: \n");
scanf("%i",&num_h);
weight = ((O*num_o + C*num_c + N*num_n + S*num_s + H*num_h)/5);
printf("amino acid average weight = %.5f \n",weight);
return 0;
}








Comments
Post a Comment