Monday, 30 January 2017

Factorial number with recursion

NIELIT O Level Paper
C Language
 January 2016 Solved

Q8 a) Write a program having a recursive function to calculate the factorial of a number. In the main() function, read the value of the number and then using the recursive function display the result.

Solution :

/*   ################################
     Girfa Student Help
     Factorial recursion  program
     for more visit : http://girfahelp.blogspot.in/p/c-language.html
     ################################

Traffic Light Programe

NIELIT O Level January 2016 Solved

Q 7 : c) Write a program that displays the recommended actions depending on the color of a traffic light using the switch statement.

Solution : 

/* *******************************************
     Girfa : Student Help
     Traffic Light Program
     for more program visit : http://girfahelp.blogspot.in/p/c-language.html
     ********************************************/

Saturday, 28 January 2017

Difference between while and do while

NIELIT O Level January 2016 Solve paper

Q 7 b.(ii) while and do..while loops

Iteration statements allow the set of instructions to execute repeatedly till the condition doesn’t turn out false. The Iteration statements in C for while loop and do while loop. These statements are commonly called loops. Here, the main difference between a while loop and do while loop is that while loop check condition before iteration of the loop, whereas do-while loop, checks the condition after the execution of the statements inside the loop.

BASIS FOR COMPARISON
WHILE
DO-WHILE
Syntax
while ( condition) {
statements; //body of loop
}
do{
.
statements; // body of loop.
.
} while( Condition );
Controlling Condition
In 'while' loop the controlling condition appears at the start of the loop.
In 'do-while' loop the controlling condition appears at the end of the loop.
Iterations
The iterations do not occur if, the condition at the first iteration, appears false.
The iteration occurs at least once even if the condition is false at the first iteration.

Friday, 27 January 2017

Passing array to function call by reference

NIELIT O Level January-16 

Q 7 (a) . How does passing an array as an argument to a function differ from call by value?

Solution : 


An array is a collection of similar data type which occupies continuous location on memory. Name of array is constant pointer which point (store address of first element of array) first element. When we passed an array to a function as an argument then we pass address of first element and if any change made inside of function to passing array then its effect original location because it is call by reference.
So when an array is passed to a function as an argument then it’s always being pass by reference.

Passing Array to function  C Language