hi all, I dont have any clue how to accomplish this. Pls provide ne clues ...Thanks..

Discussion in 'C' started by prietysharma121, Feb 26, 2010.

  1. prietysharma121

    prietysharma121 New Member

    Joined:
    Feb 26, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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 >>).
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28
    Re: hi all, I dont have any clue how to accomplish this. Pls provide ne clues ...Than

    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;    
    }
    
    
    happy coding
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice