Quantcast
Channel: w3mentor » Pointers
Browsing latest articles
Browse All 7 View Live

Function that returns the average of all the array elements except for the...

/* (Version 1) The array version of the function */   float average(int m[]){ int total=0,i; float avg; for(i=0;m[i];i++) total+=m[i]; avg=(float)(total)/i; return avg; } /* (Version 2) The pointer...

View Article


Print each element of the array together with their memory addresses

#include <stdio.h> const int MAX = 6; const int LEN = 10;   int main() { int i,j;   /*Define and Initialize the 2-D array*/ char language[MAX][LEN]={ "FORTRAN", "BASIC", "COBOL", "Pascal", "C",...

View Article


Use pointers to display the strings pointed by the array elements of an array...

/*Program using pointers to display the strings pointed by the array el- ements of an array of pointers*/   #include <stdio.h>   int main() { /*Define and Initialize the 2-D array*/ char...

View Article

Display the first characters of the strings pointed by the array elements of...

  #include <stdio.h>   int main() {   /*Define and Initialize the 2-D array*/ char *direction[]={ "North", "East", "West", "South", };   int i; const int SIZE = (int)...

View Article

A program using pointers to functions in C

#include <stdio.h>   int main() { int x,y,operation; double result, operate(double (*)(),int,int); double add(), subtract(), multiply(), divide();   printf("Enter two integers : "); scanf("%d...

View Article


Program that prints the first characters of all the arguments except for the...

#include <stdio.h>   void flush_array(int,char *[]); void flush_1st_char(int,char *[]);   int main(int argc,char *argv[]) { flush_array(argc,argv); printf("n=======> ");...

View Article

Check the validity of a date supplied from the command line in C

#include <stdio.h>   void convert(char **,int*,int*,int*); int valid(int,int,int);   int main(int argc,char *argv[]) { int d,m,y char *progname=argv[0];   if(--argc>0) {...

View Article
Browsing latest articles
Browse All 7 View Live