Professional Documents
Culture Documents
#include <stdio.h>
int z=10;
int add1(int x,int y);
int add2(int k);
int main()
{
int a=2,b=3,c=0,d=0;
c=add1(a,b);
d = add2(c);
return 0;
}
int add1(int x,int y)
{
int z=0;
z=x+y;
return z;
}
int add2(int k)
{
int m=0;
m=z+k+5;
return m;
}
6. Write a function named check() that has three parameters. The first
parameter should accept an integer number, and the second and third
parameters should accept a double precision number. The function body
should just display the values of data passed to the function when it’s called.
7. Write a program to accept a figure code and find the area of different
geometrical figures such as circle, square, triangle and rectangle using
switch case and functions.
8. Write a program to add, subtract, multiply and divide two integers using
user-defined type functions for each operation with return type.
9. Write a function that takes a positive integer as input and returns the
leading digit in its decimal representation.
11. Write a program that accepts an array of integers and displays the average.
Use a function to calculate the average.
12. Write a function to find the given year is a leap year or not.
13. Write two functions that compute f(x)=2.3*x and g(x,y)=x*y. x and y are
user defined values.
14. Write a program using functions to store some elements (1-D Array) and
accept key then split the array from that point and add the first half to the
end of second half.
(Eg: Enter the value of n: 5 enter the numbers:30 10 40 50 60. Enter the
position of the element to split the array: 2. The resultant array is: 40 50 60
30 10)
15. Write a program to find the sum of all odd numbers within the given limit
using recursion.
19. Write a program to convert decimal number to binary number using the
function.
21. Write a program to find Sum of elements positioned at even places of an array
using function.
23. Given a set of cities, the central city is the city that has the shortest total
distance to all other cities. Write a program that prompts the user to enter the
number of the cities and the locations of the cities (coordinates). Write
functions to find the central city and its total distance to all other cities.
For example
2.5 5.0 5.1 3.0 1.0 9.0 5.4 5.4 5.5 2.1
For example
output:
25. Consider an array having size 20. If the array is not full, an element can be
inserted at the beginning, ending or any user defined position. If the array is
not empty, an element can be removed from the beginning, ending or any user
defined position. Write a program to implement the concept using the
following functions: