VIT - Vellore
VIT - Vellore
40
0
04
04
04
00
T0
T0
T0
T
BK
BK
BK
BK
Name: KHUSHI SRIVASTAVA . Scan to verify results
24
24
24
24
Email: khushi.srivastava2024@vitstudent.ac.in
Roll no: 24BKT0040
Phone: 9999999999
Branch: JASMIN T. JOSE_OOPS
Department: admin
Batch: VL2024250502006
Degree: admin
0
40
40
04
04
00
00
BCSE102P_Structured and Object Oriented Programming
T0
T0
KT
T
BK
BK
BK
Lab_VL2024250502006
B
24
24
24
24
VIT V_Structured and OOP_Lab 3_COD_Hard_Pointer Arithmetic
Attempt : 1
Total Mark : 20
Marks Obtained : 20
Section 1 : Coding
0
40
0
1. Problem Statement
04
04
04
00
T0
T0
T0
T
BK
BK
BK
Kathir aims to create a program to determine the total ticket cost for an BK
24
24
24
24
upcoming event, considering his age and the quantity of tickets he intends
to buy.
The available ticket types are Basic (Rs. 150.0) and VIP (Rs. 300.0), each
priced differently. The program should apply age-based discounts and
utilize pointers for price calculations.
Discount Calculation:
If Kathir's age is less than 18, he will receive a 10% discount on Basic
0
40
40
40
04
0
T0
T0
T0
T0
tickets.
BK
BK
BK
BK
24
24
24
24
Formulas Used: Total Cost = Discounted Price * Number of Tickets, where
0
40
0
04
04
04
00
Discounted Price = Original Price - (Original Price * Discount Percentage)
T0
T0
T0
T
BK
BK
BK
BK
24
24
24
24
Answer
// You are using GCC
#include<stdio.h>
double calc(int *age, int *ticks){
double basic=150.0,vip=300.0;
double discounted;
if (*age<18){
discounted = basic - (basic *0.10);
} else {
discounted = vip - (vip * 0.05);
0
40
40
04
04
00
00
T0
T0
KT
T
BK
BK
BK
B
}
24
24
24
24
int main(){
int age,n;
scanf("%d\n%d",&age,&n);
double total=calc(&age,&n);
printf("Rs.%.2lf\n",total);
return 0;
}
40
0
04
04
04
00
T0
T0
T0
T
BK
BK
BK
2. Problem Statement BK
24
24
24
24
Dev wants to write a program for a school project that takes an integer
input and calculates the sum of its odd digits using pointer arithmetic.
Answer
// You are using GCC
#include<stdio.h>
0
40
40
40
04
0
T0
T0
T0
T0
{
BK
BK
BK
BK
24
24
24
24
0
40
0
04
04
04
while(num!=0)
00
T0
T0
T0
T
{
BK
BK
BK
BK
int d = num%10;
24
24
24
24
if(d%2==0)
{
}
else
{
*sum = *sum+d;
}
num = num/10;
}
0
40
40
04
04
00
00
T0
T0
KT
T
int main()
BK
BK
BK
B
{
24
24
24
24
int n;
scanf("%d",&n);
int s = 0;
sumODD(n,&s);
printf("%d",s);
return 0;
}
40
0
04
04
04
00
T0
T0
T0
T
BK
BK
BK
BK
24
24
24
24
0
40
40
40
04
0
T0
T0
T0
T0
BK
BK
BK
BK
24
24
24
24