VideoBar

This content is not yet available over encrypted connections.

Friday, November 4, 2016

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 9- Making fun with looping

Code:

#include<stdio.h>
main()
{
    int n;
    printf("Enter no. of row n:");// standard n=10
    scanf("%d",&n);
/*1st part*/
 for(int i=0;i<n;i++)
    {
                for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("-");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf(".");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("-");
        }
         for(int j=n;j>=n-i;j--)
        {
                    printf(".");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
    printf("\n");
     }


/*2nd part*/
 for(int i=0;i<n;i++)
    {
               for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }
                for(int j=1;j<=n-i;j++)
        {
                    printf(".");
        }

                        for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf(".");
        }

                     for(int j=n;j>=n-i;j--)
        {
                    printf("-");
        }
                            for(int j=1;j<=n-i;j++)
        {
                    printf(".");
        }
                    for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }

         for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }

    printf("\n");
     }

/*1st part*/
 for(int i=0;i<n;i++)
    {
                for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("-");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf(".");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(".");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("-");
        }
         for(int j=n;j>=n-i;j--)
        {
                    printf(".");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
    printf("\n");
     }


/*2nd part*/
 for(int i=0;i<n;i++)
    {
               for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }
                for(int j=1;j<=n-i;j++)
        {
                    printf(".");
        }

                        for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }

                     for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }
                            for(int j=1;j<=n-i;j++)
        {
                    printf(".");
        }
                    for(int j=1;j<=n-i;j++)
        {
                    printf("-");
        }

         for(int j=n;j>=n-i;j--)
        {
                    printf(" ");
        }

    printf("\n");
     }
}

Output:
Output of making fun with looping





Wednesday, October 5, 2016

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 8- Data casting


#include<stdio.h>
main()
{
int i;
float f;
printf("Enter i such that i  integer:\n" );
scanf("%d",&i);
printf("Enter f such that f  floating point:\n");
scanf("%f",&f);
printf("The sum of %d and %f is = %f \n \n",i,f,(float)(i+f) );
}
Output




প্রোগ্রামিং-এর গল্প (A tale of Programming) : Numerical Method- Coding for Newton Raphson Method

//Program for Newton-Raphson Method
#include<stdio.h>
#include<math.h>
float f(float x)
{
    return x*x-4*x-10;
}
float fdx(float x)
{
    return 2*x-4;
}
main()
{
float x1,x2,f1,f2,e,error,root;
int i=0;
printf("Enter the initial value x1:");
scanf("%f",&x1);
printf("Enter the error limit e:");
scanf("%f",&e);
while(1)
{
i++;//i=i+1;
f1=f(x1);
f2=fdx(x1);
x2=x1-(f1/f2);
error=fabs((x2-x1)/x2);
if(error<e)
{
    root=x2;
    printf("\n\n\n\nNo. of iteration:%d",i-1);
    printf("\n\nFinal functional value:%f",f1);
    printf("\n\nFinal root:%f",root);
    break;
}
else
{
    x1=x2;
    printf("\n\nIteration=%d  x1=%.2f  x2=%.2f  f1=%.2f  f2=%.2f  error=%.2f",i,x1,x2,f1,f2,error);
}

}

}
Output for Newton Raphson Method

প্রোগ্রামিং-এর গল্প (A tale of Programming) : Numerical Method- Coding for False Position Method

//program for false position
#include<stdio.h>
#include<math.h>
float f(float x)
{
    return x*x-4*x-10;
}
main()
{
    float xl,xu,x0,fxl,fxu,fx0,e,error,root;
    int i=0;
    printf("Enter lower limit xl:");
    scanf("%f",&xl);
    printf("Enter upper limit xu:");
    scanf("%f",&xu);
    printf("Enter limit of error:");
    scanf("%f",&e);
    fxl=f(xl);
    fxu=f(xu);
    if(fxl*fxu>0)
    {
        printf("\nSorry, the limits doesn't bracket any root:");
        main();
    }
    else//    if(fxl*fxu<0)
    {
        printf("\n\n\nIteration  xl\txu\tx0\tfxl\tfxu\tfx0\terror");
        while(1)
        {
           i++;
           x0=xl-((fxl*(xl-xu))/(fxl-fxu));
           fxl=f(xl);
           fxu=f(xu);
           fx0=f(x0);
           if(fx0*fxl<0)
           {
               xu=x0;
           }
           else//           if(fx0*fxu<0)
           {
               xl=x0;
           }
           error=fabs((xl-xu)/xl);
           printf("\n%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f",i,xl,xu,x0,fxl,fxu,fx0,error);
           if(error<=e)
           {
               x0=xl-((fxl*(xl-xu))/(fxl-fxu));
               root=x0;
               printf("\n\n\n\nThe desired root is= %f\n\n",root);
               break;
           }
        }
    }
}

Output for False Position Method

প্রোগ্রামিং-এর গল্প (A tale of Programming) : Numerical Method- Coding for Bisection Method

