Access over 20 million homework & study documents

Some basic C programs

Content type
User Generated
Rating
Showing Page:
1/4
//module-5, assignment-2, (q2) find the sum of the squares of n
numbers:
#include<stdio.h>
#include<conio.h>
#include<math.h>
main(){
int i=1, n;
float x, sum=0;
printf("number of values:");
scanf("%d",&n);
while(i<=n){
printf("\nenter the value of x%d=",i);
scanf("%f",&x);
sum=sum+(x*x);
i=i+1;
}
printf("\nthe required sum of the squares is: %f", sum);
return 0;}

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
//module-5,assignment-2, (q3) How to find the harmonic mean of n
numbers?
#include<stdio.h>
#include<conio.h>
main(){
int i=1, n;
float x, H, k=0;
printf("enter the number of inputs:");
scanf("%d",&n);
while(i<=n){
printf("\nenter the value of x%d=",i);
scanf("%f",&x);
k=k+(1/x);
i++;
}
H=n/k;
printf("\nThe harmonic mean of the given numbers is:H=%f", H);
return 0;
}

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now
Unformatted Attachment Preview
//module-5, assignment-2, (q2) find the sum of the squares of n numbers: #include #include #include main(){ int i=1, n; float x, sum=0; printf("number of values:"); scanf("%d",&n); while(i ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really helpful material, saved me a great deal of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4