Write a C program to display the Product information and Payment mode of a customer using bit fields.
* The product information are P_rice=0, P_wheat=1, P_dall=2, P_sugar=3, Cash=5 and Card=6
* The bit fields member functions are Ptype, Pmode and *Pname is character type
#include<stdio.h>
#include <string.h>
struct Product{
unsigned int P_rice;
unsigned int P_wheat ;
unsigned int P_dall;
unsigned int P_sugar;
unsigned int Cash;
unsigned int Card;
//unsigned int product_information[7];
};
void Ptype(){
struct Product c = { 0, 1, 2, 3, 5 ,6};
c.P_rice = 0;
printf("P_rice%d=\t", c.P_rice);
printf("\nP_wheat= %d\t",c.P_wheat);
printf("\nP_dall= %d\t",c.P_dall);
printf("\nP_sugar =%d\t",c.P_sugar);
printf("\nP_wheat= %d\t",c.P_wheat);
}
void Pmode(){
struct Product c = { 0, 1, 2, 3, 5 ,6};
printf("\nP_sugar =%d\t",c.P_cash);
printf("\nP_wheat= %d\t",c.P_card);
}
char *Pname(int n){
}
int main(){
struct Product c;
Ptype();
}
Comments
Leave a comment