1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Pls help me..asap

Discussion in 'C' started by farahlyna, Aug 28, 2010.

  1. farahlyna

    farahlyna Guest

    In C a structure is passed to a function by value. This means that the structure valued is copied for processing in the body of the function. Therefore any changes made to the value by the function would not give any effect on the value of the structure Any idea for me to insert the function void for this program..


    struct book{

    char title[80];
    int bar_code;
    float price;

    struct book BOOK;
    float price2,discount;
    void main(){

    struct book *ptr;
    ptr = &BOOK;

    /**scanf("%s", &ptr->title);**/
    printf("bar code:");
    scanf("%d", &ptr->bar_code);
    scanf("%f", &ptr->price);

    price2 = ptr->price;
    if (price2>=100) {
    discount =price2-(price2*0.10);

    printf("discount price:%.2f",discount);

    printf("%s\n", ptr->title);
    printf("Before Discount:%.2f\n", ptr->price);
    printf("After Discount:%.2f\n", discount) ;

Share This Page