We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 36
id Exp. Name: Write a € program to find Area and een
Circumference of a Circle
Write a program to find the area and (circunference) of a eile.
Note: Use the printf0 function with a newline character ( \n) at the end
area = PI * radius * radius
circumference = 2 * PI * radius
Define (Pi) value as (3.14 using |#deFine| and consider | Float | data type for [radius
Source Code:
circle.¢
Hincludecstdio.h>
define PI 3.14
int main()
a
float radius,area,circumferences
print#( ds
scant ( "ZF" ,&radius) ;
area = PI*radiustradius;
‘adius
circumference = 2*PI*radiuss
printf (“area = Sf\n" area);
printf (“circumference = ¥f\n",cireumference);
return @3
>
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
radius
267
area = 22,388747
circumference = 16.767601
Test Case - 2
User Output
radius
30.05
area = 2635.827734
‘Circumference = 188.713989
ID: 927623BAD060 | Page No: 1
2023-2027-A6
M.Kumarasamy College of EngineeringZiON abeg “O90GWAECOLeE ‘ai
Test Case - 3
User Output
radius
14.69
92,253197,
677. 599731
circumference
BV-1202-E2Z02) Guyaauibu3 yo a6ay}09 Awesesewny2 Exp. Name: Basic Calculator implementation Date: 2023-11-11
Ain
‘Writing a C program to implement Basic Calculator
Source Code:
Hincludecstdio.h>
Ant main()
a
double nunbert ,number2;
print#("enter number:
scanf("%1#", Brumbert) ;
printf("enter non zero number?
scanf("K1#" ,Bnumber2) ;
print f("%.21f + %.21f
print("%.21f - %.21F
printf * K.21F
print, 1 %.21F
return 5
"5
%.21f\n" number number2,nunber1+number2) 5
%.21f\n" number, nunber2,nunbert-number2);
%.21F\n" ,numberd,number2, number *number2) ;
%.21\n" ,nunbert number2, number /number2) ;
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
enter number
2
enter non Zero nunber2
3
2,00 + 3.00 = 5.00
2.00 - 3.00 = -1.00
2,00 * 3.00 = 6.00
2.00 / 3.00 = 6.67
ID: 927623BAD060_ Page No: 3
2023-2027-A6
M.Kumarasamy College of EngineeringExp. Name: Design an algorithm and implement using C
S.No: 3 Date: 2023-11-11
language the following exchanges
im:
Design an algorithm and implement using C language the following exchanges a ~~ b — ¢~ d ~ a and print the
result as shown in the example.
‘Sample Input and Output:
Enter values of a, b, ¢ and d: 98 74 21 36
After swapping
a=74
b=21
c= 36
d= 98
Source Cod
exchange.c
#includecstdio.h>
int main()
{
int a,b,c.d5
print#("Enter values of a, b, c and d:
scanf("%d" 8a)
scanF("%d" 8b);
scant ("%d" 8c) 5
scant ("%d" 8d) 5
printf("After swapping\n");
print#("a = %d\nb = Xd\nc = Xd\nd = %d\n",b,¢,4,a)3
return 05
)
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
Enter values of a ) cand dy
1234
‘After swapping
Test Case - 2
User Output
Enter values of @) b) cand d
ID: 927623BAD060_ Page No: 4
2023-2027-A6
M.Kumarasamy College of EngineeringS'ON abeg “O90GWAECOLEE ‘ai
98 74 2136
After swapping
a= 74
2
36
a= 98
9V-220z-€202) Suoou
ug Jo a6ay]0 Aweserewiny W,Exp. Name: Conversion of one datatype to another
S.No: 4 datatype
Date: 2023-11-11
im:
Write a simple program that converts one given datatype to another using auto conversion, Take a double value
from the user and convert it into integer and floating point datatypes,
Note: Print the floating point value up to 2 decimal places.
ID: 927623BAD060_ Page No: 6
Source Code |
typeconversion.¢
#includecstdio.h> i
int main() i
{
double 25
peint#(“Enter a value: ")
scanf("X1F",8a);
int al=a;
Float a2-a;
printf("Value as an integer: %d\n",a1); S
peint#("Value as a float: %.21F\n",92)3 g
return @5 5
t gi
g!
2
Execution Results - All test cases have succeeded! 3
Test Case - 1 2
3
User Output @
s
Enter_a value :
12345,67890 i
Valve as an integer? Ts &
Value as a float: 12345.68 g
5
Test Case - 2 =
User Output
Enter_a value:
12
Value os an integer: 12
Value asa float: 12.00S.No: 5 Exp. Name: Solving Expression Date: 2023-11-11
Aim:
Write a C code to solve the expression as 3*2/3+5
Source Code:
evaluate.
include
int main() {
double result;
// Evaluate the expression
result = 75 // write your code here
J/ Display the result
printf(*Result: %.21f\n" result ); // write your code here
ID: 927623BAD060_ Page No: 7
return @5
>
Execution Results - ll test cases have succeeded! 3)
nl
Test Case - 1 a
User Output a
Result: 7.08 s
M.Kumarasamy College of Engineerings.
ne Exp. Name: Write the code to find addition of two ET
numbers
im:
Jenny's homework for the first day is to find the addition of two numbers, help jenny to solve the problem.
Source Code:
[sea.< |
Hincludecstdio.h>
int main()
{
int a,b;
scanf("%d" 8a)5
scant ("%d" ib) 5
peint#(“The addition of two numbers is: Xd\n" arb);
return @5
)
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
62
The addition of two numbers is: @
Test Case - 2
User Output
759 624
The addition of two numbers is: 1383
ID: 927623BAD060__ Page No: 8
2023-2027-A6
M.Kumarasamy College of Engineeringoe Exp. Name: Write a program to find the total number of. 2903.44.14
squares
im:
Problem Description:
Tina's brother gave her a friendly task of calculating the number of squares in a board that has n*n squares of
dimensions tem “lem each,
Help her to find the number of total squares including all small and big ones.
Constraints:
+2
int main()
{
int nas
scanf("%d" in);
a=n* (nea) *((2#n)#1)/65
print ("Xd")
return @5
>
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
o
35
Test Case - 2
User Output
17
1785
ID: 927623BAD060_ Page No: 9
2023-2027-A6
M.Kumarasamy College of EngineeringExp. Name: Write a program to find the quotient and
S.No: 8 , Date: 2023-11-11
remainder
im:
Problem Description:
Nancy bought apples from a fruit shop, where the shopkeeper specified the bill amount. Nancy provided some
money to the shopkeeper to pay the bill. Now, she would like to know the quotient and remainder after dividing
the amount she gave by the bill amount specified by the shopkeeper. Can you help Nancy in finding it?
Constraint :
5 < amount givens 2500
5
int main()
{
int ayns
scanf("%d" ,8a)5
scanF("%d" 8);
printf("%d\n",a/n);
pent #("%d\n", a%n) 5
return @5
)
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
1800
56
32
8
Test Case - 2
User Output
1250.
150
927623BAD060 | Page No: 10
q
8
a
8
8
M.Kumarasamy College of Engineering50
LL:ON aBeg “O90aWaEZILC6 ‘al 9V-2202-€202 Suueeu
ug Jo a6ay]0 Aweserewiny W,oy Bp. Name: Write a program to find the volume of the ET
Aim:
Problem Description:
Laasya bought anew volleyball in the sports shop. It looks medium-sized. She somehow found the radius of the
sphere. But she would like to know the volume of that ball.
Can you help her in finding the volume of the ball?
Functional Description:
Volume = (4.0/3.0) x mx r43
w= 314
Constraint:
1.00 s radius < 5.00
Input Format :
‘The input consists of a single float number representing the radius of the ball
Output Format:
The output consists of the volume of the ball
Source Cod
volumeofBall.c
Hineludecstdio.h>
int main()
{
Float a,r3
scanF("%F" 8°)
4.0/3.0)*3.14¥r4r tr;
printf(KF" sa);
return @3
>
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
46
407.513367
Test Case - 2
User Output
37
212.067230
927623BAD060 | Page No: 12
2023-2027-A6
M.Kumarasamy College of EngineeringS.No: 10 Dep Name: Write a program fo find the matrix Date: 2023-11-11
multiplication
Aim:
Problem Description:
‘Atif came from a very low-income family. However, his father Irfan sent him abroad for the purpose of studying
Arif also concentrated well on his learning keeping in mind his father’s poverty. Arif was excellent in mathematics,
‘One day Arif had a computer class and his computer teacher asked him to create a programming logic for the
mathematics problem of multiplying two numbers of type float.
Can you help Arif with the logic?
Constraints:
+ 1.00 vart < 1000.00
+ 1.00 < var2 < 1000.00
Input Format:
The only line of input has two floating point numbers separated by space
Output Format:
In the only line of output print the result of the multiplication with 4 values after the decimal point.
Source Cod
multiplyTwoNlums .¢
Hineludecstdio.h>
int main()
{
float jn;
scanF("RF"
print#(
return 8;
41 f\0",a*n) 5
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
412.2365 154.2136
63571.7266
Test Case -2
User Output
784.2536 956.2487
749941 5000
927623BAD060 | Page No: 13
q
8
a
8
8
M.Kumarasamy College of EngineeringCreal Exp. Name: Write a program to calculate the area ofthe... ao93.44.44
Pyramid
im:
Problem Description:
Jannu and Preethi both went to Egypt for visiting Pyramids
‘On seeing the Pyramids they were in discussion.
During the discussion Jannu asked Preethi, what will be the area of this Pyramid.
Preethi have no idea about it.
927623BAD060 | Page No: 14
Can you help Preethi in calculating the area of this Pyramid?
Functional Description: &
Area = (height * base )/2
Constraints:
eight <= 500
Input Format:
The only line of input has two floating point values representing height and base respectively separated by a
space.
2023-2027-A6
Output Format
In the only line of output print the area of the pyramid with only three values after decimal point.
Source Code:
areaofPyramid
Hincludecstdio.h>
Ant main()
a
float a,b,¢3
scant ("%F", 8a);
scant ("%F", 8b) 5
ab) /25
print #("%.31f\n",c);
M.Kumarasamy College of Engineering
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
31.5437
688.275
Test Case - 2User Output
176.3 120.6
10630.890
SL:ON eGeg “O90GWEEZIZZE *
BV-1202-E2Z02) Suyaauibu3 yo a6ay}09 AwesesewnyExp. Name: Print months in a year using switch case
statement
S.No: 12 Date: 2023-11-11
im:
Write aC program to display month name according to the month number using switch case statement.
Note: If the given input number is not in the range ie, other than 1 to 12, the output should be as “invalid
month number’
Source Code
DisplayMonth.c
927623BAD060 | Page No: 16
2023-2027-A6
M.Kumarasamy College of Engineering// write your code here...
Hincludecstdio.h>
int main()
{
Ant month nos
nter month number : ")3
print #(
scanf("%d" ,&month_no) ;
sswitch(nonth_no)
{
y
return 05
case 1
print #("January\n");
break;
case 2:
print #("February\n");
breaks
case 3:
print #(*March\n");
break;
case 4
printf
break;
case 5:
printf
break;
case 6:
print#("June\n");
break;
case 7:
print#
break;
case 8:
print F("August\n") 5
breaks
case 9:
print #("September\n") ;
break;
case 10:
print#(“dctober\n");
break;
case 1
printf(“Novenber\n");
break;
case 12:
print#("Decenber\n");
break;
default:
print#("Invalid month number\a");
break;
July\n") 5
Execution Results - all test cases have succeeded!
927623BAD060 | Page No: 17
2023-2027-A6
M.Kumarasamy College of EngineeringTest Case - 1
User Output
Enter month number
1
Danuary
Test Case - 2
User Output
Enter month number
u
6
2
8
a
3
2
a
8
5
by
Novenber
Test Case - 3
User Output
Enter month nunber
B
Invalid month number
Test Case - 4
2023-2027-A6
User Output
Enter month number
9
September
Test Case - 5
User Output
Enter month number
4
M.Kumarasamy College of Engineering
april
Test Case - 6
User Output
Enter month number
2
February
Test Case - 7
User Output
Enter month nunber‘August
Test Case - 8
User Output
Enter month number +
6
Bune
Test Case - 9
User Output
Enter month number =
12
Decenber
Test Case - 10
User Output
Enter month number
0
Invalid month number
Test Case - 11
=
User Output
Enter month number
z
duly
ID: 927623BAD060 | Page No: 19
M.Kumarasamy College of Engineering |2023-2027-A6S.No: 13 Exp. Name: sum of n non-negative numbers Date: 2023-11-18
Aim:
Write a C program to find the sum of n non-negative numbers entered by the user.
Source Code:
jonnegative.c
Hincludecstdio.h>
void main()
a
int num, sum
scanf("%d" 8);
print f("Enter Xd Numbers: ",n);
for(int 4
927623BAD060 | Page No: 20
sit)
scanf("%d", mum) 5
if(nume)
{
,
y <
print#("Sum = %d\n", sum); 5
3
5 2
Execution Results - All test cases have succeeded! 5
Test Case - 1 >
User Output. iat
&
e 5
Enter 5 Numbers: g
1234-7 &
Sun = 9 :
5
Test Case - 2 =
User Output
7
Enter 7 Numbers
“3-2-4-5101112
Sun = 33Exp. Name: Write a C program to calculate whether a
S.No: 14
° given number is Palindrome or not
Date: 2023-11-19
im:
Design and develop an algorithm to find the reverse of an integer number and check whether itis Palindrome or
not
Implement a € program for the developed algorithm that takes an integer number as input and output the
reverse of the same with suitable messages.
At the time of execution, the program should print the message on the console as:
Enter an integer :
927623BAD060_ Page No: 21
For example, if the user gives the input as: =
Enter an integer : 2014
then the program should print the result as:
The reverse of a given number : 412
2014 is not a palindrome
Ifthe input is given as (1221 | then the result should be:
2023-2027-A6
The reverse of a given number : 1221
1221 is a palindrome
Source Code:
M.Kumarasamy College of EngineeringHincludecstdio.h>
Ant main()
t
dint num, reversed_nun-@, renainder,original_num;
printf(“Enter an integer : ");
scamf("%d" Brum);
original_nun-nums
whi e(num
(
remaindersnunt10;
reversed_nun=reversed_nun*i@+renainders
run/=10;
}
if(original_nun=-reversed_num)
‘
printf ("The reverse of a given nunber : %d\n",reversed_num);
printf("é is @ palindrome\n", original_num);
)
else
‘
printf ("The reverse of a given nunber : %d\n",reversed_num);
printf("%d is not a palindrone\n",original_nun);
}
return @3
>
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
Enter an integer
2014
The reverse of @ given number + 4102
2014 is not a palindrone
Test Case - 2
User Output
Enter an integer
1221
The reverse of @ given number: 1221
3221 1s 2 palindrone
927623BAD060 | Page No: 22
2023-2027-A6
M.Kumarasamy College of EngineeringS.No: 15 Exp. Name: Fibonacci series Date: 2023-11-19
Aim:
Write aC program to print the Fibonacci series ie, 0 1123 5.8 13 21... up to the limit given by the user
Hint: By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is
the sum of the previous two.
Source Code:
Programl4.c
// Type your code here.
includecstdio.h>
int main()
{
int n,i,t1=0,t2=1,nextTerm;
printf("Enter the maximum limit to generate the Fibonacci series :
scanf("%d" in) 5
printf("The Fibonacci series is :");
for(1=0;i
HincLudecmath.ho-
int main()
{
Ant num,at,rem,n=@;
Float result=0.0;
printf(“enter any number : ");
scanf("%d" num) ;
at=nun;
for(alsnumsal!=0;n++)
{
a1/=105
y
for(al=num3ai!=0;21/=10)
(
rem=ai¥10;
result+=pou(rem,n);
nun) 5
print#("The given number %4 is not an armstrong munber\n", nun);
return @3
>
in Results - All test cases have succeeded!
Test Case - 1
User Output
Enter_any number:
370
The given nunber 370 is an armstrong number
Test Case -2
User Output
Enter any number
1824
The given number 1824 is not an armstrong number
Test Case - 3
User Output
Enter any number
5
The given nunber 5 is an armstrong nunber
Test Case - 4
927623BAD060 | Page No: 25
2023-2027-A6
M.Kumarasamy College of EngineeringUser Output
Enter any number
1634
The given nunber 1634 1s an armstrong number
ID: 927623BAD060 | Page No: 26
q
8
a
8
8
2
M.Kumarasamy College of En:Exp. Name: Write the C program to find the Factorial of
a number.
S.No: 17 Date: 2023-11-20
im:
‘Write a program to find the Factorial of a non-zero positive integer n, denoted by nt, where factorial is the
product of all positive integers less than or equal ton, For example, I= 5*4*3*2*1 = 120
Note:
+ For negative values factorial cannot be calculated, so print “Invalid”
Constraints: -10 <= n <= 10
Instruction: To run your custom test cases strictly map your input and output layout with the visible test cases.
Source Code:
FactorialDowhile.c
Hincludecstdio.h>
void main()
{
int n45
unsigned long long fact=
print ("Num: ")3
scanf("%d",8n)3
iF(nca)
‘
print#("Invalid\n");
}
else
‘
for(det;4can;iee)
t
fact*=i;
,
print#("Factorial: td", fact);
}
}
Execution Results - all test cases have succeeded!
Test Case - 1
User Output
Nor
9
Factorial: 362860
Test Case - 2
User Output
927623BAD060 | Page No: 27
2023-2027-A6
M.Kumarasamy College of Engineering92 :0N e6eg “O90GWEEZIZZ6 “al
Nam
1
Factorial
Test Case - 3
User Output
Nun
-10
Invalid
BW-1202-E2Z02) Suyaauibu3 yo a6ay}09 AwesesewnyS.No: 18 Exp. Name: Triple of numbers Date: 2023-11-20
Input Format
‘Only line of input has three integers A BC separated by a space.
A triple of numbers is said to be poor when two of those numbers are equal but the other number is different &
from those two numbers. 2
e
You will be given three integers A, 8, and é
Constraints: g
1<=A,B,andC <= 50 8
a
3
oi
3
Output Format .
Print the output in a single lin, Ifthe given triple is poor, print Yes; otherwise, print No.
Source Cod
triple.c
Hincludecstdio.h>
Ant main()
a
int a,b,c;
scanf("%d Xd Xd", 8a, 8b, 8c);
2023-2027-A6
print#("Yes"); 2
else if((a==c)8&(a!-b)) 2
prante(ves"); é
else if((b==c)&&(b!=a)) &
printf(“ves"); S
else S
print #("No"); 3
return 85 g
> 5
E
Execution Results - All test cases have succeeded! :
Test Case - 1
User Output
2318 34
No
Test Case - 2
User Output
39 28 39
YesS.No: 19 Exp. Name: Write @ program to find the profit and loss Date: 2023-11-19
In primary mathematics classes, you all have leaned about profit and loss.
If cost price is greater than selling price, then there is a loss otherwise profit
Can you kindly automate the same?
Constraints:
1000 Selling Price Print a “Loss” along with the amount of loss.
IF Cost Price < Selling Price Print as “Profit” along with the amount of profit
If Cost Price = Selling Price Print “No Profit No Loss’
Source Code:
profitLoss.c
#includecstdio.h>
int main()
t
int sp,co;
scanf("kd\nkd" ,8ep,85p)5
4F(cp>sp)
printf("Loss: %4",cp-sp);
4#(cp
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
15945
13785
loss: 2160
Test Case - 2
927623BAD060 | Page No: 30
2023-2027-A6
M.Kumarasamy College of EngineeringUser Output
26832
28513
Profit: 1681
User Output
Test Case - 3
100
100
No Profit No Loss
8
2
8
a
3
2
a
8
5
by
2023-2027-A6
M.Kumarasamy College of EngineeringS.No: 20 Exp. Name: Write a program to find the N pages Date: 2023-11-19
Aim:
Problem Descri
‘Tharun wants to print a document with "N” pages double-sided, where two pages of data can be printed on one
sheet of paper.
Can you tell him how many sheets of paper he needs to print N pages?
Constraints:
+1
int main()
t
int ni
scanf("%4",8n)5
if(n/: )
printe(%a" n/2)5
else
printe(%a"n/241)5
return @}
)
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
189
35
Test Case - 2
User Output
567,
784)
927623BAD060 | Page No: 32
2023-2027-A6
M.Kumarasamy College of Engineeringerect Exp. Name: Write @ program to find the difference eee
between speeds
Aim:
Problem Description:
‘Arav and Aaron are participating in the Bike racing, Arav crossed some milestones earlier and Aaron crossed some
milestones earlier during their racing because they have changed their speeds at different times.
Both of them like to know the difference in speeds between them at different stages of racing,
Can you help find the speed difference between Arav and Aaron?
Constraints:
20s aravspeed <100
20s aaronspeed <100
927623BAD060 | Page No: 33
Input Format
The first line of input represents the speed of Arav.
The second line of input represents speed of Aaron.
Output Format:
Print difference between the driving speed of two participants in a single line.
Source Cod
speed.c
2023-2027-A6
Hineludecstdio.h>
2
int main() 5
{ t
tnt $1,525 .,
scanf("%d\n%d" ,&s1, 852); &
if(sbs2) 5
printf("%d",s1-s2); 2
else 3
printé("%a",s2-s1)5 S
return 5 5
: 5
5
=
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
74
51
23
Test Case - 2
User Output
7689
3
VE:ON e6eg “O90GWEEZIZZ6 ‘al 9V-ZZ02-E20Z Guuaaui6uy Jo abayjo> AweseseunyS.No: 22 Exp. Name: Represent the currency value. Date: 2023-11-19
Aim:
Problem Deseri
Paytm announced a Cashback offer for the people of Tamil Nadu which is a one-time offer for the new year-But to
avail of the Cashback users need to pass the simple tasks given by Paytm, One such task given by Paytm is to
ccheck the nature of the currency value provided by Paytm.
Constraint:
1 <= currency <= 20000
Functional Description
‘One more condition imposed by Paytm is that participants need to do this checking using the concept of
Operators,
Input Format:
Only the Line of input has a single value of type integer representing the currency value.
Output Format:
Print either as "Even Currency’ or "Odd Currency’.
Source Code:
currency.
Hincludecstdio.h>
int main()
a
int ¢;
scanF("%d" 8c);
if (cH2==0)
print#(“Even Currency");
else
printf(“Odd Currency")s
return @3
)
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
1985
‘Odd Currency
Test Case - 2
User Output
1642
Even currency
927623BAD060 | Page No: 35
q
8
a
8
8
M.Kumarasamy College of EngineeringS.No: 23 Exp. Name: Store and print numbers using array Date: 2023-11-19
Aim:
Write a program to accept n numbers in an array and display it
Source Code:
printNumbers.c
Hincludecstdio.h>
Ant main()
a
int are(10};
ant 1,03
printf("How many numbers do you want to enter: ");
seanf (“Rd n)3
printf("Enter %d numbers: ",n);
for(
sens i++)
{
scanf("%d", &arr(i]);
}
print#("Entered numbers are
For(i-0; den i++)
{
print#(" %é" are(il);
print#(
return 0;
Execution Results - All test cases have succeeded!
Test Case - 1
User Output
How many numbers do you want to enter
5
Enter 5 numbers:
246810
Entered numbers are: 24 68 10
Test Case - 2
User Output
How many numbers do you want to enter:
10
Enter 10 numbers:
12345678910
Entered numbers ares 12345678910
3
3
e
2
8
g
3
3
5
a
2023-2027-A6
M.Kumarasamy College of Engineering