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.
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.
As a safety precaution banks provide a feature that during any ATM transaction if someone comes and attacks, then the customer can enter the ATM pin in reverse order. This sends a message to the nearest police station. However if the reversed pin is the same as he original pin then no alarm is created. The bank needs a software application that checks that a user chooses an ATM pin whose reverse is not the same number. A software need to be developed with following requirements using while loop.
a. Read the pin number
b. Calculate the reverse the pin number
c. if the reversed pin is same as original pin then inform the user that this is an invalid pin number
In a box of total area 10000cm3, Mr. Varun has to pack the balls of given radius “r” and all the balls have the same volume, Help Mr. Varun to find the total number of balls that he can pack in the given box.
Requirements
Capture the radius of the ball “r”
Compute the volume (Hint: Volume=4/3πr3)
Calculate how many number of balls can be placed in the box of 10000cm3 box
Display the number of balls packed by Mr. Varun
1. Return types and basic algorithms
I. Write a program to find the sum of 10 integer numbers inside a separate function called sum() and print the total inside the main function.
II. Improve the above program to find even numbers in a given array.
III. Which parts of the above program (a) needs to be changed to code linear search?
Your task is to develop a circular linked-list based simulation of the Josephus problem. The simulation will be text based. The user should be presented with a text-based menu asking him to enter the total number of people (n), starting point (i), direction (clockwise/anti-clockwise) and number to be skipped (k). Your program then must populate a circular linked list with n nodes where data of each node should be their position in the circle (starting from 1).Your program should then work iteratively printing the remaining persons after each iteration (round of killing). After the last iteration only the node with the winning initial position should be left in the list. Example:
• For n =15
• k = 2
• starting point (i) = 1
• direction = clockwise
Initial scenario:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
After1st iteration: 1 3 5 7 9 11 13 15
After2nd iteration: 3 7 11 15
After3rd iteration: 7 15
After4th iteration: 15 (15 remains in the end). Program ends.
In the situation where there are multiple users or a networked computer system, you probably share a printer with other users. When you request to print a file, your request is added to the print buffer. When your request reaches the front of the print buffer, your file is printed. This ensures that only one person at a time has access to the printer and that this access is given on a first-come, first-served basis. Write a C program to implement the above scenario.
Arjun wants to count total number of digits of an Integer number (N). Help him to generate the program using do while loop.
As a safety precaution banks provide a feature that during any ATM transaction if someone comes and attacks, then the customer can enter the ATM pin in reverse order. This sends a message to the nearest police station. However if the reversed pin is the same as he original pin then no alarm is created. The bank needs a software application that checks that a user chooses an ATM pin whose reverse is not the same number. A software need to be developed with following requirements using while loop.
a. Read the pin number
b. Calculate the reverse the pin number
c. if the reversed pin is same as original pin then inform the user that this is an invalid pin number