hello everybody,
I need some help regarding my project.....any hints clues will be highly appreciated.....Thanks its very urgent .....
This project will require you to develop three C functions:
float nandFloatMul(float a, float b) float nandFloatAdd(float a, float b) float nandFloatSub(float a, float b)
Each of the above functions takes as input two float operands and returns their product, sum, and difference, respectively, as a float.
You must also implement the following “helper” functions:
int boolNand(int i, int j)
int bitWiseNand(int i, int j)
Notes: 1. boolNand() returns zero if and only if both inputs are not zero. 2. bitWiseNand() returns the bit-wise nand of the inputs. 3. You may implement versions of boolNand() and bitWiseNand() in any,
or all, integral C data types. Requirements:
1. In implementing your nandFloat*() functions, you may only use: (a) boolNand(), (b) bitWiseNand(), (c) the C assignment (=) operator, and (d) the C shifting operators (<< and >>).
hi all, I dont have any clue how to accomplish this. Pls provide ne clues ...Thanks..
|
Newbie Member
|
|
| 27Feb2010,01:22 | #1 |
|
Pro contributor
|
![]() |
| 28Feb2010,05:34 | #2 |
|
this is the skeleton of your program.You must edit
nandFoat* functions to supply your instructions. the other 2 helper functions are ok. Code:
#include <stdio.h>
float nandFloatMul(float, float);
float nandFloatAdd(float, float);
float nandFloatSub(float, float);
int boolNand(int , int );
int bitWiseNand(int, int);
float nandFloatMul(float a, float b){
return a*b;
}
float nandFloatAdd(float a, float b){
return a+b;
}
float nandFloatSub(float a, float b){
return a-b;
}
int boolNand(int i, int j){
if (i!=0 && j!=0) return 0;
return 1;
}
int bitWiseNand(int i, int j){
return !(i&j);
}
int main(){
float a=5.3,b=6.3;
printf("\n%f*%f=%5.4f",a,b,nandFloatMul(a,b));
printf("\n%f+%f=%5.4f",a,b,nandFloatAdd(a,b));
printf("\n%f-%f=%5.4f",a,b,nandFloatSub(a,b));
int a1=1,b1=1;
printf("\nNAND(%d,%d)=%d",a1,b1,boolNand(a1,b1));
printf("\nbitwise NAND(%d,%d)=%d",a1,b1,bitWiseNand(a1,b1));
getchar();
return 0;
}
|

