DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
Computer Programming
(CS234P)
B. Tech Degree- CHEMISTRY CYCLE
School of Engineering and Technology,
CHRIST (Deemed to be University),
Kumbalagodu, Bengaluru-560 074
April 2022
Certificate
This is to certify that ………………………………………………. has successfully completed
the record work for Computer Programming – CS234P in partial fulfillment for the award of
Bachelor of Technology in during the year 2021-2022.
Dr. K. Balachandran
HEAD OF DEPARTMENT FACULTY- IN CHARGE
EXAMINER 1:
EXAMINER 2:
Name :
Register No. :
Examination Center :
Date of Examination :
INDEX
Exp. No Date Experiment Name Page No Marks Signature
29-01-2
1 Sequential Programming
022
[Link]: 1 Date: 29-01-2022
SEQUENTIAL PROGRAMMING
PROBLEM GIVEN:
Write a program to store the following patient details – Patient Id, Age, Weight, and Patient
Category( Inpatient - 'I', Outpatient – 'O') and annual income, Number of days admitted. Declare
variables of appropriate data types, read the values from the user. Calculate the total cost to the
patient ( per day charge is Rs200/-). Display the patient summary as a form.
ALGORITHM:
Step 1: Start
Step 2: declare customer age, id,name,number,roomtype
Step 3: input datas using printf scanf
Step 4: ask the type of room required, calculate room price with gst for duration of stay
Step 5: Stop
PROGRAM:
# include <stdio.h>
# include <math.h>
void main()
char name[20],type[2],roomtype[2],ac[2];
int id,age,duration;
float bill;
printf("**************************************\nDOMAIN:HOTEL MANAGEMENT \n
NAME:SPURGEN \n ROLL NO. 2161008\n**************************************");
printf("\n\nEnter your ID card details: ");
scanf("%d",&id);
printf(" Enter your name:");
scanf("%s",&name);
printf("Enter your age:");
scanf("%d",&age);
printf("Select customer type: \n PERMANENT[P],TEMPORARY[T]:");
scanf("%s",&type);
printf("Select the room type preferred\n SINGLE[S],DOUBLE[D]:");
scanf("%s",&roomtype);
printf("AC required?[Y/N]:");
scanf("%s",&ac);
printf("Stay duration in hours:");
scanf("%d",&duration);
printf("******RATE MANUAL*******\nRates per hour\n SINGLE WITH AC-150\nSINGLE
WITHOUT AC-100\nDOUBLE WITH AC-200\nDOUBLE WITHOUT AC-150");
printf("\nEnter bill amount based on rate manual:");
scanf("%f",&bill);
const float total=bill*duration*(0.15+1);
printf("******BILL DETAILS******\nNAME:%s",name);
printf("\nID NUMBER:%d",id);
printf("\nAGE:%d",age);
printf("\nDURATION OF STAY:%d",duration);
printf("\n ROOM TYPE:S-SINGLE,D-DOUBLE:%s",roomtype);
printf("\nYOUR TOTAL PAYABLE BILL AMOUNT INCLUDING GST:%f",total);
printf("\n\n***********THANK YOU,VISIT
AGAIN***********\n**********************************************************");
OUTPUT:
[Link]: 2 Date: 29-01-2022
SEQUENTIAL PROGRAMMING
PROBLEM GIVEN:
Write a program to generate the bill for the Hotel according to the following rules:1. Depending on the room type opted by the
customer assign the room rent to calculate the total room rent (single non ac - Rs 1000/-, Single A/C Rs 1500/-, Double Non A/C
Rs 2000/- Double A/C Rs 2500/.) 2. If the customer is a regular customer, 10% of reduction in the rent of the Hotel. (extend the
previous program to implement the above). Display the final bill with all the necessary details.
ALGORITHM:
Step 1: Start
Step 2: input name,id,roomtype,stay duration,customer type etc
Step 3: if roomtype is single ac bill=1500
If roomtype is single non ac bill=1000
If room type is double ac bill=2500
If room type is double non ac bill=2000
Step 4: if customer is permanent eligible for 10% discount
Step 5: Stop
PROGRAM:
# include <stdio.h>
# include <math.h>
int main()
{
int num1,num2,num3,num4;
char Roomcode,type;
float bill;
printf("Manual for Room types***single ac 1, single non ac 2, double ac 3, double non ac 4*******");
fflush(stdin);
printf("please enter the room type");
scanf("%d",&num1);
if(num1==2)
{
printf("You are allotted a single non ac room. Please pay Rs.1000. Thank you****f");
}
else if((num1=1))
{
printf("your allotted room is single with ac. PLease pay Rs.1500. Thank you****");}
else if((num1=4))
{printf(" You are alotted Double room with non [Link] pay Rs.2000. THank you****");}
else
{
printf("You are allotted Double room with AC. Please pay Rs.2500. Thank you****");
}
printf("Are you a regular customer?");
fflush(stdin);
scanf("%c",&type);
if(type=='Y')
{
printf("Congradulations. You are eligible for a 10 percent discount");
printf("\nEnter bill amount based on rate manual:");
scanf("%f",&bill);
const float total=bill*(1-0.1);
printf("Total bill:%f",total);
printf("Thank you. Visit Again");
}
else{
printf("Sorry. You are not eligible for the discount****");
printf("Please pay the room fare and collect your key. Thank you. Visit again");
}
}
OUTPUT:
[Link]: 3 Date: 29-01-2022
SEQUENTIAL PROGRAMMING
PROBLEM GIVEN:
Write a program to display a menu to the passenger using switch case for the following - 1. Customer Profile 2. Discount
calculation. 3. e-Bill. Extend the previous program to implement the program.
ALGORITHM:
Step 1: Start
Step 2 :input name,age,id,roomtype,custmertype etc
Step 3: switch(details)
Step 4 case 1-bill details
Case 2-amount details
Case 3-discount details
Step 5: Stop
#include<stdio.h>
#include<math.h>
int main()
{
int id,num1,option;
char name,type;
float bill,total;
printf("Please type your name");
scanf("%c",&name);
fflush(stdin);
printf("please type your customer id");
scanf("%d",&id);
printf("Thank you");
printf("Manual for Room types***single ac 1, single non ac 2, double ac 3, double non
ac 4*******");
printf("please enter the room type");
scanf("%d",&num1);
if(num1==2)
{
printf("You are allotted a single non ac room. Please pay Rs.1000. Thank
you****");
}
else if((num1=1))
{
printf("your allotted room is single with ac. PLease pay Rs.1500. Thank
you****");}
else if((num1=4))
{printf(" You are alotted Double room with non [Link] pay Rs.2000. THank
you****");}
else
{
printf("You are allotted Double room with AC. Please pay Rs.2500. Thank
you****");
}
printf("Are you a regular customer?");
fflush(stdin);
scanf("%c",&type);
if(type=='Y')
{
printf("Congradulations. You are eligible for a 10 percent discount");
printf("\nEnter bill amount based on rate manual:");
scanf("%f",&bill);
const float total=bill*(1-0.1);
printf("Total bill:%f",total);
printf("Thank you. Visit Again ");
}
else{
printf("Sorry. You are not eligible for the discount****");
printf("Please pay the room fare and collect your key. Thank you. Visit
again");
}
printf("Please click 1 for customer details, 2 for discount details and 3 for bill
details");
scanf("%d",&option);
switch(option)
{case 1:
printf("Name:%c",name);
printf("Customer id:%d",id);
break;
case 2:
printf("Total bill excluding discount:%f",bill);
printf("Total bill after discount:%f",total);
printf("Discount percentage:10per");
break;
case 3:
printf("Customer name:%c",name);
printf("Customer id:%d",id);
printf("Total bill after discount:%f",total);
printf("Discount percentage:10per");
break;
case 4:
printf("Original rate for the room:3000 ");
printf("Total bill after discount:2500 ");
break;
}
}
OUTPUT:
[Link] : 2a Date:
PROGRAMMING HEADING
PROBLEM GIVEN:
Write the given problem statement
ALGORITHM:
PROGRAM:
OUTPUT:
[Link] : 4a Date:
1D Arrays
PROBLEM GIVEN:
Write a program to include an Exit Option by the user. The menu should be displayed, only if the
user selects the option 4. Exit should the loop run. Use do while to implement the same. Extend
the previous program to implement the program.
ALGORITHM:
Step 1: start
Step 2: input name,age,id,roomtype,customer type
Step 3: customer details
step 4:case1-bill,case2-amount,case3-discount,case4 exit
step 5:exit program when 4 is selected
step 6: stop
PROGRAM:
#include<stdio.h>
#include<math.h>
int main()
int i,roomnum,id,num1,option,numofrooms,num2;
char name,type;
float bill,bill2,total;
printf("Please type your name::");
scanf("%c",&name);
fflush(stdin);
printf("please type your customer id");
scanf("%d",&id);
printf("Thank you");
printf("Enter the number of rooms required:");
scanf("%d",&numofrooms);
printf("required number of rooms:%d",numofrooms);
printf("Manual for Room types***single ac 1, single non ac 2, double ac 3, double non
ac 4*******");
printf("please enter the room type");
scanf("%d",&num1);
if(num1==2)
printf("You are allotted a single non ac room. Please pay Rs.1000 per room. Thank
you****");
bill=1000;
else if((num1=1))
{
printf("your allotted room is single with ac. PLease pay Rs.1500 per room. Thank
you****");
bill=1500;
else if((num1=4))
{printf(" You are alotted Double room with non [Link] pay Rs.2000 per room. THank
you****");
bill=2000;
else
printf("You are allotted Double room with AC. Please pay Rs.2500 per room. Thank
you****");
bill=2500;
bill2=numofrooms*bill;
printf("total bill:%d",total);
do
printf("Please click 1 for customer details, 2 for discount details and 3 for bill
details and 4 to exit");
scanf("%d",&option);
switch(option)
{case 1:
printf("Name:%c",name);
printf("Customer id:%d",id);
break;
case 2:
printf("Total bill excluding discount:%f",bill);
printf("Total bill:%f",total);
printf("Discount percentage:10per");
break;
case 3:
printf("Customer name:%c",name);
printf("Customer id:%d",id);
printf("Total bill after discount:%f",total);
printf("Discount percentage:10per");
break;
case 4:
printf("You have exited the program");
break;
}
while(option<=4);
OUTPUT:
[Link] : 4a Date:
1D Arrays
PROBLEM GIVEN:
Write a program to include an Exit Option by the user. The menu should be displayed, only if the
user selects the option 4. Exit should the loop run. Use do while to implement the same. Extend
the previous program to implement the program.
ALGORITHM:
Step 1: start
Step 2: input i,j
Step 3: print n values
step 4: if i=4 check if i<=6, if yes increase i by i++
step 5:if j=1 check if j<=i, if yes increase j by j++
step 6: stop
PROGRAM:
#include <stdio.h>
int main ()
int i,j;
int k=1;
for (i=4;i<=6;i++)
{
for (j=1;j<=i;j++)
printf("%d\t",k);
k++;
printf("\n");
OUTPUT:
[Link] : 5 Date:
1D Arrays
PROBLEM GIVEN:
write a program to store the data of customers and search for a given costumer by name or
number and display details of costomer.
ALGORITHM:
Step 1: start
Step 2: enter no. of customers
Step 3: for (i=0; i<n; i++)
step 4: Enter name, id ,age,ph number
step 5: Enter customer number to be searched
step 6: for(i=0; i<n; i++) if (num[i]==x)
step 7: Print name,age,id,ph number
step 8: stop
PROGRAM:
#include<stdio.h>
int main()
int id[10],num[10],age[5],ph[10],n,i,j,x;
char name[10][10],roomtype;
printf("enter no. of customers ");
scanf("%d",&n);
for(i=0;i<n;i++) {
printf("enter customer no.");
fflush(stdin);
scanf("%d",&num[i]);
printf("enter name:");
fflush(stdin);
scanf("%s",&name[i]);
printf("enter id:");
fflush(stdin);
scanf("%d",&id[i]);
printf("enter age:");
fflush(stdin);
scanf("%d",&age[i]);
printf("enter phone number:");
fflush(stdin);
scanf("%d",&ph[i]);
}
printf("enter customer no. to search:");
scanf("%d",&x);
for(i=0;i<n;i++) {
if(num[i]==x)
printf("the searched customer no. is %d\n",num[i]);
printf("name:%s\n",&name[i]);
printf("id:%d\n",id[i]);
printf("age:%d\n",age[i]);
printf("phone number:%d\n",ph[i]);
}
OUTPUT:
[Link] : 6 Date:
1D Arrays
PROBLEM GIVEN:
Write a program in C using 2D Arrays to display the following pattern
1234
5678
9 10 11 12
ALGORITHM:
Step 1: start
Step 2: k=1 for(i=o;i<3;i++)
Step 3: for (j=0; j<n; j++)
step 4: print k value
step 5: k++
step 6: stop
PROGRAM:
#include <stdio.h>
int main()
int a[3][4];
int k=1,i,j;
for(i=0;i<3;i++)
for(j=0;j<4;j++)
printf("%d\t",k);
k++;
}printf("\n");
OUTPUT: