Who can help me with the area of a rectangle. I can't make foolproof, ie the ban on entering letters and negative numbers.I just can not create a second condition when creating the first that refers to the letters. How can I do this, or I must even change the program from scratch. I just need to find the area of a rectangle.
#include "stdafx.h"
#include <stdio.h>
#include <math.h>
#include <locale.h>
#include <Windows.h>
int _tmain(int argc, char* argv[])
{
printf("Area of a Rectangle. Press Enter to start\n");
system("pause");
float a, s, d;
do
{
fflush(stdin);
system("cls");
printf("Enter the lengths of the rectangle\n");
scanf_s("%f", &a);
scanf_s("%f", &s);
if (getchar() != '\n') {
while (getchar() != '\n')
;
printf("Your data is wrong\n");
system("pause");
continue;
}
break;
} while (true);
d = a*s;
printf(" Area is %.1f ", d);
system("pause");
return 0;
}