Skip to main content

ads1

Class 10th Chapter :- 16 Function

 



 Function


C program has at least one main() function. The use of function in a program makes it modular.

Modularity means partitioning a complex problem into small sub-problems which are easy to understand and maintain.

There are two categories of functions in C.

(1) Library functions or System defined functions
(2) User defined functions

Library Functions  :-The C language standard library provides many built-in functions that our program can use. They are also known as system defined functions. For example printf( ), scanf(), sqrt() and cos are examples of library functions

User Defined Functions
The functions developed by user are known as user defined functions. The main() is special type of user defined function in C. The program execution starts from main() function. Testing and debugging of such program may be become difficult for programmer.

Variables By scope of variable we mean the part of program where the variable is accessible. In C scope of variables are of two types:

(i) Global variables
(ii) Local variables

These formal parameters accept the value sent at the time of calling function from the main(). The integer variable result returns the addition of two numbers to the caller function which is stored in total variable of main().

Function Prototype

The function prototype is needed when the function is defined after the main() in a program. When we call any function in our program, compiler searches for a corresponding function definition.

(1) The main() function in C language is a

(a) User defined function
(b) Library function
(c) Keyword
(d) Reserved function

(2) By default the main() function returns
(a) Char value
(b) Float value
(c) Integer value
(d) Double value

(3) Which keyword is used as a return type when function does not return any value?
(a) int
(b) main
(c) void
(d) auto

(4) Which of the following is not an inbuilt library function ?
(a) pow()
(b) printf()
(c) sum()
(d) sqrt()

(5) What will be the value of variable number2 after execution of following code :
int main() {
int number1 = 2, number2;
number2 = sqr(number1);
printf("number2 = %d",number2);
return 0;
int sqr(int n){
return(n*n); }//End of program

(a) number2 = 4  
(b) number2 = 6
(C) number2 = 8
(d) number2 = 18



ads2

Popular posts from this blog

11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following:

    11. Write a Java program to input basic salary of an employee and calculate its Gross salary according to following: Basic Salary <= 10000 : HRA = 20%, DA = 80% Basic Salary <= 20000 : HRA = 25%, DA = 90% Basic Salary > 20000 : HRA = 30%, DA = 95% Static Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     if(basic <=10000)     {         da = basic * 0.8;         hra = basic *0.2;     }              else if(basic <=20000)     {         da = basic * 0.9;         hra = basic *0.25;     }     else     {         da = basic * 0.95;         hra = basic * 0.3;     }     gross = basic + da + hra;     System.out.println("The Gross Salary is :-"+gross);     } } Output :-  Dynamic Solution :-  class salary {     public static void main(String args[])     {     double basic=20000.50,gross,da,hra;     Scanner in = new Scanner(System.in);     System.out.println("Enter the Basic Salary

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise or class wise.

1. Given the school result data, analyses the performance of the students on #different parameters, e.g subject wise  or class wise. Solution :-   # x-axis is shows the subject and y -axis # shows the markers in each subject # import pandas and matplotlib  import pandas as pd  import matplotlib.pyplot as plt # Simple Line Chart with setting of Label of X and Y axis, # title for chart line and color of line  subject = ['Physic','Chemistry','Mathematics', 'Biology','Computer'] marks =[80,75,70,78,82] # To draw line in red colour plt.plot(subject,marks,'r',marker ='*')     # To Write Title of the Line Chart plt.title('Marks Scored') # To Put Label At Y Axis plt.xlabel('SUBJECT')           # To Put Label At X Axis plt.ylabel('MARKS')             plt.show() Output :- 

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category.

24.Create a Data Frame quarterly sales where each row contains the item category, item name, and expenditure. Group the rows by the category and print the total expenditure per category. import pandas as pd  # initialize list of lists data = [['CAR','Maruti',1000000],['AC','Hitachi',55000],['AIRCOLLER','Bajaj',12000], ['WASHING MACHINE','LG',15000],['CAR','Ford',7000000],['AC','SAMSUNG',45000],['AIRCOLLER','Symphony',20000],['WASHING MACHINE','Wirlpool',25000]] Col=['itemcat','itemname','expenditure'] # Create the pandas DataFrame qrtsales = pd.DataFrame(data,columns=Col) # print dataframe.  print (qrtsales) qs=qrtsales.groupby('itemcat')  print('Result after Filtering Dataframe')  print(qs['itemcat','expenditure'].sum()) Output :-