Uncategorized

algorithm and data structure (friday 14pm) – subject: struct, and pointer


look and compile  this code below:

#include <stdio.h>
struct x {
	int a;
	int b;
	int c;
} ;

void showMember(struct x * pz){
	printf(" first member %d \n", (*pz).a);
}

main(){
	struct x z, *pz;
	pz = &z;
	z.a = 10;
	z.a++;
	showMember(pz);
}

From this code, please modify and make a simple program to show “prime number”.

  • Use a struct. Example:
              struct prime { int topLimit; };
  • Main function just to input topLimit (batas atas) of prime number and call function to show the prime number
  • showPrime is a function to show prime number before the topLimit. This function has a parameter. The type of parameter is sturct (topLimit)

example:

      void showPrime(struct prime *x){ ....................... }

for more know, look at this screen shot:

Send your project hard copy next meeting!

happy source code!

best regards,

-y2-

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s