Let Veen be the set of all vectors of length n each component of which comes fro
ID: 3184940 • Letter: L
Question
Let Veen be the set of all vectors of length n each component of which comes from range(n). For example, (3, 0, 2, 2) E Vec4. If v E Vecn, a quirk is defined as a pair (i, j) such that 0 si vil Kn- (a) (4 points) Create a sample space consisting of the elements of Vec3. List all the elements of this space. Turn it into a probability space by using the uniform distribution Finally, compute the average number of quirks in members of Vec3. (b) 6 points) Generalize the results of Part (a) to determine the average umber of quirks in members of Vecn. You do not need to list the elements of Ven.Explanation / Answer
#include <stdio.h>
struct student
{
char name[50];
int Age;
char Country_Name[20];
char City_Name[20];
float Height;
float Weight;
char Education[20];
} s[8];
void getAverage(float,float);
void Increase(float,float);
int main()
{
int i;
printf("Enter information of students: ");
for(i=0; i<8; ++i)
{
printf("Enter name: ");
scanf("%s",s[i].name);
printf("Enter Age: ");
scanf("%d",&s[i].Age);
printf("Enter Country Name: ");
scanf("%s",s[i].Country_Name);
printf("Enter the City Name: ");
scanf("%s",s[i].City_Name);
printf("Enter the Height: ");
scanf("%f",&s[i].Height);
printf("Enter the Weight: ");
scanf("%f",&s[i].Weight);
printf("Enter the education : ");
scanf("%s",s[i].Education);
printf(" ");
}
printf("Displaying Information: ");
for(i=0; i<8; ++i)
{
printf("Name: ");
puts(s[i].name);
printf("Age: %d ",s[i].Age);
printf("Country Name: ");
puts(s[i].Country_Name);
printf("City Name: ");
puts(s[i].City_Name);
printf("Height: %.1f ",s[i].Height);
printf("Weight: %.1f ",s[i].Weight);
printf("Education: ");
puts(s[i].Education);
printf(" ");
}
getAverage(s[i].Height,s[i].Weight);
Increase(s[0].Height,s[0].Weight);
return 0;
}
void getAverage(float x,float y)
{
int i,total=0,sum=0;
for(i=0;i<8;i++)
{
total += s[i].Weight;
x = total/8;
sum += s[i].Height;
y = sum/8;
}
printf("The average Weight is %.2f ",x);
printf("The average Height is %.2f ",y);
}
void Increase(float x1,float y1)
{
x1 =(s[0].Weight/5)+(s[0].Weight);
y1 =(s[0].Height/5)+(s[0].Height);
printf("The new weight of person 1: %.2f ",x1);
printf("The new height of person 1: %.2f",y1);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.