I have to take this program and do the exact same effect bu instead of passing by value through the function discriminate I need to pass pointers by reference.
Can anyone help?
My AIM: awedaveo
MSN: [email protected]
__________________________________________________
#include <stdio.h>
#include <math.h>
int discriminate(int a,int b,int c);
int main()
{
int a,b,c,d;
long double root1,root2;
char choice[1];
display_instructions();
while(1)
{
printf("Do you want to continue? y/n\n");
scanf("%s",&choice);
if(choice[0]=='n')
{
break;
}
printf("Please enter a value for a: \n");
scanf("%d",&a);
printf("\nPlease enter a value for b: \n");
scanf("%d",&b);
printf("\nPlease enter a value for c: \n");
scanf("%d",&c);
d=discriminate(a,b,c);
if(d>0)
{
root1=(-b+sqrt(d))/(2*a);
root2=(-b-sqrt(d))/(2*a);
printf("root1= %Lf\nroot2= %Lf\n",root1,root2);
}
else if(d==0)
{
root1=(-b+sqrt(d))/(2*a);
printf("root1=root2= %Lf\n",root1);
}
else
{
printf("Based on your values there is no solution.\n");
}
}
return 0;
}
int discriminate(int a,int b,int c)
{
int d;
d=(b*b)-(4*a*c);
return d;
}