5. Using the online compiler (or Dev C++):
• Enter the code
int main(int argc, char *argv[]) {
int a;
// Obtain the value of integer a
printf("Enter the value of integer a: ");
scanf("%d", &a);
printf("\n\n");
// Determine using a switch construct whether
// a is an odd digit, even digit or multiple digits
switch(a)
{
case 0:
case 2:
case 4:
case 6:
case 8:
printf("a (%d) is an even digit\n", a);
break;
case 1:
case 3:
case 5:
case 7:
case 9:
printf("a (%d) is an odd digit\n", a);
break;
default:
printf("a (%d) contains multiple digits\n", a);
}
system("pause");
return 0;• Enter an ODD single digit value that is less than 10.
• Enter an EVEN single digit value that is less than 10.
• Enter a value that is greater than 10.
• Write a code on its functionality comparing the outputs against the source code.
• Modify the program In other words for a 0, the program would display “ZERO” for a 7 the program, would display “SEVEN”
4. Using the online compiler
• Enter the code
int main(int argc, char *argv[]) {
int a, b;
// Obtain values for a and b
printf("Enter the value for integer a: ");
scanf("%d", &a);
printf("Enter the value for integer b: ");
scanf("%d", &b);
printf("\n\n");
// Compare a and b
if (a > b) // Testing for a greater than b
{
printf("a (%d) is bigger than b 0(%d)\n", a, b);
}
else if (a == b) // Testing for equality
{
printf("a (%d) is equal to b (%d)\n", a, b);
}
else // Otherwise a must be less than b
{
printf("a (%d) is less than b (%d)\n", a, b);
}
system("pause");
return 0;
• Enter a value of a that is greater than b.
• Enter a value of a that is less than b.
• Enter a value of a that is equal to b.
• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code.
• write the message “Password correct” if the value of a is 42 AND the value of b is 216.
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions:
Create a variable that accepts a positive odd integer.
Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.
Reverse the order of the list. Then, print out the list's new order in this manner:
[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.
Input
The first line contains an odd positive integer.
The next lines contains an integer.
7
1
2
3
4
5
6
7
Output
A line containing a list.
[7,6,5]-[4]-[3,2,1]
1. Using the online compiler
• Enter the code from the file
int main(int argc, char *argv[]) {
float f;
int a, b, c;
int quotient, remainder;
// Obtain integer values for a and b
printf("Enter the value for integer a: ");
scanf("%d", &a);
printf("Enter the value for integer b: ");
scanf("%d", &b);
printf("\n\n");
// Integer add, subtract, multiply, divide
c = a + b;
printf("%d + %d = %d\n", a, b, c);
c = a - b;
printf("%d - %d = %d\n", a, b, c);
c = a * b;
printf("%d * %d = %d\n", a, b, c);
quotient = a / b;
remainder = a % b;
printf("%d / %d = %d\ r %d\n\n\n", a, b, quotient, remainder);
// Floating point division without and without typecast.
f = a / b;
printf("%d / %d = %f (a and b are integers)\n", a, b, f);
f = (float)a / b;
printf("%f / %d = %f (a and b are integers but with a cast as a float)\n", (float)a, b, f);
Run the program. enter integer values for Enter 4 for a, and 5 for b.
A School District has its own internal mail. However, it can’t accept packages that
weigh more than 0.5 kg or are larger than 0.2 cubic meters. Write a program that asks the user
to input the weight of a package and its three dimensions (length, width, and height) in meters.
If the package doesn’t meet the requirements, it should say why it failed, otherwise give a
success message.
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms based on the outcome of the match.
A win earns a team 3 points.A draw earns 1.A loss earns 0.
The following information is expected:
MP:Matches Played
W:Matches Won
D:Matches Drawn(Tied)
L:Matches Lost
P:Points
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms based on the outcome of the match.
A win earns a team 3 points.A draw earns 1.A loss earns 0.
The following information is expected:
MP:Matches Played
W:Matches Won
D:Matches Drawn(Tied)
L:Matches Lost
P:Points
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0
Write a simple bank transactions program that will do the following:
Deposit
withdraw
inquire
USE FUNCTIONS FOR THIS PLEASE
IPL Match Details
Write a program that reads all the match outcomes and summarizes the information of all the matches.
Points are given to the terms based on the outcome of the match.
A win earns a team 3 points.A draw earns 1.A loss earns 0.
The following information is expected:
MP:Matches Played
W:Matches Won
D:Matches Drawn(Tied)
L:Matches Lost
P:Points
The team information should be displayed in descending order of points.
Sample input 1
6
CSK;RR;loss
RR;DD;draw
MI;KKR;win
KKR;RR;loss
CSK;DD;draw
MI;DD; draw
Sample output 1
Team: RR, Matches Played: 3, Won: 2, Lost: 0, Draw: 1, Points: 7
Team: MI, Matches Played: 2, Won: 1, Lost: 0, Draw: 1, Points: 4
Team: DD, Matches Played: 3, Won: 0, Lost: 0, Draw: 3, Points: 3
Team: CSK, Matches Played: 2, Won: 0, Lost: 1, Draw: 1, Points: 1
Team: KKR, Matches Played: 2, Won: 0, Lost: 2, Draw: 0, Points: 0
Make a C++ program the application of C++, and write the program at journal's paper, which find about the value of mechanical energy, with the following conditions: some people throw (by vertical) 20 mangoes with the weight of each mango is 100 gram. If the mangoes are thrown together by them. Then what is the value of the mechanical energy that occurs in that situation. With height is 10 meters and the acceleration is 1,25 m/s²in 4 second. (The acceleration due to gravity is 10 meters per second square). And as we know to find the value of the mechanical energy of an object is to first find the potential energy them the kinetic energy and then add both, next, it is the value of its mechanical energy.