Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

wtf?

Name: newfag 2010-11-04 0:45

hey all, im a newfag at programming and im taking a year one programming course at the university, (im year 3 maths) and i need sone help i have no idea wtf to do and my teacher speaks borderline english.

i need to make this program below using call by referance instead of call by value, i have no idea how to do this, so if anone could get me started,,, or anything i would really appriciate it =)



#include <stdio.h>
#include <math.h>

double washerweight(int, double, double, double, double, double);
double circlearea(double, double);
void printweight(char, int, double, double, double);

void main(void)
{

double washer1 = 'A', washer2 = 'B', washer3 = 'C', washer4 = 'D';
int q1, q2, q3, q4;
double t1, t2, t3, t4;
double d1, d2, d3, d4;
double dA1, dA2, dB1, dB2, dC1, dC2, dD1, dD2;
double pi = 3.14159265;

double weight1, weight2, weight3, weight4;
double total_weight;
double area1, area2, area3, area4;

printf("Enter quantity, thickness, density, inner diameter, outer diameter of Washer Type A : \n");
scanf("%d %lf %lf %lf %lf", &q1, &t1, &d1, &dA1, &dA2);
printf("Enter quantity, thickness, density, inner diameter, outer diameter of Washer Type B : \n");
scanf("%d %lf %lf %lf %lf", &q2, &t2, &d2, &dB1, &dB2);
printf("Enter quantity, thickness, density, inner diameter, outer diameter of Washer Type C : \n");
scanf("%d %lf %lf %lf %lf", &q3, &t3, &d3, &dC1, &dC2);
printf("Enter quantity, thickness, density, inner diameter, outer diameter of Washer Type D : \n");
scanf("%d %lf %lf %lf %lf", &q4, &t4, &d4, &dD1, &dD2);

weight1 = washerweight(q1, t1, d1, dA1, dA2, pi);
weight2 = washerweight(q2, t2, d2, dB1, dB2, pi);
weight3 = washerweight(q3, t3, d3, dC1, dC2, pi);
weight4 = washerweight(q4, t4, d4, dD1, dD2, pi);
total_weight = weight1 + weight2 + weight3 + weight4;

printf("Washer Type \t Qty \t Thickness \t Desity \t Weight \n ") ;
PrintWeight(washer1, q1, t1, d1, weight1);
PrintWeight(washer2, q2, t2, d2, weight2);
PrintWeight(washer3, q3, t3, d3, weight3);
PrintWeight(washer4, q4, t4, d4, weight4);
printf("********************************************** \t %0.2f \n", total_weight);
}

double washerweight(int q, double t, double d, double d1, double d2, double pi)
{
double area, iarea, oarea, weight;
oarea = circlearea(&d2,pi);
iarea = circlearea(&d1, pi);
area = oarea - iarea;
weight = q * t *d * area;
return (weight);
}

double circlearea(double d, double pi)
{
double rad;
rad = d/2.0;
return (pi * rad * rad);
}

void printweight(char washer, int q, double t, double d, double weight)
{
printf("%c \t \t %d \t %0.2lf \t \t %0.2lf \t %0.2lf \n ", washer, q, t, d, weight) ;
}

Name: Anonymous 2010-11-04 21:19

"call by reference"
I assume he means use a reference parameter. So do it, you nigger.

void op(bool IsAFaggot);
to
void op(bool &IsAFaggot);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List