Advertisement
wingman007

OSKAExam2024

Feb 13th, 2024 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. 001
  2. Write a function void print_perimeter_trapez(unsigned int a, unsigned int b, unsigned int c, unsigned int d), which prints "Perimeter of trapez(a,b,c,d) = P". For computing and printing use functions perimeter_trapez(unsigned int a, unsigned int b, unsigned int c, unsigned int d,) and printf.
  3.  
  4. 002
  5. Write a function void print_sum(int n), which prints "sum(n) = S". Where S is the sum of the numbers to n including n. For computing and printing use functions int sum(int n) and printf.
  6.  
  7. 003
  8. Write a function void print_fib(unsigned short n), which prints "fib(n) = F" Where F is the Fibonacci number at position n . For computing and printing use functions int fib(unsigned short n) and printf.
  9.  
  10. 004
  11. Write a function void print_letter_of_my_strdup(char* s, unsigned short n), which prints "my_strdup[n] = L" where L is the letter or ASCII number of the letter at position n. For making a duplicate of the string use a function char *my_strdup(char *s) and for printing use function printf.
  12. Tip: Create a string to be duplicated in main() using char *s = (char *)malloc(5 * sizeof(char)); s[0] = 'a'; s[1] = 'b'; s[2] = 'c'; s[3] = 'd'; s[4] = 'e'; s[5] = 0;
  13.  
  14. 005
  15. Write a function void print_perimeter_of_rectangle(int a, int b), which prints "Perimeter of rectangle(a, b) = P". For computing and printing use functions int perimeter_of_rectangle(int a, int b) and printf.
  16.  
  17. 006
  18. Write a function void print_area_of_rectangle(int a, int b), which prints "Area of rectangle(a, b) = S". For computing and printing use functions int area_of_rectangle(int a, int b) and printf.
  19.  
  20. 007
  21. Write a function void print_perimeter_of_triangle(int a, int b, int c), which prints "Perimeter of triangle(a, b, c) = P". For computing and printing use functions int perimeter_of_triangle(int a, int b, int c) and printf.
  22.  
  23. 008
  24. Write a function void print_perimeter_of_rectangular_triangle(int a, int b), which prints "Perimeter of rectangular triangle(a, b) = P". For computing and printing use functions int perimeter_of_rectangular_triangle(int a, int b) and printf.
  25.  
  26. 009
  27. Write a function void print_area_of_triangle(int a, int b, int c), which prints "Area of triangle(a, b, c) = S". For computing and printing use functions int area_of_triangle(int a, int b, int c) and printf.
  28.  
  29. 010
  30. Write a function void print_area_of_cube(int a), which prints "Area of cube(a) = S". For computing and printing use functions int area_of_cube(int a) and printf.
  31.  
  32. 011
  33. Write a function void print_avg_int(int a, int b, int c), which prints "Average of (a, b, c) = A". The average is an integer number. For computing and printing use functions int avg_int(int a, int b, int c) and printf.
  34.  
  35. 012
  36. Write a function void print_avg_short(short a, short b, short c), which prints "Average of (a, b, c) = A". The average is an integer number. For computing and printing use functions short avg_short(short a, short b, short c) and printf. The function short avg_short(short a, short b, short c) calculates the average value of these three short numbers.Try that it works correctly for both positive and negative numbers(including their mix).
  37.  
  38. 013
  39. Write a function void print_max(unsigned char a, short b, int c), which prints "Max of (a, b, c) = M". M is the biggest of these 3 numbers. For computing and printing use functions int max(unsigned char a, short b, int c) and printf.
  40.  
  41. 014
  42. Write a function void print_min(unsigned char a, short b, int c), which prints "Min of (a, b, c) = M". M is the smallest of these 3 numbers. For computing and printing use functions int min(unsigned char a, short b, int c) and printf.
  43.  
  44. 015
  45. Write a function void print_positive(int a, int b, int c), which prints "Positive of (a, b, c) = P". Where P is 1 if all arguments are positive, otherwise 0. For computing and printing use functions int positive(int a, int b, int c) and printf.
  46.  
  47. 016
  48. Write a function void print_power(int n, unsigned int m), which prints "Pow (n,m) = P". Where P is n to the power of m (n^m). For computing and printing use functions int power(int n, unsigned int m) and printf.
  49.  
  50. 017
  51. Write a function void print_powers_element(unsigned short n), which prints "Pow (n) = P". Where P is the n-th element of an array[10], created by function void powers(). Create a static field of 10 short elements.Write the function void powers(), which will store numbers 1 to power of 2, 2 to power of 2, ..., 10 to power of 2 in the field. For printing use printf.
  52.  
  53.  
  54.  
  55. 018
  56. Write a function void print_powers_element(unsigned short n), which prints "Pow (n) = P". Where P is the n-th element of an array[10], created by function void powers(). Create a field(using a malloc call from C) of 10 int types.Write the function void powers(), which will store numbers 2 to the power of 0, 2 to the power of 1, ..., 2 to the power of 9 in the field.. For printing use printf.
  57.  
  58. 019
  59. Write a function void print_array_min_element(), which prints "Min =M". Where M is the smallest element of an array[10]. Write int minimum() function that returns the smallest array element. In the body of this function in C, create a local variable of the field type of the size of 10 int elements from which the values will be selected. (int local[10] = {10, 15, 1, 28, 16, -18, 5, 20, 1, 3};). Try that the function works correctly for both positive and negative numbers. For printing use printf.
  60.  
  61. 020
  62. Write a function void print_array_max_element(), which prints "Max =M". Where M is the biggest element of an array[10]. Write int max() function that returns the biggest array element. In the body of this function in C, create a local variable of the field type of the size of 10 int elements from which the values will be selected. (int local[10] = {10, 15, 1, 28, 16, -18, 5, 20, 1, 3};). Try that the function works correctly for both positive and negative numbers. For printing use printf.
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement