In C language, char value is stored in 1 byte. A char type may contain a single letter, digit, control character or special character.
__avd
Posting Genius (adatapost)
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
>>if (length=breadth)
you are using the wrong operator -- use == boolean operator instead of = assignment operator.
>> shape= 'square';
Two problems with that line All strings (two or more characters) have to be enclosed in double quotes, such as "square"
variable [shape] can only hold a single character, such just do this: shape = 's'; . If you want shape to contain the entire string then redefine it as char shape[15]; and use strcpy() to copy it strcpy(shape,"square");
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
scanf("%f", &length);
length is an int, you are passing a float. Same with scanf("%f", &breadth);
Either you change the type in the declaration of length and breadth, or change the f to d in the calling of scanf().
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218
1) you failed to read Aia's comment.
2) The printf() statement is incorrect. %s is for a charcter array, shape is not a character array. What you want os %c
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343