SlideShare a Scribd company logo
--- PROBLEM DESCRIPTION - M2P1 - 4 - Splitting into Teams ---
Splitting into Teams
During the Physical Education hour, PT sir has decided to conduct some team games. He wants to split the
students in the class into equal sized teams.
In some cases, there may be some students who are left out from teams and he wanted to use the left out
students to assist him in conducting the team games.
For instance, if there are 50 students in the class and if the class has to be divided into 7 equal sized teams,
7 students will be there in each team and 1 student will be left out.
PT sir asks your help to automate this team splitting task. Can you please help him out?
Input Format:
Input consists of 2 integers. The first integer corresponds to the number of students in the class and the
second integer corresponds to the number of teams.
Output Format:
Refer sample input and output for formatting specifications.
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Number of students:
60
Number of teams:
8
The number of students in each team is 7 and left out is 4
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - M2P1 - 4 - Splitting into Teams ---
Step 1: Start the program.
Step 2: Read the number of students [a] and number of teams [b] as from the user.
Step 3: Use a/b to calculate the number of students in each team and a % b to calculate the left out students.
Step 4: Display the result to the user
Step 5: Stop the program
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - M2P1 - 4 - Splitting into Teams ---
--- PROGRAM - M2P1 - 4 - Splitting into Teams---
# include <stdio.h>
int main()
{
int n, t;
printf(" Number of students :n");
scanf("%d", &n);
printf("Number of teams:n");
scanf("%d", &t);
int m, l;
m = n / t;
l = n % t;
printf("The number of students in each team is %d and left out is %d", m, l);
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program for splitting the number of students into team was executed and verified
successfully.
--- PROBLEM DESCRIPTION - Odd or Even using Bitwise and Operator ---
Odd or Even using Bitwise and Operator
Write a C program to find whether the given number is odd or even, using Bitwise ' & ' Operator.
Input Format:
The input consists of an integer.
Output Format:
Output should display whether the input is Odd or Even.
Refersample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1:
Enter the number :
5
Odd
Sample Input and Output 2:
Enter the number :
8
Even
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - Odd or even using Bitwise and Operator ---
Step 1: Start the process.
Step 2: Declare and get the values for a,b,c.
Step 3: Use n & 1 to check whether the given number is odd or even
Step 4: Display the result to the user
Step 5: Stop the program
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - Odd or even using Bitwise and Operator ---
--- PROGRAM - Odd or even using Bitwise and Operator---
# include <stdio.h>
int main()
{
int a;
printf("Enter the number :n");
scanf("%d", &a);
(a & 1) ? printf("Odd n") : printf("Even n");
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program for finding whether the given number is odd or even using bitwise operator was
executed and verified successfully.
--- PROBLEM DESCRIPTION - Largest of three numbers using Ternary Operator ---
Largest of three numbers using Ternary Operator
Write a program to find greatest of three numbers, using Ternary Operator.
Input Format:
The input consists of 3 integers.
Output Format:
Output should display the greatest of the 3 numbers.
Refersample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to output]
Sample Input and Output 1:
Enter the numbers:
5
8
2
8 is the greatest number
Sample Input and Output 2:
Enter the numbers:
44
16
23
44 is the greatest number
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - Largest of three numbers using Ternary Operator ---
Step 1: Start the process.
Step 2: Initialize variables a,b,c and d. Get the values of a,b,c from user.
Step 3: Using ternary operator find the greatest among 3 numbers and store the value in
big.
Step 4: Display the value of big.
Step 5: Stop the process.
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - Largest of three numbers using Ternary Operator ---
--- PROGRAM - Largest of three numbers using Ternary Operator---
# include <stdio.h>
int main()
{
int a, b, c;
printf("Enter the numbers:n");
scanf("%d %d %d", &a, &b, &c);
int big;
big = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c);
printf("%d is the greatest number", big);
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program for finding largest of three numbers using ternary operator was executed and
verified successfully.
--- PROBLEM DESCRIPTION - M2P2 - 7 - THREE IDIOTS ---
THREE IDIOTS
Ajay, Binoy and Chandru were very close friends at school. They were very good in Mathematics and they
were the pet students of Emily Mam. Their gang was known as 3-idiots. Ajay, Binoy and Chandru live in
the same locality.
A new student Dinesh joins their class and he wanted to be friends with them. He asked Binoy about his
house address. Binoy wanted to test Dinesh's mathematical skills. Binoy told Dinesh that his house is at the
midpoint of the line joining Ajay's house and Chandru's house. Dinesh was puzzled. Can you help Dinesh
out?
Given the coordinates of the 2 end points of a line (x1,y1) and (x2,y2), write a program to find the midpoint
of the line.
Input Format:
Input consists of 4 integers. The first integer corresponds to x1 . The second integer corresponds to y1. The
third and fouth integers correspond to x2 and y2 respectively.
Output Format:
Refer Sample Input and Output for exact formatting
specifications. [All floating point values are displayed
correct to 1 decimal place] Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
X1
2
Y1
4
X2
10
Y2
15
Binoy's house is located at (6.0,9.5)
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - M2P2 - 7 - THREE IDIOTS ---
Step 1:Start the process.
Step 2:Declare and get the values for x1,y1,x2,y2.
Step 3:Declare and calculate x3=(x1+x2)/2 and y3=(y1+y2)/2.
Step 4:Display the result.
Step 5:Stop the process.
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - M2P2 - 7 - THREE IDIOTS ---
--- PROGRAM - M2P2 - 7 - THREE IDIOTS---
#include<stdio.h>
int main()
{
int x1, x2, y1, y2;
char c1 = '(';
char c2 = ')';
printf("X1n");
scanf("%d", &x1);
printf("Y1n");
scanf("%d", &y1);
printf("X2n");
scanf("%d", &x2);
printf("Y2n");
scanf("%d", &y2);
float x3 = ((x1 + x2) / 2.0);
float y3 = ((y1 + y2) / 2.0);
printf("Binoy's house is located at %c%.1f,%.1f%c", c1, x3, y3, c2);
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program for finding distance between two points was executed and verified successfully.
--- PROBLEM DESCRIPTION - Celsius to Fahrenheit Converter ---
Celsius to Fahrenheit Converter
The relatioship between Celsius (C) and Fahrenheit (F) degrees for measuring temperature is linear.
Find an equation relating C and F if 0 C corresponds to 32 F and 100 C corresponds to 212 F.
Write a program to simulate Celsius to Fahrenheit Converter.
Input Format:
Input consists of a single integer which corresponds to a measure of temparature in Celcius.
Output Format:
Refer Sample Input and Output for exact formatting
specifications. [All floating point values are displayed
correct to 1 decimal place]
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Temparature in Celsius:
12
Temparature in Fahrenheit is 53.6F
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - Celsius to Fahrenheit Converter ---
Step 1: Start the process.
Step 2: Initialize c and f.
Step 3: Get the value of c from the user.
Step 3: Compute f= (c*9/5) +32.
Step 4: Print the result.
Step 5: Stop the process.
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - Celsius to Fahrenheit Converter ---
--- PROGRAM - Celsius to Fahrenheit Converter---
# include <stdio.h>
int main()
{
float c, f;
printf("Temparature in Celsius:");
scanf("n%f", &c);
f = (c * 9 / 5) + 32;
printf("nTemparature in Fahrenheit is %.1fF", f);
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program to convert the temperature from Celsius to Fahrenheit was executed and verified
successfully.
--- PROBLEM DESCRIPTION - quadratic equation roots ---
Quadratic Equation Roots
Write a program to find the roots of given quadratic equation. The
Quadratic equation is of the form ax2+bx+c = 0.
Input Format:
Input consists of 3 integer corresponding to a,b and c respectively.
Output Format:
Print the of the equation formed by the given values of a,b,c. Display the roots correct to 1 decimal place.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to
output.]
Sample Input and Output:
Enter the values of a,b,c :
1
4
4
The roots are:
root1 = -2.0
root2 = -2.0
-----------------------------------------------------------------------------------------------------------------------
--- ALGORITHM - quadratic equation roots ---
Step 1: Start the process.
Step 2: Declare and get the values for a,b,c.
Step 3: Calculate root1=(-b+(b*b-4*a*c))/(2*a) and
root2=(-b-(b*b-4*a*c))/(2*a).
Step 4: Display the result.
Step 5: Stop the process.
-----------------------------------------------------------------------------------------------------------------------
--- FLOWCHART - quadratic equation roots ---
--- PROGRAM - quadratic equation roots---
# include <stdio.h>
# include <math.h>
int main()
{
int a, b, c;
float root1, root2;
printf("Enter the values of a,b,c :");
scanf("%d %d %d", &a, &b, &c);
root1 = (-b + sqrt((b * b) - (4 * a * c))) / (2 * a);
root2 = (-b - sqrt((b * b) - (4 * a * c))) / (2 * a);
printf("nThe roots are:");
printf("nroot1 = %.1f", root1);
printf("nroot2 = %.1f", root2);
return 0;
}
-----------------------------------------------------------------------------------------------------------------------
Result:
Thus the C Program to find the roots of the quadratic equation was executed and verified successfully.

More Related Content

Similar to Module 1 programs

Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
Gaurav Dixit
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
amaranthbeg8
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
bellflower169
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
bellflower148
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
bellflower126
 
1 Faculty of Computer Studies Information Technology a.docx
1 Faculty of Computer Studies Information Technology a.docx1 Faculty of Computer Studies Information Technology a.docx
1 Faculty of Computer Studies Information Technology a.docx
mercysuttle
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.com
claric119
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.com
claric169
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
sujatam8
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
Animesh Chaturvedi
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
Programming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptxProgramming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptx
SONU KUMAR
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Sheila Sinclair
 
paython practical
paython practical paython practical
paython practical
Upadhyayjanki
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
NarutoUzumaki413489
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
Drjilesh
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
India
 
Bba105 computer fundamentals..
Bba105  computer fundamentals..Bba105  computer fundamentals..
Bba105 computer fundamentals..
smumbahelp
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
noahjamessss
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
cskvsmi44
 

Similar to Module 1 programs (20)

Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
 
Gsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.comGsp 215 Future Our Mission/newtonhelp.com
Gsp 215 Future Our Mission/newtonhelp.com
 
GSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.comGSP 215 Perfect Education/newtonhelp.com
GSP 215 Perfect Education/newtonhelp.com
 
GSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.comGSP 215 Become Exceptional/newtonhelp.com
GSP 215 Become Exceptional/newtonhelp.com
 
GSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.comGSP 215 Doing by learn/newtonhelp.com
GSP 215 Doing by learn/newtonhelp.com
 
1 Faculty of Computer Studies Information Technology a.docx
1 Faculty of Computer Studies Information Technology a.docx1 Faculty of Computer Studies Information Technology a.docx
1 Faculty of Computer Studies Information Technology a.docx
 
GSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.comGSP 215 RANK Become Exceptional--gsp215rank.com
GSP 215 RANK Become Exceptional--gsp215rank.com
 
GSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.comGSP 215 RANK Achievement Education--gsp215rank.com
GSP 215 RANK Achievement Education--gsp215rank.com
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
Programming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptxProgramming in C by SONU KUMAR.pptx
Programming in C by SONU KUMAR.pptx
 
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And EngineersAnswers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
Answers To Selected Exercises For Fortran 90 95 For Scientists And Engineers
 
paython practical
paython practical paython practical
paython practical
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
 
best notes in c language
best notes in c languagebest notes in c language
best notes in c language
 
Bba105 computer fundamentals..
Bba105  computer fundamentals..Bba105  computer fundamentals..
Bba105 computer fundamentals..
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 

Recently uploaded

How to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM SoftwareHow to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM Software
SalesTown
 
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
Lacey Max
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
FelixPerez547899
 
Income Tax exemption for Start up : Section 80 IAC
Income Tax  exemption for Start up : Section 80 IACIncome Tax  exemption for Start up : Section 80 IAC
Income Tax exemption for Start up : Section 80 IAC
CA Dr. Prithvi Ranjan Parhi
 
Digital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital ExcellenceDigital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital Excellence
Operational Excellence Consulting
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
JeremyPeirce1
 
Part 2 Deep Dive: Navigating the 2024 Slowdown
Part 2 Deep Dive: Navigating the 2024 SlowdownPart 2 Deep Dive: Navigating the 2024 Slowdown
Part 2 Deep Dive: Navigating the 2024 Slowdown
jeffkluth1
 
How MJ Global Leads the Packaging Industry.pdf
How MJ Global Leads the Packaging Industry.pdfHow MJ Global Leads the Packaging Industry.pdf
How MJ Global Leads the Packaging Industry.pdf
MJ Global
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Holger Mueller
 
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
thesiliconleaders
 
Best practices for project execution and delivery
Best practices for project execution and deliveryBest practices for project execution and delivery
Best practices for project execution and delivery
CLIVE MINCHIN
 
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta MatkaDpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
➒➌➎➏➑➐➋➑➐➐Dpboss Matka Guessing Satta Matka Kalyan Chart Indian Matka
 
Authentically Social by Corey Perlman - EO Puerto Rico
Authentically Social by Corey Perlman - EO Puerto RicoAuthentically Social by Corey Perlman - EO Puerto Rico
Authentically Social by Corey Perlman - EO Puerto Rico
Corey Perlman, Social Media Speaker and Consultant
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
SOFTTECHHUB
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
Kirill Klimov
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
Norma Mushkat Gaffin
 
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
APCO
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
bosssp10
 
Chapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .pptChapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .ppt
ssuser567e2d
 
The Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb PlatformThe Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb Platform
SabaaSudozai
 

Recently uploaded (20)

How to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM SoftwareHow to Implement a Real Estate CRM Software
How to Implement a Real Estate CRM Software
 
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
How are Lilac French Bulldogs Beauty Charming the World and Capturing Hearts....
 
Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024Company Valuation webinar series - Tuesday, 4 June 2024
Company Valuation webinar series - Tuesday, 4 June 2024
 
Income Tax exemption for Start up : Section 80 IAC
Income Tax  exemption for Start up : Section 80 IACIncome Tax  exemption for Start up : Section 80 IAC
Income Tax exemption for Start up : Section 80 IAC
 
Digital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital ExcellenceDigital Transformation Frameworks: Driving Digital Excellence
Digital Transformation Frameworks: Driving Digital Excellence
 
Top mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptxTop mailing list providers in the USA.pptx
Top mailing list providers in the USA.pptx
 
Part 2 Deep Dive: Navigating the 2024 Slowdown
Part 2 Deep Dive: Navigating the 2024 SlowdownPart 2 Deep Dive: Navigating the 2024 Slowdown
Part 2 Deep Dive: Navigating the 2024 Slowdown
 
How MJ Global Leads the Packaging Industry.pdf
How MJ Global Leads the Packaging Industry.pdfHow MJ Global Leads the Packaging Industry.pdf
How MJ Global Leads the Packaging Industry.pdf
 
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challengesEvent Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
Event Report - SAP Sapphire 2024 Orlando - lots of innovation and old challenges
 
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdfThe 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
The 10 Most Influential Leaders Guiding Corporate Evolution, 2024.pdf
 
Best practices for project execution and delivery
Best practices for project execution and deliveryBest practices for project execution and delivery
Best practices for project execution and delivery
 
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta MatkaDpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
Dpboss Matka Guessing Satta Matta Matka Kalyan Chart Satta Matka
 
Authentically Social by Corey Perlman - EO Puerto Rico
Authentically Social by Corey Perlman - EO Puerto RicoAuthentically Social by Corey Perlman - EO Puerto Rico
Authentically Social by Corey Perlman - EO Puerto Rico
 
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
Hamster Kombat' Telegram Game Surpasses 100 Million Players—Token Release Sch...
 
Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024Organizational Change Leadership Agile Tour Geneve 2024
Organizational Change Leadership Agile Tour Geneve 2024
 
Mastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnapMastering B2B Payments Webinar from BlueSnap
Mastering B2B Payments Webinar from BlueSnap
 
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
The APCO Geopolitical Radar - Q3 2024 The Global Operating Environment for Bu...
 
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
Call 8867766396 Satta Matka Dpboss Matka Guessing Satta batta Matka 420 Satta...
 
Chapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .pptChapter 7 Final business management sciences .ppt
Chapter 7 Final business management sciences .ppt
 
The Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb PlatformThe Genesis of BriansClub.cm Famous Dark WEb Platform
The Genesis of BriansClub.cm Famous Dark WEb Platform
 

Module 1 programs

  • 1. --- PROBLEM DESCRIPTION - M2P1 - 4 - Splitting into Teams --- Splitting into Teams During the Physical Education hour, PT sir has decided to conduct some team games. He wants to split the students in the class into equal sized teams. In some cases, there may be some students who are left out from teams and he wanted to use the left out students to assist him in conducting the team games. For instance, if there are 50 students in the class and if the class has to be divided into 7 equal sized teams, 7 students will be there in each team and 1 student will be left out. PT sir asks your help to automate this team splitting task. Can you please help him out? Input Format: Input consists of 2 integers. The first integer corresponds to the number of students in the class and the second integer corresponds to the number of teams. Output Format: Refer sample input and output for formatting specifications. Sample Input and Output: [All text in bold corresponds to input and the rest corresponds to output] Number of students: 60 Number of teams: 8 The number of students in each team is 7 and left out is 4 -----------------------------------------------------------------------------------------------------------------------
  • 2. --- ALGORITHM - M2P1 - 4 - Splitting into Teams --- Step 1: Start the program. Step 2: Read the number of students [a] and number of teams [b] as from the user. Step 3: Use a/b to calculate the number of students in each team and a % b to calculate the left out students. Step 4: Display the result to the user Step 5: Stop the program -----------------------------------------------------------------------------------------------------------------------
  • 3. --- FLOWCHART - M2P1 - 4 - Splitting into Teams ---
  • 4. --- PROGRAM - M2P1 - 4 - Splitting into Teams--- # include <stdio.h> int main() { int n, t; printf(" Number of students :n"); scanf("%d", &n); printf("Number of teams:n"); scanf("%d", &t); int m, l; m = n / t; l = n % t; printf("The number of students in each team is %d and left out is %d", m, l); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program for splitting the number of students into team was executed and verified successfully.
  • 5. --- PROBLEM DESCRIPTION - Odd or Even using Bitwise and Operator --- Odd or Even using Bitwise and Operator Write a C program to find whether the given number is odd or even, using Bitwise ' & ' Operator. Input Format: The input consists of an integer. Output Format: Output should display whether the input is Odd or Even. Refersample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output] Sample Input and Output 1: Enter the number : 5 Odd Sample Input and Output 2: Enter the number : 8 Even -----------------------------------------------------------------------------------------------------------------------
  • 6. --- ALGORITHM - Odd or even using Bitwise and Operator --- Step 1: Start the process. Step 2: Declare and get the values for a,b,c. Step 3: Use n & 1 to check whether the given number is odd or even Step 4: Display the result to the user Step 5: Stop the program -----------------------------------------------------------------------------------------------------------------------
  • 7. --- FLOWCHART - Odd or even using Bitwise and Operator ---
  • 8. --- PROGRAM - Odd or even using Bitwise and Operator--- # include <stdio.h> int main() { int a; printf("Enter the number :n"); scanf("%d", &a); (a & 1) ? printf("Odd n") : printf("Even n"); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program for finding whether the given number is odd or even using bitwise operator was executed and verified successfully.
  • 9. --- PROBLEM DESCRIPTION - Largest of three numbers using Ternary Operator --- Largest of three numbers using Ternary Operator Write a program to find greatest of three numbers, using Ternary Operator. Input Format: The input consists of 3 integers. Output Format: Output should display the greatest of the 3 numbers. Refersample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output] Sample Input and Output 1: Enter the numbers: 5 8 2 8 is the greatest number Sample Input and Output 2: Enter the numbers: 44 16 23 44 is the greatest number -----------------------------------------------------------------------------------------------------------------------
  • 10. --- ALGORITHM - Largest of three numbers using Ternary Operator --- Step 1: Start the process. Step 2: Initialize variables a,b,c and d. Get the values of a,b,c from user. Step 3: Using ternary operator find the greatest among 3 numbers and store the value in big. Step 4: Display the value of big. Step 5: Stop the process. -----------------------------------------------------------------------------------------------------------------------
  • 11. --- FLOWCHART - Largest of three numbers using Ternary Operator ---
  • 12. --- PROGRAM - Largest of three numbers using Ternary Operator--- # include <stdio.h> int main() { int a, b, c; printf("Enter the numbers:n"); scanf("%d %d %d", &a, &b, &c); int big; big = (a > b) ? ((a > c) ? a : c) : ((b > c) ? b : c); printf("%d is the greatest number", big); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program for finding largest of three numbers using ternary operator was executed and verified successfully.
  • 13. --- PROBLEM DESCRIPTION - M2P2 - 7 - THREE IDIOTS --- THREE IDIOTS Ajay, Binoy and Chandru were very close friends at school. They were very good in Mathematics and they were the pet students of Emily Mam. Their gang was known as 3-idiots. Ajay, Binoy and Chandru live in the same locality. A new student Dinesh joins their class and he wanted to be friends with them. He asked Binoy about his house address. Binoy wanted to test Dinesh's mathematical skills. Binoy told Dinesh that his house is at the midpoint of the line joining Ajay's house and Chandru's house. Dinesh was puzzled. Can you help Dinesh out? Given the coordinates of the 2 end points of a line (x1,y1) and (x2,y2), write a program to find the midpoint of the line. Input Format: Input consists of 4 integers. The first integer corresponds to x1 . The second integer corresponds to y1. The third and fouth integers correspond to x2 and y2 respectively. Output Format: Refer Sample Input and Output for exact formatting specifications. [All floating point values are displayed correct to 1 decimal place] Sample Input and Output: [All text in bold corresponds to input and the rest corresponds to output] X1 2 Y1 4 X2 10 Y2 15 Binoy's house is located at (6.0,9.5) -----------------------------------------------------------------------------------------------------------------------
  • 14. --- ALGORITHM - M2P2 - 7 - THREE IDIOTS --- Step 1:Start the process. Step 2:Declare and get the values for x1,y1,x2,y2. Step 3:Declare and calculate x3=(x1+x2)/2 and y3=(y1+y2)/2. Step 4:Display the result. Step 5:Stop the process. -----------------------------------------------------------------------------------------------------------------------
  • 15. --- FLOWCHART - M2P2 - 7 - THREE IDIOTS ---
  • 16. --- PROGRAM - M2P2 - 7 - THREE IDIOTS--- #include<stdio.h> int main() { int x1, x2, y1, y2; char c1 = '('; char c2 = ')'; printf("X1n"); scanf("%d", &x1); printf("Y1n"); scanf("%d", &y1); printf("X2n"); scanf("%d", &x2); printf("Y2n"); scanf("%d", &y2); float x3 = ((x1 + x2) / 2.0); float y3 = ((y1 + y2) / 2.0); printf("Binoy's house is located at %c%.1f,%.1f%c", c1, x3, y3, c2); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program for finding distance between two points was executed and verified successfully.
  • 17. --- PROBLEM DESCRIPTION - Celsius to Fahrenheit Converter --- Celsius to Fahrenheit Converter The relatioship between Celsius (C) and Fahrenheit (F) degrees for measuring temperature is linear. Find an equation relating C and F if 0 C corresponds to 32 F and 100 C corresponds to 212 F. Write a program to simulate Celsius to Fahrenheit Converter. Input Format: Input consists of a single integer which corresponds to a measure of temparature in Celcius. Output Format: Refer Sample Input and Output for exact formatting specifications. [All floating point values are displayed correct to 1 decimal place] Sample Input and Output: [All text in bold corresponds to input and the rest corresponds to output] Temparature in Celsius: 12 Temparature in Fahrenheit is 53.6F -----------------------------------------------------------------------------------------------------------------------
  • 18. --- ALGORITHM - Celsius to Fahrenheit Converter --- Step 1: Start the process. Step 2: Initialize c and f. Step 3: Get the value of c from the user. Step 3: Compute f= (c*9/5) +32. Step 4: Print the result. Step 5: Stop the process. -----------------------------------------------------------------------------------------------------------------------
  • 19. --- FLOWCHART - Celsius to Fahrenheit Converter ---
  • 20. --- PROGRAM - Celsius to Fahrenheit Converter--- # include <stdio.h> int main() { float c, f; printf("Temparature in Celsius:"); scanf("n%f", &c); f = (c * 9 / 5) + 32; printf("nTemparature in Fahrenheit is %.1fF", f); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program to convert the temperature from Celsius to Fahrenheit was executed and verified successfully.
  • 21. --- PROBLEM DESCRIPTION - quadratic equation roots --- Quadratic Equation Roots Write a program to find the roots of given quadratic equation. The Quadratic equation is of the form ax2+bx+c = 0. Input Format: Input consists of 3 integer corresponding to a,b and c respectively. Output Format: Print the of the equation formed by the given values of a,b,c. Display the roots correct to 1 decimal place. Refer sample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to output.] Sample Input and Output: Enter the values of a,b,c : 1 4 4 The roots are: root1 = -2.0 root2 = -2.0 -----------------------------------------------------------------------------------------------------------------------
  • 22. --- ALGORITHM - quadratic equation roots --- Step 1: Start the process. Step 2: Declare and get the values for a,b,c. Step 3: Calculate root1=(-b+(b*b-4*a*c))/(2*a) and root2=(-b-(b*b-4*a*c))/(2*a). Step 4: Display the result. Step 5: Stop the process. -----------------------------------------------------------------------------------------------------------------------
  • 23. --- FLOWCHART - quadratic equation roots ---
  • 24. --- PROGRAM - quadratic equation roots--- # include <stdio.h> # include <math.h> int main() { int a, b, c; float root1, root2; printf("Enter the values of a,b,c :"); scanf("%d %d %d", &a, &b, &c); root1 = (-b + sqrt((b * b) - (4 * a * c))) / (2 * a); root2 = (-b - sqrt((b * b) - (4 * a * c))) / (2 * a); printf("nThe roots are:"); printf("nroot1 = %.1f", root1); printf("nroot2 = %.1f", root2); return 0; } ----------------------------------------------------------------------------------------------------------------------- Result: Thus the C Program to find the roots of the quadratic equation was executed and verified successfully.