Access Millions of academic & study documents

A mathematical operation where all operands are type char is Why

Content type
User Generated
Showing Page:
1/2
A mathematical operation where all
operands are type char is: Why?
A. illegal - type of char is only used for
character operations.
B. evaluated using type signed char
arithmetic.
C. evaluated using type char arithmetic.
D. evaluated using type int or unsigned int
arithmetic.
E. not as accurate as an operation with all
type long operands.
Solution
C) Evaluated using type char arithmetic
In fact, you don\'t need to even type cast the chars for
doing this with a single char:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
char f1 = \'9\';
char f2 = \'7\';
int v = (f1 - \'0\') - (f2 - \'0\');
printf(\"%d\ \", v);

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
A mathematical operation where all operands are type char is: Why? A. illegal - type of char is only used for character operations. B. evaluated using type signed char arithmetic. C. evaluated using type char arithmetic. D. evaluated using type int or unsigned int arithmetic. E. not as accurate as an operation with all type long operands. Solution C) Evaluated using type char arithmetic In fact, you don\'t need to even type cast the chars for doing this with a single char: #include #include int main(int argc, char* argv[]) { char f1 = \'9\'; char f2 = \'7\'; int v = (f1 ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4