EmbLogic's Blog

various functions made

#include
#include
#include

//int debug(const char*,const char*[10],char*);

int say(char*);
int say_num(int*);
int* sum(int*,int*);
int fact(int);
int find_addr();
int back();

int main()
{

printf(“%s -> %p”,__func__,&__func__);

char *b=”hello world”;
char c[]=”humpty dumpty sat on a wall”;
int d[]={1,2,3,4,5,6,7,8,9,0};
printf(“\n%d”,say(b));
printf(“\n%d”,say_num(d));
printf(“\n%d”,*(sum(d+1,d+2)));
printf(“\nfacrorial 5 : %d”,fact(5));
find_addr();
back();
return 0;
}

int say(char* a)
{
printf(“%s -> %p”,__func__,&__func__);

int i=0;
for(;*a;a++,i++) printf(“%c”,i%2?toupper(*a):tolower(*a));
return 0;
}

int say_num(int* a)
{
printf(“%s -> %p”,__func__,&__func__);

int i=0;
for(;*a;a++,i++) printf(“%d”,*a);
return 0;
}

int* sum(int *a,int *b)
{
printf(“%s -> %p”,__func__,&__func__);

int *total=malloc(sizeof(int));
*total=*a+*b;
return total;
}

int fact(int a)
{
printf(“%s -> %p”,__func__,&__func__);

printf(“\nfact() : a = %d”,a);
if(a==0) return 1;
else return (a*fact(a-1));
}

int find_addr()
{
printf(“\n%s():%p,%s”,__func__,&__func__,”inside the address function”);
// debug(__func__,&__func__,”loading….”);
return 0;
}

/*
int debug(const char* fn,const char*[10] addr,char* mesg)
{
printf(“%s() -> %p : %s”,*fn,addr,*mesg);
return 0;
}
*/
int back()
{
char ch;
printf(“enter a char:”);
scanf(“%c”,&ch);
if(ch!=’.’) back();
printf(“%c”,ch);
return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>