Showing posts with label C প্রোগ্রামিং চার অধ্যায় -Library Function. Show all posts
Showing posts with label C প্রোগ্রামিং চার অধ্যায় -Library Function. Show all posts

Wednesday, February 4, 2015

Ctype header file function

 

1               toupper ()

 

#include<stdio.h>
#include<ctype.h>
int main()
{
    char ch;
    char  a;
    ch=getchar();
 
    a=toupper(ch);
 
    printf("%c",a);
    return 0;
}

 


2      tolower ()      


#include<stdio.h>
#include<ctype.h>
int main()
{
    char ch;
    ch=getchar();
    char  a;
    a=tolower(ch);
    printf("%c",a);
    return 0;
}


 


3    toascii ()    


#include<stdio.h>
#include<ctype.h>
int main()
{
    char ch;
    ch=getchar();
    int a;
    a=toascii(ch);
    printf("%d",a);
    return 0;
}

Math.h header file

 

#include<stdio.h>
#include<math.h>
int main()
{
    double a=sin(1.5);
    printf("%lf\n",sin(1.5));
    printf("%lf\n",cos(1.5));
    printf("%lf\n",tan(1.5));
    //..................
printf("%lf\n",exp(1));
printf("%lf\n",log(1));
printf("%lf\n",log10(100));
printf("%lf\n",pow(4,2));
printf("%lf\n",sqrt(4));
printf("%lf\n",fmod(4.1,5));
//.................
printf("%lf\n",fabs(-4));
printf("%ld\n",labs(-42));
printf("%lf\n",floor(4.6));
printf("%lf\n",ceil(4.2));
 
    return 0;
}

Friday, November 21, 2014

factorial using recursive function

factorial recursive function


 



#include<stdio.h>
long long int fac(long long a)
{
 if(a==0)
 {
 return 1;
 }
 return a*fac(a-1);
}
 
int main()
{
  long long int a;
  while(scanf("%lld",&a)!=EOF)
{
    long long int n=fac(a);
    printf("factorial = %lld\n",n);
}
  return 0;
 
}

Monday, November 17, 2014

power(using math.h function)

 
power(using math.h function)

 
#include<stdio.h>
#include<math.h>
int main()
{
double base,exp;
printf("Enter base number: ");
scanf("%lf",&base);
printf("Enter power number: ");
scanf("%lf",&exp);
if(base==0&&exp==0)
{
printf("Math Error\n");
}
else
{
double power=pow(base,exp);
printf("%.3lf^%.3lf = %lf\n", base,exp,power);
}

return 0;
}

Wednesday, December 11, 2013

C প্রোগ্রামিং চার অধ্যায় -Library Function - PART :1

Library Function: Library function হল সি ল্যাঙ্গুয়েজ এ দেয়া default function’s. সকল ফাংশন এর corresponding header file আছে। যেমন আমরা যখন  printf(), scanf() function ব্যবহার করেছি, তখন আমাদের “stdio.h” header file declare করতে হয়েছে। যেকোন default function প্রোগ্রাম এ ব্যবহার করা হলে তার header file অবশ্যই প্রথমে declare করা লাগবে।



কিছু গুরুত্বপূর্ন লাইব্রেরী ফাংশন।

Function nameHeader fileWork
scanf(…)stdio.hInput নেয়া
printf(…)stdio.hOutput দেয়া
abs(i)stdlib.hReturn the absolute value of i
acos(d)math.hReturn cos-1(d) (মান radian এ return করে, not degree)
asin(d)math.hReturn sin-1(d)
atan(d)math.hReturn tan-1(d)
Sin(i)math.hReturn sin(d) (d এর মান radian এ, degree এর জন্য function টা use করলে degree কে radian এ convert করতে হবে)
cos(i)math.hReturn cos(d)
tan(i)math.hReturn tan(d)
floor(d)math.hReturn only the integer part of a fractional number.
ceil(d)math.hReturn the integer_part+1 of a fractional number
getchar()stdio.hTake a single character input
isalnum(c)ctype.hReturn true if character c is either A-Z,a-z,0-9
isalpha(c)ctype.hReturn true if character c is either A-Z,a-z
isdigit(c)ctype.hReturn true if character c is either 0-9
isupper(c)ctype.hReturn true if character c is either A-Z
islower(c)ctype.hReturn true if character c is either a-z
log(c)math.hReturn ln(c)
log10(c)math.hReturn log(c)
pow(base,p)math.hReturn basep
sqrt(d)math.hReturn d (square root of d)
toupper(c)ctype.h or
stdlib.h
Return capital letter of a letter.
tolower(c)ctype.h or
stdlib.h
Return small letter of a letter.
strlen(name)string.hReturn the length of a character array
strcpy(name1,name2)string.hCopy name2 to name1
strcmp(name1,name2)string.hReturn true if name1 and name2 are exactly same
gets(name)stdio.hTake charater array or string as input


C Programming এ আরও অনেক গুলো Library Function রয়েছে। এগুলো সাধারনত সবচেয়ে বেশি ব্যবহৃত Function. নিচে আরও কিছু সবচেয়ে বেশী ব্যবহৃত Library Function এর চার্ট দেওয়া হলো।