-->

q36)Wap to display those records which have price >340. Records are with fields name,price and edition.

//Wap to display those records which have price >340. Records are with fields name,price and edition.
#include<stdio.h>
include<conio.h>
void main()
{
FILE *k;                                                                    //  pointer for file declaration
char book_name[30],author_name[40];                   //identifier declaration
int book_edition;                                                         //       "             "
k=fopen("book.dat","r");

while((fscanf(k,"%d %s %d",&book_price,book_name,&book_edition)!=EOF))//reading data from data file
{
 if(book_price>340)                                                   // condition validating
{
printf("book name=%s ,book edition=%d and price=%d",book_name,book edition,book_price); //displaying data
}
}
fclose(k);                                                                                   //closing data file
getch();
}

No comments:

Post a Comment