Write a C program that asks the user to enter the value of the mathematical constant Pi to three decimal places. If the value is not entered correctly as 3.142, the program will allow the user to enter the value again until the correct value is entered.
After the correct value is entered, simply print on screen, "Thank you very much... have a nice day..."
Include explicit instructions for the user.
C program to enter the value of mathematical constant pi to 3 decimal places.?
//Program to Input the value of PI as 3.412
#include%26lt;conio.h%26gt;
#include%26lt;stdio.h%26gt;
void main(){
const float PI=3.142;
float input=0.0;
clrscr();
while(input!=PI){
printf("Enter the value of PI correct to 3 decimal places: ");
scanf("%f",%26amp;input);
if(input==PI)
printf("\n\nThank you very much... have a nice day...");
else printf("\n\nWrong value entered...Please try again...");
getch();
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment