Write a program that will delete all negative number by using Pointer. You have to declare a
pointer array and dynamically allocate memory to input elements of array.
The purpose of a sorting algorithm is to order/categorize set of items within a series of items.
Write a program/method to swap two neighboring numbers in an array when the first index is given.
Write a program that calculate the cost of energy for energy units restricted between 0 to 500 kWh for an amount less than $6 000.00 for any Zimbabwean resident customer and any amount and unlimited number of units for a foreign resident customer buying from outside Zimbabwe at a rate of $90.00 to one USD. The tariffs are as follows:
• 0 to 50 kWh cost $2.25
• Above 50 kWh to 100 kWh cost $4.51 / kWh
• Above 100kWh to 200 kWh cost $7.89 / kWh
• Above 200kWh to 300 kWh cost $11.25 / kWh
• Above 300kWh to 400 kWh cost $12.94 / kWh
• Above 400 kWh cost $13.50 / kWh
2. Using the online compiler •
Enter the code
int main(int argc, char *argv[]) {
byte_t first_byte = 128;
byte_t second_byte = 1;
int shift;
printf("Enter the number of left/right shifts: ");
scanf("%d", &shift);
printf("\n\n");
// Right-shift first_byte
first_byte = first_byte >> shift;
// Left-shift second byte
// This is the equivalent of second_byte = second_byte << shift;
second_byte <<= shift;
// Display the results
printf("128 >> %d = %d\n", shift, first_byte);
printf("1 << %d = %d\n", shift, second_byte);
system("pause");
return 0;
}You will be prompted to enter a value for the number of shifts. Initially enter the value of zero
Repeat the previous two steps with values of 1, 2, 3, 4, 5, 6, 7 and 8
10. Using the online compiler
• Write a program using a for loop that counts upwards from 0 to 100 in steps of 2.
9. Using the online compiler
• Write a program that counts down from 100 to 0 using a for a loop.
8. Using the online compiler
• Write a program that counts upwards from 0 to 100 using a for a loop. •
7) 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;
}• Run the program (which uses for loops and arrays).
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
4. One of the purposes of asymptotic analysis is to compare algorithms. Use the codes of selection and bubble sort program you have written and decide which algorithm performs better.
I. Use the random number generator you programmed and generate a list of 100 items.