Hi there i have wrote a program ,The user can only Choose the letter S for square or R for rectangle..
i have done every thing as you can see ... the only problem that am having is if the user puts 's' small letter also 'r' small letter ..
So how can i fix this problem?
#include <stdio.h>
int main (void)
{
char choice ;
int a;
int b;
int area , perimeter ;
printf("Enter 'S' for Square or 'R' for rectangle :");
scanf(" %c",&choice);
if (choice == 'S')
{
printf("enter the length of the side of the sqaure:");
scanf(" %d",&a);
area = a * a;
printf("Area = %d \n",area);
perimeter = a * 4;
printf ("perimeter = %d \n",perimeter);
}
else
if (choice == 'R')
{
printf("enter the length and the width of the rectangle:");
scanf("%d%d",&a,&b);
area = a * b;
printf("Area = %d \n",area);
perimeter = area + 4;
printf ("perimeter = %d \n",perimeter);
}
else
printf("You can only choose 'S' for squrae or 'R' for rectangle\n");
system("system pause");
return 0 ;
}