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


Java Script Album With PHP

<html>
<head>
 <title>
Girfa :Student Help :: PHP Java Script Programming
</title>
 </head>
<body>
 <?php
echo 
"<script language='javascript'>";
echo 
"var i=0; show();";
echo 
"function show(){i++;if(i==5){i=0;}else{img1.src=i + '.jpg'";
echo 
"} setTimeout('show()',1000);}</script>";
?>
</body>
</html>

Passing 2D Array to Function

NIELIT O Level January 2016

Q 6.c :  Write a function to read a two dimensional matrix along with the number of rows and columns in it, from the user. The contents of the array and the number of rows and columns should be passed back to the calling function.

Solution : 

/*   ************************************************
           Girfa : Student Help
           Passing Two dimentional array to a function
           for more program visit : http://girfahelp.blogspot.com/p/c-language-assignment.html
     *************************************************/
#include<stdio.h>
#include<conio.h>
#define ROW 10
#define COL 10
void print(int (*)[],int,int);
void main()
{
     int ar[ROW][COL],r,c,i;
     clrscr();
     for(r=0,i=1;r<ROW;r++)
     {
           for(c=0;c<COL;c++)
           {
                ar[r][c]=i;
                i++;
           }
     }
     printf("Enter Number of row and column to read>> ");
     scanf("%d%d",&r,&c);
     print(ar,r,c);

Thursday 26 January 2017

Differentiate between if and switch case

NIELIT O Level January-2016

Q 6 B (i) :  Differentiate between  if and switch case

Solution : 
While programming, a number conditions come and a number of decisions need to be taken by a programmer. For decision making in C programming, the statements such as if, if..else, else if, switch case etc.
Though which when number of possible condition got increase in some scenario then if-else ladder implementation become complicated. So we can achieve this using switch case in simple manner with decreasing complexity.