Upload
vinay-arora
View
568
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
C Programming - Structures
Organized By: Vinay Arora
Assistant Professor, CSED
Thapar University, Patiala
Vinay Arora
CSED
Program - 1
#include<stdio.h>
#include<conio.h>
void main()
{
char name[3];
float price[3],i;
clrscr();
printf("Enter names, price of 3 books\n");
for(i=0;i<=2;i++)
scanf("\n%c %f",&name[i],&price[i]);
printf("\nAnd this is what you have entered\n");
for(i=0;i<=2;i++)
printf("%c %f\n",name[i],price[i]);
getch();
}
Vinay Arora
CSED
Program – 1 (output)
Vinay Arora
CSED
Program - 2
#include<stdio.h>
#include<conio.h>
void main()
{
struct book
{
char name;
float price;
};
struct book b1,b2,b3;
clrscr();
printf("Enter names, price of 3 books\n");
scanf("\n%c %f",&b1.name,&b1.price);
scanf("\n%c %f",&b2.name,&b2.price);
scanf("\n%c %f",&b3.name,&b3.price);
printf("\nAnd this is what you have entered\n");
printf("\n%c %f",b1.name,b1.price);
printf("\n%c %f",b2.name,b2.price);
printf("\n%c %f",b3.name,b3.price);
getch();
}
Vinay Arora
CSED
Program – 2 (output)
Vinay Arora
CSED
Thnx…