Total Pageviews

Saturday 21 November 2015

JAVA Practices of Ganpat University [solved programs]

Hello all,
                  This is batch of  2014 and We are uploading the solutions of Ganpat University Practicals.This will help you in Developing your JAVA skills . I will also add some important links so that you can download java and Setup on your Windows | Mac | Linux PC   ....

JAVA Practicals   or  Link 2(Dropbox)





Download JAVA-->

NetBeans IDE FOR JAVA


Java Works on cross platform means if you create a file on Mac OS and running on Windows OS .It will Definitely run ,But you need the File reader(class file reader) This JAVA Development kit Helps you to convert binary (class file ) into JAVA file .It also compile and run the file you have created .In C you have seen functions here You will see Class .Java is very secure.



Java has better opportunity for good programmers .So Learn well..

Good Wishes From All Tricks & Team .

Tuesday 15 September 2015

C Programming Arrays and Functions [1.0.16]


In C programming, a single array element or an entire array can be passed to a function. Also, both one-dimensional and multi-dimensional array can be passed to function as argument.

Passing One-dimensional Array In Function

C program to pass a single element of an array to function

#include <stdio.h>
void display(int a)
   {
   printf("%d",a);
   }
int main(){
   int c[]={2,3,4};
   display(c[2]);  //Passing array element c[2] only.
   return 0;
}
Output
4
Single element of an array can be passed in similar manner as passing variable to a function.

Passing entire one-dimensional array to a function

While passing arrays to the argument, the name of the array is passed as an argument(,i.e, starting address of memory area is passed as argument).
Write a C program to pass an array containing age of person to a function. This function should find average age and display the average age in main function.

#include <stdio.h>
float average(float a[]);
int main(){
     float avg, c[]={23.4, 55, 22.6, 3, 40.5, 18};
     avg=average(c);   /* Only name of array is passed as argument. */
     printf("Average age=%.2f",avg);
     return 0;
   }
float average(float a[]){ 
     int i;
     float avg, sum=0.0;
     for(i=0;i<6;++i){
       sum+=a[i];
     }
     avg =(sum/6);
     return avg;
}
Output
Average age=27.08

Passing Multi-dimensional Arrays to Function

To pass two-dimensional array to a function as an argument, starting address of memory area reserved is passed as in one dimensional array

Example to pass two-dimensional arrays to function


#include 
void Function(int c[2][2]);
int main(){
   int c[2][2],i,j;
   printf("Enter 4 numbers:\n");
   for(i=0;i<2;++i)
      for(j=0;j<2;++j){
           scanf("%d",&c[i][j]);
      }
   Function(c);   /* passing multi-dimensional array to function */
   return 0;
}
void Function(int c[2][2]){
/* Instead to above line, void Function(int c[][2]){ is also valid */
   int i,j;
   printf("Displaying:\n");
   for(i=0;i<2;++i)
      for(j=0;j<2;++j)
          printf("%d\n",c[i][j]);
}
Output

Enter 4 numbers:
2 3 4 5 Displaying: 2 3 4 5


Next C Post