0% found this document useful (0 votes)
30 views4 pages

Iiop

The document describes a C++ program that takes customer information like ID, name, purchase amount and calculates discount and net amount to be paid based on purchase amount. The program uses a structure to store customer data and loops through 5 customers to input data and display output.

Uploaded by

umangpatel0412
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views4 pages

Iiop

The document describes a C++ program that takes customer information like ID, name, purchase amount and calculates discount and net amount to be paid based on purchase amount. The program uses a structure to store customer data and loops through 5 customers to input data and display output.

Uploaded by

umangpatel0412
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

//Program 23:-To enter the contents of 5 customers & print dis. & net amt.

//Milan S Patel,Class:XI B,Roll No:19;Date:4/10/10


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct customer
{ int cust_id;
char name[25];
float P_amt;
float net_amt;
int disc;
}c[5];
void main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
cout<<"Enter the customer ID :";
cin>>c[i].cust_id;
cout<<"Enter the name of the customer :";
gets(c[i].name);
cout<<"Enter the purchase amount :";
cin>>c[i].P_amt;
if(c[i].P_amt>=10000)
c[i].disc=c[i].P_amt*0.10;
else if(c[i].P_amt>=5000)
c[i].disc=c[i].P_amt*0.07;
else
c[i].disc=c[i].P_amt*0.05;
c[i].net_amt=c[i].P_amt-c[i].disc;
cout<<"The customer ID is : "<<c[i].cust_id<<"\n";
cout<<"The name of the customer is : "<<c[i].name<<"\n";
cout<<"The purchase amount is : "<<c[i].P_amt<<"\n";
cout<<"The discount given to customer is : "<<c[i].disc<<"\n";
cout<<"The net amount to be paid is : "<<c[i].net_amt<<"\n";
}
getch();
}

Page no:- 27
Output:-
Enter the customer ID :1
Enter the name of the customer :Ram
Enter the purchase amount :10000
The customer ID is : 1
The name of the customer is : Ram
The purchase amount is : 10000
The discount given to customer is : 1000
The net amount to be paid is : 9000

Enter the customer ID :2


Enter the name of the customer :Shyam
Enter the purchase amount :5000
The customer ID is : 2
The name of the customer is : Shyam
The purchase amount is : 5000
The discount given to customer is : 350
The net amount to be paid is : 4650

Enter the customer ID :3


Enter the name of the customer :Rahul
Enter the purchase amount :9999
The customer ID is : 3
The name of the customer is : Rahul
The purchase amount is : 9999
The discount given to customer is : 699
The net amount to be paid is : 9300

Enter the customer ID :4


Enter the name of the customer :Vivek
Enter the purchase amount :4999
The customer ID is : 4
The name of the customer is : Vivek
The purchase amount is : 4999
The discount given to customer is : 249
The net amount to be paid is : 4750

Enter the customer ID :5


Enter the name of the customer :VVS Laxman
Enter the purchase amount :12000
The customer ID is : 5
The name of the customer is : VVS Laxman
The purchase amount is : 12000 Signature:-
The discount given to customer is : 1200
The net amount to be paid is : 10800 Page no :-28
//Program 24:-To cal distance using structure whose members are m & cm
//Milan S Patel,Class:-XI B,Roll No:19,Date:11/10/10
#include<iostream.h>
#include<conio.h>
struct dist
{ int m;
int cm;
};
void main()
{
dist d1,d2;
clrscr();
cout<<"Enter the distance 1 in m & cm:\n";
cin>>d1.m>>d1.cm;
cout<<"Enter the distance 2 in m & cm:\n";
cin>>d2.m>>d2.cm;
void distance(dist &,dist &);
distance(d1,d2);
getch();
}
void distance(dist &d1,dist &d2)
{
dist d3;
d3.m=d1.m+d2.m+(d1.cm+d2.cm)/100;
d3.cm=(d1.cm+d2.cm)%100;
cout<<"The total distance="<<d3.m<<" metres and "<<d3.cm<<"
centimetres";
}

Output:-
Enter the distance 1 in m & cm:
1
50
Enter the distance 2 in m & cm:
2
75
The total distance=4 metres and 25 centimetres

Signature:-

Page No:-29

You might also like