Function in c that returns smallest of four given integers


Question1)a) Write C expressions for each of the following expressions:

i) √x-1/2+y-1/2

ii) (x2+3)/(x-4)-(x-2)/(x3+x-1)

iii) e|xy|sin-1(x/y)

Here x, y are floating point variables.

b) What change is required in the following program so that its output becomes 3, 6, 1, 20, 37,......,1034?

1 # include
2 # include
3 int main ( )
4 {
5 int a = 1, r = 2, i ,
6 for (i = 0; i <=10; i ++)
7 printf (", %d ", a*pow (r, i));
8 return 0;
9 }

Question2)a) Write a program to find a four digit number such that its value is increased by 75% when its left most digit is removed and is placed after its right most digit.

b) Consider the declaration

int beta[5][5], i, j;

Explain what is stored in beta after the following statement execute:

1 for(i = 0; i < 5; i++)
2 for(j =0; j < 5; j++)
3 beta [i][j] = 2*(i + j) % 4;

c) Explain the output of following code fragment:

1 int alpha = 5;
2 int beta = 10;
3 i f (beta > = 10)
4 {
5 int alpha = 10;
6 beta = beta + alpha;
7 printf ("%d, %d\n", alpha, beta);
8 }
9 printf ("%d, %d", alpha , beta)

Question3)a) Write a function which finds the first occurrence of a specific character in a given string. The function should return a pointer to the occurrence in the string or NULL if it is not found. (6)

b) Given the following program segment
1 int j = 2, i;
2 for(i = 0; i <= 5; i ++)
3 {
4 printf ("%4d", j);
5 j = j + 5;
6 }
7 printf ("\n");
Write a while loop and a do ::: while loop that have the same output.

Question4) a)Write a function int min ( int, int, int, int) that returns the smallest of four given integers

b) Admission to a professional course is subject to the following conditions

• Marks in Mathematics≥60.

• Marks in Physics ≥ 55.

• Marks in Chemistry ≥ 45

OR

• Total marks in mathematics and physics ≥ 150.

Given the marks in three subjects, write a program to process the applications to list the eligible candidates.

c) Write a program to print the following using for loops only:

  * * * * *
    * * *
      *
   * * *
 * * * * *

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Function in c that returns smallest of four given integers
Reference No:- TGS02598

Expected delivery within 24 Hours