Unit 3 Control Flow
Part-I- Decision Control and Looping statements.
Decision Control Statements
2.1) if condition
2.2) if…. else condition
2.3) nested if ……else
2.4) if…else ladder
2.5)switch statement
Looping Statements
2.6)While
2.7)Do while
2.8)for
i)Nested for
Jumping ststement
2.9)Break
2.10)Continue
2.11)Go to
Function
-------------------------------------------------------------------------------------------------------------------
-----------------------
C- Programming Dr. Laxmikant Goud Page 1
2.1 Simple if() statement
if statement is the most simple decision-making statement. If a certain condition is true
then a block of statement is executed otherwise not.
The program execution procedure in one direction only i.e TRUE
Syntax-
if(condition)
{
Statement block;
}
Statement x;
If the condition is true then control transfer inside if block and the statements inside if
block will be executed
If condition is false then control transfer to outside if block to statement x.
Flowchart:
1. Write a program in ‘c’ the find largest of number between two numbers. Accept
numbers from user.
#include<stdio.h>
#include<conio.h>
C- Programming Dr. Laxmikant Goud Page 2
void main()
{
int num1,num2;
printf("Enter Two numbers:"); //Message
scanf("%d%d",&num1,&num2); //Read two numbers
if(num1>num2)
{
printf("Num1 is Largest");
}
if(num2>num1)
{
printf("Num2 is Largest");
}
getch();
}
2. WAP to find smallest number among two numbers. Accept numbers from user
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2;
printf("Enter Two numbers:"); //Message
scanf("%d%d",&num1,&num2); //Read two numbers
if(num1<num2)
{
printf("Num1 is Smallest");
}
if(num2<num1)
{
printf("Num2 is Smallest");
}
C- Programming Dr. Laxmikant Goud Page 3
getch();
}
2. if-else() condition
The if-else statement is a decision-making statement that is used to decide whether the part of
the code will be executed or not based on the specified condition (test expression).
If the given condition is true, then the code inside the if block is executed, otherwise the code
inside the else block is executed.
Syntax-
if(condition)
{
statements;
}
else
{
statements;
}
Statement x;
When the program control first comes to the if-else block, the test condition is checked.
If the test condition is true:
The if block is executed.
If the test condition is false:
The else block is executed
Flowchart:
C- Programming Dr. Laxmikant Goud Page 4
3. write a program in ‘c’ to find Entered number is positive or negative number.
#include<stdio.h>
#include<conio.h>
void main()
{
int n;
printf(“enter positive number”);
scanf(“%d”, & n);
if (n>0)
{
printf(“number is positive”);
}
else
{
printf(“number is negative”);
}
getch();
}
4. WAP to find whether Given Year is Leap Year or Not
#include<stdio.h>
#include<conio.h>
void main()
{
int year;
printf("Enter Year:");
scanf("%d",&year);
if(year%4==0)
{
printf("Entered Year is Leap Year");
}
else
{
printf("Entered Year is NOT a Leap Year");
}}
C- Programming Dr. Laxmikant Goud Page 5
5. WAP to check if the person is eligible for Voting or NOT. Age >= 18 then Eligible
#include<stdio.h>
#include<conio.h>
void main()
{
int age;
printf("Enter Your Age:");
scanf("%d",&age);
if(age>=18)
{
printf("You are Eligible For Voting");
}
else
{
printf("You Are not eligible for Voting");
}
printf("\nEnd of Program");
getch();
}
6. WAP to check whether Given number is Even or Odd
#include<stdio.h>
#include<conio.h>
void main()
{
int num;
printf("Enter Number:");
scanf("%d",&num);
if(num%2==0)
{
printf("Given Number is Even");
}
else
{
printf("Given Number is ODD"); } }
C- Programming Dr. Laxmikant Goud Page 6
7. WAP to find smallest number among two numbers. Accept numbers from user
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2;
printf("Enter Two numbers:"); //Message
scanf("%d%d",&num1,&num2); //Read two numbers
if(num1<num2)
{
printf("Num1 is Smallest");
}
else
{
printf("Num2 is Smallest");
}
getch();
}
8. WAP to find Largest number among two numbers. Accept numbers from user
#include<stdio.h>
#include<conio.h>
void main()
{
int num1,num2;
printf("Enter Two numbers:"); //Message
scanf("%d%d",&num1,&num2); //Read two numbers
if(num1>num2)
{
printf("Num1 is Largest");
}
else
{
printf("Num2 is Largest");
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 7
3. Nested ifelse()
When a series of decision is required, then nested if-else is used. Nesting means using one if-
else within another one. Nested if statements means adding if statement inside another if
statement.
Syntax-
if(condition)
{
if(condition)
{
True block of statement;
}
else
{
False block of statement;
}
}
else
{
if (condition)
{
True block;
}
else
{
False block;
}
}
If the outer if condition is true then the control goes to inner block.
In the inner block, if the inner if condition is true, then it will process the If block
otherwise it will process an else block.
C- Programming Dr. Laxmikant Goud Page 8
If the outer if condition is false the outer else block is processed and control goes to
outer else block.
In the outer else block, if the inner if condition is true, then it will process the If block
otherwise it will process an else block.
9. WAP to find Largest number among three numbers
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter three numbers:");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("A is Largest Number");
}
else
{
printf("C is Largest Number");
}
}
else
{
if(b>c)
{
printf("B is largest");
}
else
{
printf("C is Largest");
}
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 9
4. if-elseif OR Else-If ladder-
Here, a user can decide among multiple options. The if statements are executed from the
top down.
As soon as one of the if conditions is true, the statement associated with that if is
executed, and the rest of the else-if ladder is bypassed.
If none of the conditions is true, then the final else statement will be executed.
Else-if ladder is similar to switch statement.
Syntax-
if(condition1)
Statement block 1;
else if(condition 2)
Statement block;
else if (condition n)
Statement block n;
else
Default statement;
Statement x;
Flowchart:
C- Programming Dr. Laxmikant Goud Page 10
10. write a program in ‘c’ that read roll number, mark of subject, calculate total marks &
average marks display all information with remark & give remark according to the following
condition.
1) Remark is distinction when average marks are >70.
2) Remark is first class if average marks are in between 60 & 70.
3) Remark is second class if average marks are in between 50 &60.
4) Remark is third class if average marks are in between 40 & 50 otherwise 5) Remark is fail.
#include<stdio.h>
main()
{
int s1,s2,s3,s4,total;
float per;
printf(“enter marks of 4 subjects \n”);
scanf(“%d %d %d %d”,&s1,&s2,&s3,&s4);
total=s1+s2+s3+s4;
per=(total/4)*100;
if(per>=70)
{
printf(“Distinction”)
}
elseif(per>=60)
{
printf(“First Class”);
}
elseif(per>=50)
{
printf(“Second Class”);
}
elseif(per>=40)
{
printf(“PASS”);
}
else
{
printf(“FAIL”);
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 11
5. Switch Statement-
The switch statement test the value of given variable or expression against a list of case
values and when a match is found a block of statements associated with that case is
executed.
The variable in switch should be either integer or character or the expression.
There can be any number of cases. The cases can be written in any sequence.
Each statement of the case can have a break statement.
The default statement is optional and if none of the cases are matched then default
statement is executed.
Syntax-
switch(expression)
{
case value1:
Statement block 1;
break;
case value2:
Statement block 2;
break;
case value3:
Statement block 3;
break;
case Valuen:
Statement block N;
break;
defaul:
Default Statement block ;
}
C- Programming Dr. Laxmikant Goud Page 12
Flowchart: Following flow chart shows the switch condition-
C- Programming Dr. Laxmikant Goud Page 13
# Write a program in ‘c’ which can perform addition, subtraction, multiplication & division of
two number using switch case or
# Write a program in C to create simple calculator by using switch cases..
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, ch;
clrscr();
printf(“enter two number”);
scanf(“%d%d”,&a&b);
printf(“enter your choice 1.Add, 2.Sub, 3.Mul, 4.Div”);
scanf(“%d”, &ch);
switch(ch)
{
case 1:
c=a+b;
printf(“addition=%d”, c);
break;
case 2:
c=a-b;
printf(“substraction=%d”, c);
break;
case 3:
c=a*b;
printf(“multiplication=%d”, c);
break;
case 4:
c=a/b;
printf(“division=%d”, c);
break;
deafault:
printf(“Wrong Choice”);
}
gech();
}
C- Programming Dr. Laxmikant Goud Page 14
LOOPING STATEMENT
1. while loop
2. do –while loop
3. for loop
4. Jump satatement
a. break
b. goto
c. continue
1. for() loop:-
For loop in C programming is a repetition control structure that allows programmers to execute
statements for specific number of times.
Syntax:-
for (initialization; condition; increment/decrement)
{
statements;
}
In for loop, a loop variable is used to control the loop.
Firstly we initialize the loop variable with some value, and then check its test condition.
If the condition is true then control will move to the body and the body of for loop will be
executed.
C- Programming Dr. Laxmikant Goud Page 15
Loop variable will be incremented and repeated till the end value condition becomes true.
Once the End value condition becomes false then for loop will stop.
Flowchart:-
Write a program in ‘C’ which will print message “Hello World 10 times”.
/* operation of for loop */
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf(“Hello World”);
}
C- Programming Dr. Laxmikant Goud Page 16
getch();
}
Write a program in ‘C’ which can display sum of 20 natural no.
#include<stdio.h>
#include<conio.h>
void main()
{
int i, sum=0;
clrscr();
for(i=1;i<=20;i++)
{
sum=sum+i;
}
Printf(“Sum =%d”,sum);
getch();
}
2. While Loop:-
While loop is an entry control loop that mean’s the condition is tested before the loop body is
executed.
The general form of while statement is
Syntax: while (condition)
{
Statements Loop body;
}
Statement x;
If condition is true then Loop Body is executed.
If condition is False then Statement x is executed i.e. Loop body is not executed.
Example:
Write a program in ‘C’ which will print message “Hello World 10 times”.
/* operation of for loop */
C- Programming Dr. Laxmikant Goud Page 17
#include<stdio.h>
#include<conio.h>
void main()
{
int i;
clrscr();
for(i=1;i<=10;i++)
{
printf(“Hello World”);
}
getch(); false
While
}
condition
Flowchart:-
true
Loop body
Next stmt
Write a Program that will display 1 to 100 numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int i=1;
while(i<=100)
{
[rintf(“%d\n”,i);
i=i+1;
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 18
Write a C program to print the sum of first 5 natural numbers using while.
void main()
{
int i=1,sum=0;
while(i<=5)
{
sum=sum+i;
i++;
}
printf(“%d”,sum);
getch();
}
Write the program in ‘C’ which can display odd no. between 1 to 50.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1;
while(i<=50)
{
if(i%2==1)
{
printf(“%d\n”, i);
}
i++;
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 19
3. do-while loop:-
This loop is used when the statements are to be executed initially and then condition is
checked.
In this loop computers enters into the body of do while ,execute it and then checks the
condition .
if the condition is true it goes back and continuous till condition remains true. When
condition become false it terminates the loop and goes to the next statement.
Syntax: do
{
loop body;
}while(condition);
Flowchart:
C- Programming Dr. Laxmikant Goud Page 20
Write a program to print Natural Numbers between 1 to 100 using do-while.
#include<stdio.h>
#include<conio.h>
main()
{
int num=1;
do
{
printf(“%a\n”,num);
n++;
}while(num<=100);
getch();
}
Write a program in C to print the sum of first 5 natural numbers using do-while.
void main()
{
int i=1,sum=0;
do
{
sum=sum+i;
i++;
} while(i<=5);
printf(“%d”,sum);
getch();
}
C- Programming Dr. Laxmikant Goud Page 21
Differentiate between while and do-while loop
while do-while
Condition is checked first then statement(s) is Statement(s) is executed atleast once,
executed. thereafter condition is checked.
It might occur statement(s) is executed zero At least once the statement(s) is executed.
times, If condition is false.
No semicolon at the end of while. Semicolon at the end of while.
while(condition) while(condition);
If there is a single statement, brackets are not Brackets are always required.
required.
Variable in condition is initialized before the variable may be initialized before or within
execution of loop. the loop.
while loop is entry controlled loop. do-while loop is exit controlled loop.
while(condition) do { statement(s); }
{ statement(s); } while(condition);
4. Nested for loop :-
When one loop is inserted completely within another loop then it is called as nested loop.
When the nested for loop are executed then for every increment/decrement of outer loop, the
inner loop will be executed for all values.
Hence, the nested loops are very powerful & useful. The nested loop is situated following form
Syntax:
for(initialization; condition; incr/decr)
{
for(initialization; condition; incr/decr)
{
Statements;
}
Statements;
}
Write a program in ‘c’ that show & the working of nested for.
#include<stdio.h>
#include<conio.h>
main()
{
C- Programming Dr. Laxmikant Goud Page 22
int I,j;
clrscr();
for(i=1;i<=10;i++)
{
for(j=1;j<=10;j++)
{
Printf(“%d%d\t”,i,j);
}
Printf(“\n”);
}
getch();
}
Jump Statement:-
1. Break-
The break statement is used when you want to break the cycle of execution. After satisfying the
condition this statement breaks the further operation of the loop & stop the execution of loop &
comes out of loop or block.
When break statement gets executed computer stops execution of loop and goes outside loop to
the next statement. The beak statement exit from single loop only,
Example:
#include<stdio.h>
#include<conio.h>
main()
{
int i;
for(i=1;i<=5;i++)
{
if(i==3)
{
break;
}
C- Programming Dr. Laxmikant Goud Page 23
printf(“%d\n”,i);
}
getch();
}
Output:
1
2
In above program when i=3 then break statement executed and it stops the further execution of
loop comes outside loop.
2. Continue:-
When this statement get’s executed the control of computer goes back to the top of the loop
without executing the remaining statement.
The statement should be alone with specified structure only.
Example:
#include<stdio.h>
#include<conio.h>
main()
{
int i;
for(i=1;i<=5;i++)
{
if(i==3)
{
continue;
}
printf(“%d\n”,i);
}
getch();
}
Output:
1
C- Programming Dr. Laxmikant Goud Page 24
2
4
5
In above program when i=3 then continue statement executed and it skips the further statements
and goes to the next value of loop. Hence 3 value of I is not printed.
3. Goto statement:-
This is a statement which transfer the control of the computer from one point in the program to
the other point there are two types of goto statements .
1. Conditional goto
2. Unconditional goto
1. Conditional goto :
When a goto statement is written as part of body of if or else then it is called conditional goto .
Here we have a condition to control the number of repetition. Whenever a goto statement is
used always prefer conditional goto rather unconditional.
Example:
#include<stdio.h>
#include<conio.h>
main()
{
int n=1;
top:printf(“%d\n”,n);
n++;
if(n<=10)
{
goto top;
}
getch();
}
C- Programming Dr. Laxmikant Goud Page 25
2. Unconditional goto:-
When a goto statement written without any condition then it is called as unconditional goto. In
this statement we cannot control the number of repetition and hence program may enter into
infinite loop.
Example:
#include<stdio.h>
#include<conio.h>
void main()
{
int n=1;
top:printf(“%d\n”,n);
n++;
goto top;
getch();
}
Part-II- Function
1. what is function?
A function is a self-contained block of codes or sub programs with a set of statements that
perform some specific task or coherent task when it is called.
Any ‘C’ program contain at least one function i.e main().
In C there are two types of function
1. Predefined function/library
2. User defined function
Predefined or library function are prewritten compile & placed in library. They come along
with the compiler and can’t be modified.
User defined functions are written by user & the user has the freedom to choose the name
arrangements & written data type of a function.
C- Programming Dr. Laxmikant Goud Page 26
2. Working with function:-
There are three Concepts are used when we will use a functions.
1. Function Declaration (Function Prototype):-
Function declaration is also known as function prototype.
It inform the compiler about three thing, those are name of the function, number and
type of arguments received by the function and the type of value returned by the
function
Syntax:-
returntype functionname(arg1type, arg2type,….., argntype);
The function prototype tells to the compiler –
o The return_data type of function.
o The name of the function.
o The number & types of arguments that will be passed to the function.
Function Prototype declaration is done before the main() function.
The function prototype tells to the compiler that there is a function later somewhere
presents in the program so compiler keep that function in their memory.
Ex.:- int sum(int,int);
void diplay();
double square(double);
2. Function Definition (Function Body):-
Function definition is the actual function. Function definition consists of the whole code
of the function.
It tells about what function is doing what are its inputs and what its output are.
Syntax:-
returntype functionname(type arg1,arg2,…….. argn)
{
Statements;
}
i. return type:-
The return type denotes the type of the value that function will return and if it does not return
any value then it is void by default.
C- Programming Dr. Laxmikant Goud Page 27
ii. function name:-
The function name can be any valid name.
iii. Argument list(parameter list):-
These are means of communication between the calling & called function. The arguments of
the function definition are known as formal arguments.
3. Function Call
When the function gets called by the calling function then function is called.
The compiler executes these functions when there function name() followed by semicolon.
Syntax:-
functionname(arg1,arg2,arg3);
The argument that are used inside the function call are called actual argument
Ex:-
sum(a,b); //a and b are actual arguments
Example:
/* addition of two numbers using function */
#include<stdio.h>
#include<conio.h>
void add( int,int); // function prototype declaration
void main()
{
int a=10,b=20;
add( int,int);
add(a,b); // function call (Calling Function) a and b are actual parameters
getch();
}
void add(int x, int y) // function definition (Called Function) x and y are formal arguments
{
int res;
res=x+y;
printf(“%d”,res);
}
C- Programming Dr. Laxmikant Goud Page 28
3. Function Arguments
1. Actual Argument
The argument which is mentioned or used inside the function call is knows as actual
argument and these are the original values and copies of these are actually sent to the
called function.
The argument that are used inside the function call are called actual argument
Ex:-
add(a, b); //a and b are actual arguments
2. Formal Arguments
The arguments which are mentioned in function definition are called formal arguments
or dummy arguments.
These arguments are used to just hold the copied of the values that are sent by the
calling function through the function call.
void add(int x, int y) // function definition (Called Function)
{
}
Here x and y are Formal Arguments
Difference Between the formal argument and the actual argument are
1) The formal argument are declared inside the parenthesis whereas the local variable declared
at the beginning of the function block.
2) The formal argument are automatically initialized when the copy of actual arguments are
passed while other local variable are assigned values through the statements.
Note: Order number and type of actual arguments in the function call should be match with the
order number and type of the formal arguments.
4. return() statement
It is used to return value to the calling function. It can be used in two way as
return value;
OR
return(expression);
Ex:-
C- Programming Dr. Laxmikant Goud Page 29
return (a);
Ex:- /*addition of two numbers using function*/
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
int a=10,b=20,result;
result=add(a,b); //Calling Function
printf(“%d”,result);
getch();
}
int add(int c,int d) //called function
{
int sum=c+d;
printf(“%d”,sum);
}
6. Category of Function based on argument and return type
1. Function with no argument no return value
2. Function with no argument but return value
3. Function with argument but no return value
4. Function with argument with return value
1. Function with no argument no return value:-
When a function has no argument then it does not receive any data from the calling
function. Similarly it does not return a value.
In effect there is no data transfer between the calling function & called function.
#include<stdio.h>
#include<conio.h>
void add();
void main()
C- Programming Dr. Laxmikant Goud Page 30
{
add(); // function calling , calling function
getch();
}
void add() // function definition , called function
{
int a=10,b=20;
int sum=a+b;
printf(“%d”,sum);
}
2. Function with no argument But return value:-
When a function does not take any arguments but returns a value to the calling function.
Example:
#include<stdio.h>
#include<conio.h>
int add();
void main()
{
int result=add(); // function calling , calling function
printf(“%d”,result);
getch();
}
void add() // function definition , called function
{
int a=10,b=20;
int sum=a+b;
return(sum);
}
C- Programming Dr. Laxmikant Goud Page 31
3. Function with argument but not return value:-
Here the function accept the argument but does not return any value back to the calling
program. It is one way communication i.e. calling program to function. In such function the
result may be displayed from the function itself.
#include<stdio.h>
#include<conio.h>
void add(int,int);
void main()
{
int a=10,b=20;
void add(a,b); //Calling Function
getch();
}
void add(int c,int d) //called function
{
int sum=c+d;
printf(“%d”,sum);
}
4. Function with argument with return value:-
Here the function accepts the argument and also return value to calling program.
It is two way communications i.e. calling program to function.
#include<stdio.h>
#include<conio.h>
int add(int,int);
void main()
{
int a=10,b=20,result;
result=add(a,b); //Calling Function
printf(“%d”,result);
C- Programming Dr. Laxmikant Goud Page 32
getch();
}
int add(int c,int d) //called function
{
int sum;
sum=c+d;
return(sum);
}
7. Passing Values between Function:
There are two mechanisms to pass the arguments to a function
1. Call by value
2. Call by reference
1. Call by value:-
In “C” all function arguments are passed by value.
This method copies the values of actual parameter into the formal parameter of the function.
The changes made to the formal parameters have no effect on the actual argument in the calling
function.
void swap(int,int); // function declaration
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=20;
swap(a,b); // calling function, a and b are actual parameters
printf(“%d%d”,a,b);
getch();
}
void swap(int x, int y) // function definition, c and d are formal arguments
{
int temp;
C- Programming Dr. Laxmikant Goud Page 33
temp=x;
x=y;
y=temp;
printf(“in function=%d%d”,x,y);
}
In above program parameters a and b in function call are actual parameters, x and y parameters
in function definition are Formal Arguments.
Here x and y parameters values are swap but the actual parameters a and b values are not swap.
Hence changes made to Formal Parameters have no effect on Actual Parameters.
2. Call by reference:-
In this method of passing arguments the called function has access to the original argument not
the local copy.
C language allows this method by use of address & pointer.
This allows the function to directly access the original variables and modify their values.
#include<stdio.h>
#include<conio.h>
void swap(int*,int*); // function prototype
void main()
{
int a=10,b=20;
swap(&a,&b); //function calling
printf(“After interchanging=%d%d”,a,b);
getch();
}
void swap(int *x, int *y) // function definition
{
int temp; temp=*x;
*x=*y;
*y=temp;
printf(“in function=%d%d”,x,y);
C- Programming Dr. Laxmikant Goud Page 34
}
Here x and y parameters values are swap which also swaps the values of actual parameters a
and b. Hence changes made to Formal Parameters have effect on Actual Parameters.
8. Recursion:-
When a function called itself it is called recursion generally a function calls another function in
that case control goes to a function executes it and comes back.
When a function calls itself then control goes to same function & execute it again.
In recursion function can start with a new value every time. It is very compact & powerful.
It must be conditional otherwise it may enter into an infinite loop.
#include<stdio.h>
#include<conio.h>
int factorial(int);
void main()
{
int n,fact;
printf("enter Number:");
scanf("%d",&n);
fact=factorial(n);
printf("%d",fact);
getch();
}
int factorial(int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}
C- Programming Dr. Laxmikant Goud Page 35
Computer Programming in C [BTES104]
CHAPTER-3 Control Flow and Function
Q. no Question Marks
1 Write a program to print area of square using function. 6
2 Write a program to print factorial of a given number using while and also, 6
write the program using do….while loop.
3 Differentiate between while and do…...while loop 6
4 Explain the while and do……..while loop with writing a program in C 6
program to print the sum of first 5 natural numbers.
5 Define a Function. Enlist and explain the types of the function. Write a 6
Syntax of function definition, function call, and function prototype in C.
6 Write a program in C. Two integer numbers are given as a input to program 6
and the output of the program is addition of the two integers using function
which returning the addition of the given numbers.
7 What is function in C? Write the syntax for function prototype, function 6
definition and function call.
8 Write a C program to calculate factorial of a number using function. 6
9 Write a program in C to create simple calculator by using switch cases. 6
10 What is function? Differerrtiate between Cail byvalue arld function call by 6
reference function
11 Write a program in C to print factorial of a number 6
i) without using User Define Function
ii) User Define Function
iii) Using Recursion
12 Write a program using function that receives marks obtained by a student in 6
3 subjects and returns the average of these marks. Call this function from
main() and print the results in main().
13 Write a program to calculate overtime pay of employees. Overtime is paid 6
at the rate of Rs.12 per hour for every hour worked above 40 hours.
Assume that employee do not work for fractional part of an hour.
14 6
15 6
16 6
C- Programming Dr. Laxmikant Goud Page 36