Questions: 1 978

Answers by our Experts: 1 850

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

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.

Write a C program that displays the following menu on the screen:

   MENU OF OPERATIONS

  By: <Your Name Here>

  [ 1 ] - Addition

  [ 2 ] - Subtraction

  [ 3 ] - Multiplication

  [ 4 ] - Division

  [ 5 ] - Modulo Division

  [ 6 ] - Quit

  Enter Your Choice:  3

  You have chosen Multiplication!

  Enter three integers: 89 78 67

  Sum = 465,114

  Thank you for using my program...

The user has to be prompted to input a number of his/her preferred operation and will then be asked to enter three integers and display the computed value based on the inputted operation. 


Create a C program that accepts 3 integers and display separately the highest and the lowest among them.


   Sample Run:


   Enter 3 integers: 36 54 45


   Highest: 54


   Lowest: 36


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.


II. Test that array with both selection sort and bubble sort.


III. Compute the time taken for each algorithm to complete.


IV. Repeat step two and three for 1000, 10000, 100000, and 1000000 random numbers.


V. Plot the results in a graph


3. The purpose of a sorting algorithm is to order/categorize set of items within a series of items.


I. Write a program/method to swap two neighboring numbers in an array when the first index is given.


II. Write a program/method to compare two neighboring numbers in an array when the first index is given.


III. Now combine the above two methods and implement bubble sort algorithm. You must call the above two methods in your sorting program.


IV. Now test your sorting program with a random number array generator you created 2.IV.


1.    The purpose of a sorting algorithm is to order/categorize set of items within a series of items.                                                                         

                          I.    Write a program/method to find a minimum number in an integer numbers array.         

                        II.    Write a program/method to swap two numbers in the above array when the indices are given.

                      III.    Now combine the above two methods and implement selection sort algorithm. You must call the above two methods in your sorting program.

                     IV.    Write a program/method to generate an array of random numbers.

                       V.    Now test your selection sort algorithm with a random number array.




10. Using the online compiler

(Part 8) Write a program that counts upwards from 0 to 100 using a for loop


• Modify the program of Part 8 so that it counts upwards from 0 to 100 in steps of 2.

• Add this source code to your logbook.

• Run the program and add the output of this program to your logbook.

• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code


9. Using the online compiler

• Write a program that counts down from 100 to 0 using a for loop.

• Add this source code to your logbook.

• Run the program and add the output of this program to your logbook.

• Write a short reflective account of the code concentrating on its functionality and comparing the outputs against the source code.