i know it may is very simple but can someone tell me how to ask a question in c
Ive tried everything i could but i cant figure this out when i ask do you want to enter a new value if ans is y do this otherwise do nothing can someone please help
Code:
#include<stdio.h>
#include<math.h>
float R1;
float R2;
float Rf;
float Rf2;
float Vin;
float Vin2;
float Vout;
float Vout2;
int ans;
int n;
int y;
void main( )
{
do
{
printf("Please enter a value for Voltage -->");
scanf("%f",&Vin);
}while(Vin<0);
do
{
printf("Please enter a value for Resistor 1 -->");
scanf("%f",&R1);
}while(R1<0);
do
{
printf("Please enter a value for Resistor f -->");
scanf("%f",&Rf);
}while(Rf<0);
Vout=-Rf*(Vin/R1);
printf("Voltage out is =%f \n\n",Vout);
printf("Your Voltage in was%f \n\n",Vin);
printf("Would you like to enter a new value?(y/n)\n\n");
scanf("%d",n,y);
if(ans=y)
{
do
{
printf("Please enter a value for Voltage -->");
scanf("%f",&Vin2);
}while(Vin2<0);
{
printf("Please enter a value for Resistor 1 -->");
scanf("%f",&R2);
}while(R2<0);
{
printf("Please enter a value for Resistor f -->");
scanf("%f",&Rf2);
}while(Rf2<0);
Vout2=-Rf2*(Vin2/R2);
printf("Voltage out is =%f \n\n",Vout2);
printf("Your Voltage in was%f \n\n",Vin2);
}
else
{
scanf("%d",n);
printf("Thank you for using the program please press enter to terminate the program\n\n\n\n",n);
}
}