ASP ScriptingJava ScriptingCGI ScriptingHTMLJavaLanguage CERP Education Links

LANGUAGE C

Passing Structures as Arguments

     This is an important facility used to pass groups of logically related data items together instead of passing them one by one. Remember one thing when using a structure as an argument, that the type of argument matches the type of parameter. 

#include <stdio.h>
main ( )
{
struct 
{
char name[20]; 
int numb;
float amt;
}xyz;
clrscr ( ) ;
printf("\nEnter Customer name . ");
gets(xyz.name);
printf("\nEnter Customer number . ");
scanf("%d", &xyz.numb); 
printf("\nEnter Principle Amount . ");
scanf("%f", &xyz.amt);
intcal(xyz);
intcal( struct {
char name[20];
int numb;
float amt;
} abc )
float si, rate = 5.5, yrs = 2.5;
si = (abc.amt * rate * yrs)/100;
printf ("\nThe customer name is %s" ,abc.name);
printf ("\nThe customer number is %d" ,abc.numb);
printf ("\nThe amount is %f" . ,abc.amt);
printf ("\nThe interest is %f", si)
return;
}

 


Your Ad Here
Not All Of Your Subscribers Use RSS - AWeber Email Marketing
Your Ad Here