Hi Gang! I am new to the forums, and programming in general, so I apologize forthright if I am slow or just plain dense on anything/everything. With that disclaimer gotten outta the way, I have an assignment and I am not sure what exactly how to execute it. The problem is as follows:
Given Atomic Weights:
Oxygen = 15.9994
Carbon = 12.011
Nitrogen = 14.00674
Sulfur = 32.066
Hydrogen = 1.00794
Problem Description:
Write a program that asks the user to enter the number of atoms of each of the five elements for an amino acid. Then compute and print the average weight of the atoms in the amino acid.
So far, my program code consists of asking the user to input the number of atoms for each of the five elements. I also have an obviously wrong formula to find the average of values entered. I am unsure of how to declare the weights, and how to write the formula to find the average weights. My coding is at this point is as follows:
#include<stdio.h>
#include<math.h>
int main(void)
{
int O, C, N, S, H ;
double Weight ;
printf("Enter number of atoms for O: \n") ;
scanf("%d", &O);
printf("Enter number of atoms for C: \n") ;
scanf("%d", &C) ;
printf("Enter number of atoms for N: \n") ;
scanf("%d", &N) ;
printf("Enter number of atoms for S: \n") ;
scanf("%d", &S) ;
printf("Enter number of atoms for H: \n") ;
scanf("%d", &H) ;
Weight = (O+C+N+S+H)/5 ;
printf("The average weight of the amino acid: %\n" , (O+C+N+S+H)/5 ) ;
system("PAUSE") ;
return (0) ;
}
Any help would be appreciated.