#include <stdio.h>
#include <math.h>
float fnct(float x)
{
return (x*x - 4*x -10);}
int main()
{
int i=0;
float xl, xu, x0, e = 0.0001;
float fxl,fxu,fx0,error,root;
printf("\nEnter values for xl and xu:\n");
scanf("%f %f", &xl, &xu);
fxl= fnct(xl);  fxu= fnct(xu);
if(fxl*fxu>0)
{ printf("Not in range\n");}
else
{   printf("Iter \t xl \t xu \t x0 \t fxo \t\t error \n\n ");
   while(1)
   {
        i++;
     x0 =(xl + xu)/2; fx0 = fnct(x0);
        if ( fxu* fx0 <= 0)
            xl = x0;
        else
            xu = x0;    error=fabs((xu - xl)/xl) ;
           printf("%d\t%.2f\t%.2f\t%.2f\t%f.2\t%.2f\n ",i,xl,xu,x0,fx0,error);
           if (fabs((xu - xl)/xl) < e)
         {  root = (xu+xl)/2;
            printf("Root= %6.4f\n", root);
            break;
         }
    }

}
return  0;
}


Output for Bisection Method



প্রোগ্রামিং-এর গল্প (A tale of Programming) : Numerical Method- Coding for Bisection Method

#include <stdio.h>
#include <math.h>
float fnct(float x)
{
return (x*x - 4*x -10);}
int main()
{
int i=0;
float xl, xu, x0, e = 0.0001;
float fxl,fxu,fx0,error,root;
printf("\nEnter values for xl and xu:\n");
scanf("%f %f", &xl, &xu);
fxl= fnct(xl);  fxu= fnct(xu);
if(fxl*fxu>0)
{ printf("Not in range\n");}
else
{   printf("Iter \t xl \t xu \t x0 \t fxo \t\t error \n\n ");
   while(1)
   {
        i++;
     x0 =(xl + xu)/2; fx0 = fnct(x0);
        if ( fxu* fx0 <= 0)
            xl = x0;
        else
            xu = x0;    error=fabs((xu - xl)/xl) ;
           printf("%d\t%.2f\t%.2f\t%.2f\t%f.2\t%.2f\n ",i,xl,xu,x0,fx0,error);
           if (fabs((xu - xl)/xl) < e)
         {  root = (xu+xl)/2;
            printf("Root= %6.4f\n", root);
            break;
         }
    }

}
return  0;
}


Output for Bisection Method



গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 7- Calculate year, months and days

#include<stdio.h>
main()
{
    int years,month,days;
    printf("Enter days so that greater than 365 days:");
    scanf("%d",&days);
    years=days/365;
    printf("%d years %d months %d days \n\n\n\n ",(days/365),((days%365)/30),((days%365)%30));
}
Output



গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 7- Calculate year, months and days

#include<stdio.h>
main()
{
    int years,month,days;
    printf("Enter days so that greater than 365 days:");
    scanf("%d",&days);
    years=days/365;
    printf("%d years %d months %d days \n\n\n\n ",(days/365),((days%365)/30),((days%365)%30));
}
Output



গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 6- Calculate months and days

#include<stdio.h>
main()
{
    int month,days;
    printf("Enter days:");
    scanf("%d",&days);
    printf("%d Months and  %d days\n\n\n",(days/30),(days%30));
}

Output

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 5- Find modulous of two numbers

#include<stdio.h>
main()
{
int a,b,sum;
printf("Enter a such that a>b:\n" );//10
scanf("%d",&a);
printf("Enter b such that b<a:\n");//3
scanf("%d",&b);
printf("The mod of %d and %d is = %d \n \n",a,b,(a%b) );//1
}

Output

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 4- Add two numbers and take inputs from keyboard


#include<stdio.h>
main()
{
int a,b,sum;
printf("Enter a:" );
scanf("%d",&a);
printf("Enter b:");
scanf("%d",&b);
printf("The sum of %d and %d is = %d \n \n ",a,b,(a+b) );
}
Output

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 2- Print two sentences in two new lines


#include<stdio.h>
int main()
{
printf("Hey! I am Mubin.\nI am a good boy.\n");

return 0;
}

Output

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 3- Add two numbers

#include<stdio.h>
main()
{
int a,b,sum;
a=2;
b=3;
sum=a+b;
printf("The sum of %d and %d is = %d  \n\n\n",a,b,sum);
}
Output

গল্পটা প্রোগ্রামিং-এর (A tale of Programming): Tutorial 1- Print your name

#include<stdio.h>int main()
{
printf("Hey! I am Mubin");//press F9
return 0;
}
Output

Saturday, September 17, 2016

From Little Manhatten- best Quotes

***

Love is an ugly, terrible business.. practiced by fools. It'll trample your heart and leave you bleeding on the floor. And what does it really get you in the end? Nothing but a few incredible memoriesthat you can't ever shake.
***

The sun came out again. See, life is about so much more than Rosemary. I have my family, my health,
my kicking career. I really had no room for a woman in my life.
***

There are very few things more painful than watching the woman you love grapple with another man.
 

 

code: Design Heart using C programming



#include<stdio.h>
main()
{
    int n;
    printf("Enter no. of row n:");// standard n=10
    scanf("%d",&n);
/*1st part*/
 for(int i=0;i<n;i++)
    {
                for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                         for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }

                 for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
         for(int j=n;j>=n-i;j--)
        {
                    printf("*");
        }
                        for(int j=1;j<=n-i;j++)
        {
                    printf(" ");
        }
    printf("\n");
     }


/*2nd part*/
    for(int i=0;i<(2*n);i++)
    {
                 for(int j=(2*n);j>=(2*n)-i;j--)
        {
                    printf(" ");
        }
       for(int j=1;j<=(2*n)-i;j++)
        {
                    printf(" *");
        }

        printf("\n");
    }

}

output: