0% found this document useful (0 votes)
3 views

may 2023 PIC

The document outlines the syllabus for the IB.Tech I Semester Supplementary Examinations in May 2023 for the Programming in C course. It includes various programming tasks, such as computing sums of even and odd integers, checking Fibonacci primes, memory variable locations, creating balanced meals using structures, text file error correction, and solving the Towers of Hanoi problem. Each section contains specific programming challenges to be completed for assessment.
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)
3 views

may 2023 PIC

The document outlines the syllabus for the IB.Tech I Semester Supplementary Examinations in May 2023 for the Programming in C course. It includes various programming tasks, such as computing sums of even and odd integers, checking Fibonacci primes, memory variable locations, creating balanced meals using structures, text file error correction, and solving the Towers of Hanoi problem. Each section contains specific programming challenges to be completed for assessment.
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/ 2

Regulation: R22 Code No: 22TP103/05

IB.TechI Semester Supplementary Examinations – May, 2023


PROGRAMMING IN C
(BT, BI, BME, CIVIL, CSE, CSE-CS, CSE-DS, IT, MECH)
Time: 150 Min Max. Marks: 80M
SECTION – A
Answer all Four questions 4×10M=40M
1. Design three versions of a program that computes the sum of the first n even integers and the
sum of the first n odd integers. The value for n should be entered interactively. In the first
version of your program, use the code
for (cnt = 0, i = 1, j = 2; cnt< n; ++ cnt, i += 2, j += 2)
odd_sum += i,
even_sum += j;
a. Note the prolific use of the comma operator. The code is not very good, but it will give
you confidence that the comma operator works as advertised.
b. Design the second version by using one or more for statements but no comma operators.
c. Design the third version, which use only while statements.
2. Define a function, say is_ fib_prime () and impliment the following:
a. Design in such a way, the defined function shouldchecks whether the nth Fibonacci number
is prime or not.
b. In the defined function, call two other functions: the iterative version Fibonacci () and the
function is_prime ().
c. For n between 3 and 10, it is true that the nth Fibonacci number is prime if and only if n is
prime. Define a function to evaluate, what happens when n is bigger than 10, by using is_
fib_prime ().
3. When variables are declared, are they located in memory contiguously? Design a program with
the declaration
char a, b, c, *p, *q, *r
a. Print out the locations that are assigned to all these variables by your compiler.
b. Evaluate, whether allthe locations are in order?
c. If the locations are in order, analyze whether they are in increasing or decreasing?
d. Define, is the address of each pointer variable divisible by 4?
e. If so, this probably means that each pointer value gets stored in a machine word.
4. Design a program that is able to produce a balanced meal and implement the following task.
a. Create a structure that contains the name of a food, its calories per serving, its food type
such as meat or fruit, and its costs.
b. Create an array of structure to store the.
c. Design / Create the program such a way, it should construct a meal that comes from four
different food types and that meets calorie and cost constraints.
d. Design the program in such a way, it should be capable of producing a large number of
different menus.

1 of 2
Regulation: R22 Code No: 22TP103/05

SECTION-B
Answer all Two questions 2×20M=40M

5. Large corpus of text file is available. But the problem in that text file is that there are many
errors.’a’ is written as ‘@’,’b’ is written as ‘p’, ‘p’ is written as ‘o’,’@’ is written as ‘b’,’o’ is
written as ‘a’,’.’ is written as ‘#’,’#’ is written as ‘?’,’?’ is written as ‘.’. Implement the
following tasks:
a. Read the text and clean the text by correcting them.
b. Find number of sentences
c. Find total number of words.
d. Find the number of words having “@#abp” sequence in them.
e. Find largest word without any special characters.
f. Print the unique words that does not have any special characters.
g. Print all the words having only digits.

6.In the game called Towers of Hanoi, there are three towers labeled A, B, and C. The game starts
with n disks on tower A. For simplicity, suppose n is 5. The disks are numbered from 1 to 5,
and without loss of generality we may assume that the diameter of each disk is the same as its
number. That is, disk 1 has diameter 1 (in some unit of measure), disk 2 has diameter 2, and
disk 3 has diameter 3 and so on.
All five disks start on tower A in the order 1, 2, 3,4,5. The objective of the game is to move
all the disks on tower A to C. Only one disk may be moved at a time. Any of the towers A, B,
or C may be used for the intermediate placement of disks. After each move, the disks on each
of the towers must be in order. That is, at no time can a larger disk be placed on a smaller
disk.
a. Implement the above problem using recursive function.
b. Implement the above problem using non recursive function.
c. Design a function to compute total number of moves required to solve the problem.
d. Draw the pictorial representation for the complete solution.

2 of 2

You might also like