0% found this document useful (0 votes)
4 views3 pages

VIT - Vellore

The document contains the academic details and lab results of a student named Khushi Srivastava from VIT, including her email, roll number, and course information. It outlines two programming problems related to calculating ticket costs and summing odd digits of an integer, along with the corresponding C code solutions. Both programming tasks received full marks, indicating correct implementation.

Uploaded by

khushibarbie04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

VIT - Vellore

The document contains the academic details and lab results of a student named Khushi Srivastava from VIT, including her email, roll number, and course information. It outlines two programming problems related to calculating ticket costs and summing odd digits of an integer, along with the corresponding C code solutions. Both programming tasks received full marks, indicating correct implementation.

Uploaded by

khushibarbie04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

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

tickets.If Kathir's age is 18 or older, he will receive a 5% discount on VIP


0

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

return discounted * (*ticks);

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;
}

Status : Correct Marks : 10/10


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.

Help him by writing the code.

Answer
// You are using GCC
#include<stdio.h>
0

40

40

40
04

void sumODD(int num,int *sum)


0

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;
}

Status : Correct Marks : 10/10


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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy