C Code (FCS)
C Code (FCS)
Programming Lab
1. Once upon a time, in a quiet village nestled by the countryside, lived a curious young girl named Emily.
One sunny afternoon, Emily decided to explore the fields surrounding her home. As she wandered
through the lush green meadows, she stumbled upon an old, forgotten book beneath a gnarled oak tree.
The book contained a mysterious riddle that intrigued Emily. It described a hidden treasure buried
in the meadow, protected by a magical rectangle. To uncover the treasure, she needed to calculate the
perimeter and area of the enchanted rectangle.
Emily rushed back home and quickly gathered her tools. She measured the rectangle's length,
finding it to be 7 inches, and its width, which was 5 inches. With these values in hand, she needed to
calculate perimeter and area of that rectangle.
Armed with these newfound values, Emily returned to the meadow. At the precise spot described
in the riddle, she dug, and to her astonishment, she uncovered a chest filled with sparkling jewels and
ancient coins.
Now, you have to write a program using C language to calculate and print that required values to
understand the location of that treasure.
Expected Output:
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
2. In a quiet village, there live a diligent young boy named Sam. His grandfather hands him an old math
book fills with fascinating problems. Among them is a riddle that piqued Sam's interest, which involve
computing the quotient and remainder.
The riddle instructs Sam to divide a stack of 50 delicious cookies equally among his 3 best friends.
After dividing cookies, if some remains, Sam can keep it for himself. Sam rolls up his sleeves and started
to work.
But as Sam didn’t know how to calculate quotient and remainder, he comes up with the decision
that whoever will help him, he will give those remaining cookies to that people.
You tell the answers to Sam. Now, he divides the cookies into three equal portions for each friend
and gives the remaining to you.
Sam's friends were overjoyed with the cookies, and they all enjoyed a delightful afternoon snack
together. The sweet taste of the cookies was made even sweeter by Sam's dedication and problem-
solving willing.
Now, you have to write a program in C language to convey the message that you really know how
to calculate quotient and remainder.
Expected Output:
Quotient: 16
Remainder: 2
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
3. Once upon a time, in a small coding workshop tucked away in a quiet corner of a bustling city, there
lived a young programmer named Lily. Lily had a keen interest in learning different programming
languages and loved taking on coding challenges. One sunny afternoon, she decided to create a program
in the C language that would print a beautiful box on her computer screen.
With her fingers dancing across the keyboard, Lily began writing her C program. She included the
necessary header files and defined the main function. Then, she started to implement her logic for
printing a box.
Now you also have to write such a program but inside the box your college name should also be
printed to impress Lily. And if you use only printf() function, then it will be treated as you are a work
harder boy.
Expected Output:
***************************
| |
| Academy of Technology |
| |
***************************
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
4. In the heart of a bustling city, there lived a young computer science student named Kate. Kate was
known for her love of creativity and recently started to learn coding. One day, she decided to embark
on a unique project: she wanted to create a pattern using the C language.
Kate envisioned a pattern that would mimic the cityscape outside her window, with buildings rising
and falling like waves. She spent days sketching and planning, visualizing the elegant symphony of
lines and shapes she wanted to bring to life.
With determination, Kate began coding her pattern. When Kate finally executed her program,
unfortunately it didn’t work.
Now, have to help Kate by writing the program using C language.
Expected Output:
A
c
a
d
m
e
y
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
5. In the quiet town of Knowledgeville, there was a renowned educational institution known as the
Knowledge Academy. This esteemed establishment had been at the forefront of education for decades,
shaping the minds of generations.
One fine day, a group of enthusiastic students decided to create a banner to celebrate their beloved
academy's achievements. They wanted to display the name "Academy" in a unique and eye-catching
way. After brainstorming ideas, they decided to put "Academy" in double quotes to emphasize its
significance.
With great excitement, the students gathered their art supplies and set to work. They carefully
handcrafted each letter, making them bold and beautiful. Then, they added the finishing touch: double
quotes around the word "Academy."
The banner was a masterpiece, with "Academy" enclosed in double quotes that shone brilliantly
under the sun. It symbolized the value and importance of education, capturing the spirit of the
Knowledge Academy.
The students proudly hung their banner in the town square, and it quickly became a symbol of pride
for Knowledgeville. Passersby would stop to admire the craftsmanship and the message it conveyed.
The display of "Academy" in double quotes wasn't just a simple decoration; it represented the
collective dedication to learning and the pursuit of knowledge in Knowledgeville. It reminded everyone
that education was a treasure worth cherishing, and the town's academy was at the heart of that pursuit.
Similarly, to print "Academy" in double quotes is not so much easy. Prove that you also can do such
a great thing by writing a program in C language which will print "Academy".
Expected Output:
"Academy"
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
6. In a small printing shop nestled on the corner of Elm Street, there lived an old printer named Thomas.
Thomas had been in the business of printing for decades, and he was known far and wide for his
impeccable craftsmanship.
One day, a young author named Lucy walked into Thomas's shop with a special request. She had
just finished writing her debut novel, a heartfelt story of love and adventure, and she needed Thomas's
expertise to bring it to life. But there was one particular challenge - Lucy's story was filled with quotes,
both single and double, that were integral to her narrative.
Thomas accepted the challenge with a twinkle in his eye. He carefully selected his vintage printing
press and began setting the type. With each press of the lever, he skillfully printed Lucy's novel,
ensuring that every single and double quote was meticulously placed.
As the pages rolled off the press, Lucy couldn't help but admire the precision and artistry in Thomas's
work. Her story was coming to life in a way that exceeded her wildest dreams.
When Lucy finally held her printed novel in her hands, she knew it was a masterpiece. Thomas had
captured the essence of her story, with every ' and " carefully printed to convey the emotions and
dialogues. It was a testament to the power of words and the artistry of printing.
From that day forward, Thomas's shop became a haven for writers who cherished the beauty of
quotes. His dedication to his craft and his attention to detail made him a legend in the world of printing.
And for Lucy, her debut novel became not just a story but a work of art, thanks to the skillful placement
of ' and " by the master printer, Thomas.
Now, as Thomas's shop becomes too much famous and Thomas is older enough to handle all the
task, he is finding for an assistant. The only criterion is to print single quote and double quote using C
language. You try to write the program so that you can apply for that job.
Expected Output:
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
7. Once upon a time, there was a young programmer named Alice who was working on a new project.
She had written some code that would print the contents of a folder, but she was having trouble figuring
out how to specify the path to the folder.
She decided to take a break and go for a walk to clear her head. As she was walking, she saw a sign
that said "D:\abc\xyz.txt". She realized that this was the path to the folder that she needed to print, but
the backslashes were not escaped in the code.
She went back to her computer and updated her code to print the path "D:\\abc\\xyz.txt". When
she ran the code, it successfully printed the contents of the folder.
The moral of the story is that sometimes the answer to a problem is right in front of you, you just
have to look for it.
Here is the question that Alice could ask herself to help her solve the problem:
How do I print the path "D:\\abc\\xyz.txt" in my code?
Once Alice knew how to escape the backslashes, she was able to update her code and print the
contents of the folder.
Now, if you are also able catch this trick, write a program using C language to print
"D:\\abc\\xyz.txt".
Expected Output:
D:\\abc\\xyz.txt
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
Q#1. Write a program to swap two numbers using Bitwise operator.
Hints:
1. A very well-known private company, “StackLab” wants to design an OS for computers. They are
searching for experienced programmers. Luckly, you are selected to design a particular section of
that OS. After completing this task successfully, you will get a promotion.
When the OS will be starting in a computer, the computer should show a welcome message to
impress the user. You have to write a C program to greet the user saying “Hello! User” in console.
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
2. A college wants to change the style of the identity cards for upcoming batches. The style of the ID
card is given below. Now, the rule is: everyone has to write a C program to print the details of
himself/herself as per the given format. As your friend don’t know C programming, he requested
you to write the code. If you write the code for him/her, he/she will get ID card and will give you a
treat.
ID Card Format:
Name: Aaa Bbb Ccc
Stream: XYZ
Semester: 7
Section: 1
Roll: 19
Date of Birth: 15/08/1947
Pin Code: 712121
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
3. After doing the above 2 jobs, you can think that your programming skill is improving. Now,
the final task for today is to print the following design using only the printf() function.
Output Format:
******
** **
*
*
*
*
*
** **
******
Coding Format:
/*
* Name: Aaa Bbb Ccc
* Stream: ABC
* Semester: 7
* Section: 1
* Roll: 19
*/
#include<stdio.h>
int main(){
//Write Code Here...
return 0;
}
ACADEMY OF TECHNOLOGY
Lab Assignment (C Training Lab)
Subject: Fundamental of Computer Science (FCS) Discipline: 1st Semester B. Tech (All)
Practice Assignments:
1) Write a C program to show your name.
2) Write a C program to take one integer value from user and show
its square value.
3) Write a C program to display following statements using
formatted output function:
𝒂+𝒃+𝒄
Where a, b and c are three sides of the triangle and 𝒔 =
𝟐
8) Write a C program to take sides of a triangle from user and check
whether the triangle is equilateral or not.
9) Write a C program to take a negative number from user and
convert that negative number to equivalent positive number.
10) Write a C program to take a positive integer and show its square
value.
11) Write a C program to take two integer values from user and store
them into integer variables a and b and also show ab .
12) Write a C program to take an integer from user and check
whether the given integer is odd or not.
13) Write a C program to take two integers from user and check
whether the given integers are equal or not.
14) Write a C program to find minimum between two integers given
by user.
15) Write a C program to swap two integers.
16) Write a C program to convert Fahrenheit to Celsius.
Use Indentation per line, “int main” instead of “void main” and
comment line in your programming code
1
Q#1. Write a C program to swap the value of 2 variables with one line statement using
arithmetic & assignment operators.
Q#4. Write a program to find sum of a 3 digit number [Without using loop.][Use only
Arithmetic Operator and Assignment operator]
Q#5.Given three integers a, b and c where c can be either 0 or 1. Without using any arithmetic,
relational and conditional operators set the value of a variable x based on below rules –
If c = 0
x=a
Else // Note c is binary
x = b.
Examples:
Input: a = 5, b = 10, c = 0;
Output: x = 5
Input: a = 5, b = 10, c = 1;
Output: x = 10
Hints : x = ((1 - c) * a) + (c * b)
1) James wanted to make a garden in front of his house. Hence, he has decided to select
a square land (with 196 square meter). But there is a circular pond inside that land.
Diameter of the pond is equal to the side of the land. James has decided to make the
garden within this area of the land except that pond. Write a C program to help James
to calculate the area of his garden.
2) A man standing at point P takes 1 hour to reach middle of the line i.e., Z point. He will
start from P and walk perpendicularly to reach point R. If the man needs 3 hours to
reach point R walking starting perpendicularly from P, then write a C program to
determine the time required by the man to reach the point Q through a straight line
starting from R.
P (10, 4) Z Q (10, 8)
3) Write a C program to check whether a year inputted from user is leap year or not and
also determine the number of odd days (month-wise) of that year.
[ Hint: Odd Days of a month= Remainder of (Total Days of a month / 7)]
4) Write a C program to display your first name and count the number of characters in
your first name.
5) Write a C program to find the LCM of two user given numbers if inputted numbers
are co-prime to each other (without using a loop).
6) Write a C program to take a negative number from user and convert that negative
number to equivalent positive number.
7) Write a C program to find the number of subsets of a set containing ‘n’ elements
(The value of n is given by user).
8) Between two movable points P & Q, P passes through the points A (0, –4) & B (–1, –7)
and Q passes through the points C (3, 0) & D (–3, 2). Write a C program to check
whether P and Q will meet or not.
FCS Lab Assignment-6
9) The sum of two co-prime numbers is 11 and their LCM is 24. Write a C program to get
their absolute difference of those numbers.
10) Write a C program to interchange the values of two integer variables without using
any third variable and any arithmetic operator.
11) Write a C program to check whether an inputted integer is even or odd without using
modulus operator.
13) Write a C program to show 9 using only sizeof operator without using any variable.
14) Write a C program to take two integers from user and show the product of their GCD
and LCM if they are not equal. Otherwise show their sum.
FCS LAB ASSIGNMENT-7
1) Write a C program to determine the time required by a movable point X from P (2,
7) to Q (5,8) if the speed of X is 100m per second.
2) A salesman was standing at a point A (3,2). He wanted to reach his next destination.
He found two houses located at B (9,10) and C (6,12). Then he selected nearest house.
Write a C program to which house he visited first.
3) Consider the following figure and co-ordinates of P & Q are (10, 12) and (18, 24)
respectively. S, T are midpoints of line PQ and line PR respectively. A movable point
X is located at the point S. Write a C program to determine the current location of X
and also find the distance if X is traversed through QR whereas X needs to traverse
10 meters through line ST.
S T
Q R
Fig. 1
4) Initially, Ajay is standing at a point D (3,2). After that he will move towards his west
direction and travel 4 km up to location E (7,2). From E (7,2) he will travel 3 km to
reach F (7,5). If the walking speed of Ajay is 1.5 meters per second, then write a C
program to find the time taken by Ajay to reach F from D without via F.
5) Consider the rectangular ground ABCD with area=48 square meters the length CD=
6 meters. A rat digs soils of the ground and it takes 2 days to dig 10 meters soil. Write
a C program to find the number of days required by the rat to dig soil of ground
through line AC.
A D
B C
Fig. 2
FCS LAB ASSIGNMENT-7
R
P Q
Fig. 3
7) Taniya tries to fill with appropriate number in the blanks for following series.
Write a C program to help Taniya for solving the questions:
i) 2, 4, 6, _____, 10, _____, 14, ….
ii) 2, ___, 8, 11, 14, ____, 20, ….
iii) 4, 7, 10, 13, ___, ___, 22. ….
8) There are two boxes B1 and B2 with certain number of balls. Sujoy throws a dice
and exchange the number of balls if the dice produces an even number. Otherwise,
he tries to compare the number of balls between B1 and B2. Write a C program to
help Sujoy to do that deed.
[ Constraint: Number of balls is a positive number and greater than 1.]
9) Write a C program to find total number of natural numbers between 101 and 999
divisible by both of 2 and 5.
10) Ajay joined a company with his initial salary Rs. 2000 per month in March 2022.
Write a C program to find the total years indicating the employment of Ajay in
that company if his salary is Rs. 90500 per month and he got an increment every
month of Rs 1500.
11) Suman runs across the boundary of a square ground. He runs total 1600 meters
in 15 mins. Write a C program to calculate the time taken by Suman if he will
run across the diagonal of the ground.
12) Write a C program to display 5 using only printf without direct mention of 5 and
a variable.
FCS LAB ASSIGNMENT-8
1) Write a C program to display 5 using only printf without direct mention of 5 and a
variable.
2) There are four points A (2,4), B (5,6), C (8,2), D (11, 5) in a plane. Let P1 and P2 are
two movable points. P1 starts from A and moves across the line AB. P2 starts from C
and traverses across the line CD. Write a C program to check whether they can meet
or not with each other in future or not if they will move across the straight line as
mentioned in the question.
3) There are a circular playground with origin C (2, 2) and a road AB just outside of the
ground touching a point P (2, 5) on the circumference of the ground. A person with 8
km/hr needs 30 mins to reach B from P (walking across PB). Write a C program to
calculate the time needed by the person if that person walks across B to reach C.
P B
A
Fig. 4
4) A system needs password from user for entering into home page. The password
consists of digits (0-9), uppercase alphabets(A-Z) and lowercase alphabets(a-z). Write
a C program to show a password satisfying the password criteria of the system and
determine the length of the password (without using any loop or strlen function).
5) You are purchasing a watch whose list price is $400 and the selling price is $380.
Write a C program to find the discount rate.
8) Teacher asks John to find a number. According to the question asked by the teacher,
one-third of one-fourth of a number is 15. Write a C program to help John for finding
the number.
9) In the first 10 overs of a cricket game, the run rate was only 3.2. Write a C program
to find the run rate in the remaining 40 overs to reach the target of 282 runs.
FCS LAB ASSIGNMENT-8
10) Write a C program to check whether the three points P (2, 4), Q (4, 6) and R (6, 8)
are collinear or not.
11) Write a C program to find the number of multiples of 4 lie between 10 and 250.
12) In a flower bed, there are 23 marigold plants in the first row, 21 in the second, 19 in
the third, and so on. There are 5 marigold plants in the last row. Write a C program
to find the rows in the flower bed.
13) Write a C program to find minimum of two inputted integers without using any
arithmetic operator, conditional operator and also if-else statement.
14) Write a C program to convert an uppercase alphabet given by the user without using
any arithmetic operator.
15) A cycle is run across the line AD making angle 300 with the line AC and angle 600
with line CB as the figure mentioned below:
A B
C
Fig. 5
If the speed of the cycle is 480 meters per hour and it takes 8 mins to reach D across the
line AD starting from A and needs 6 mins to reach B across the line DB starting from B,
then write a C program to find the perimeter of this circular ground.
FCS LAB ASSIGNMENTS
1) Write a C program to take sides of a triangle from user and check whether
the triangle is equilateral or not.
2) Write a C program to take a negative number from user and convert that
negative number to equivalent positive number.
3) Write a C program to take two integer values from user and store them into
4) Write a C program to find maximum between two numbers using switch case.
5) Write a C program to find minimum between two numbers using switch case.
6) Write a C program to input number from user and check whether the number is even
or odd using switch case.
8) Write a C program to create menu driven calculator that performs basic arithmetic
operations (add, subtract, multiply and divide).