Welcome to Onlinetunes24 .....

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 1 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 2 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 3 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

This is default featured post 4 title

We are committed to become your long-term, trusted partner. Our priority is not only to provide professional services and solutions but to become your IT vendor dedicated to meet your needs today and support your growing business needs tomorrow.

Showing posts with label প্রোগ্রামিং-ইন-সি (Programming-in-C). Show all posts
Showing posts with label প্রোগ্রামিং-ইন-সি (Programming-in-C). Show all posts

Matrix multiplication in c language

Matrix multiplication in c language: c program to multiply matrices (two dimensional array), this program multiplies two matrices which will be entered by the user. Firstly user will enter the order of a matrix. If the entered orders of two matrix is such that they can't be multiplied then an error message is displayed on the screen. You have already studied the logic to multiply them in Mathematics. 

Program:
#include <stdio.h>
int main()
{

  int m, n, p, q, i, j, k, sum = 0;
  int first[10][10], second[10][10], multiply[10][10]; // There are three array

  printf("Enter the number of rows and columns of first matrix\n");
  scanf("%d%d", &m, &n);
  printf("Enter the elements of first matrix\n");

  // take input for first matrix
  for (i = 0; i < m; i++)
  {
    for (j = 0; j < n; j++)
    {
        scanf("%d", &first[i][j]);
    }
  }

  printf("Enter the number of rows and columns of second matrix\n");
  scanf("%d%d", &p, &q);

  if (n != p)
    printf("Matrices with entered orders can't be multiplied with each other.\n");
  else
  {
    printf("Enter the elements of second matrix\n");

    // take input for second matrix
    for (i = 0; i < p; i++)
    {
        for (j = 0; j < q; j++)
        {
            scanf("%d", &second[i][j]);
        }
    }

    // calculation
    for (i = 0; i < m; i++)
    {
      for (j = 0; j < q; j++)
      {
        for (k = 0; k < p; k++)
        {
          sum = sum + first[i][k] * second[k][j];
        }

        multiply[i][j] = sum;
        sum = 0;
      }
    }

    printf("Product of entered matrices:-\n");

    for (i = 0; i < m; i++)
    {
      for (j = 0; j < q; j++)
      {
         printf("%d\t", multiply[i][j]);
      }
      printf("\n");
    }
  }

  return 0;
}

Moving two circle above a line by Programming in C.

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>

void main ()
{
int gd=DETECT, gm=DETECT, i,j,x,x2,y;
initgraph(&gd, &gm, "c:\\TurboC3\\bgi");
setcolor(RED);
delay (100);
line(100,161,600,161);

x=100;
y=150;
x2=600;
 

for(i=0, j=0; i<245,j<245; i+=5,j+=5)
{
circle(x+i, y, 10);
circle(x2-j, y, 10);
delay(100);
setcolor(BLACK);
circle(x+i, y, 10);
circle(x2-j, y, 10);
setcolor(RED);
}
 

rectangle(300,125,350,150);
rectangle(360,125,410,150);

getch();
}

National Flag of Bangladesh by programmign in C

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int driver = DETECT, mode=0;
initgraph (&driver, &mode, "..\\bgi");
delay(1000);
printf ("\n\n\n\t\t\t National Flag of Bangladesh");
printf("\n\t\t\t Programmed by Mohammad Lukman Hussain");
delay(1000);

setcolor(2); /* Flag's Rectangle */
//rectangle(200, 150, 450, 300);
rectangle(200,150,400,250);
setfillstyle(1,2);
floodfill(325,225,2);
delay(1000);

setcolor(4); /* Flag's Circle */
//circle(325,225,50);
circle(300,200,30);
setfillstyle(1,4);
floodfill(300,200,4);
delay(1000);

setcolor(3); /* Flag's Stand */
rectangle(190,150,200,400);
setfillstyle(1,5);
floodfill(190,350,3);
delay(1000);

setcolor(3); /* Ground Stand */
rectangle(180,400,210,410);
rectangle(170,410,220,420);
rectangle(160,420,230,430);
delay(1000);

getch();
}

Moving Wheel using Mid-Point Circle algorithm and DDA Line algorithm

#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<dos.h>

int l = 1;

void ddaline(int x1, int y1, int x2, int y2)
{

    int s, dx, dy, m;
    float xi, yi, x, y;

    dx = x2 - x1;
    dy = y2 - y1;

    if (abs(dx) > abs(dy))
    s = abs(dx);
    else
    s = abs(dy);

    xi = dx / (float) s;
    yi = dy / (float) s;

    x = x1;
    y = y1;

    putpixel(x1 + 0.5, y1 + 0.5, 15);

    for (m = 0; m < s; m++) {
    x += xi;
    y += yi;
    putpixel(x + 0.5, y + 0.5, 15);
    }
}


void plotpoints1(int x, int y, int cx, int cy)
{
    putpixel(cx + x, cy + y, 15);
    putpixel(cx - x, cy - y, 15);
    putpixel(cx - y, cy + x, 15);
    putpixel(cx + y, cy - x, 15);
    if (l % 20 == 0) {
    ddaline(cx - x, cy - y, cx + x, cy + y);
    ddaline(cx - y, cy + x, cx + y, cy - x);
    }
    l++;
}

void plotpoints2(int x, int y, int cx, int cy)
{

    putpixel(cx - x, cy + y, 15);
    putpixel(cx + x, cy - y, 15);
    putpixel(cx + y, cy + x, 15);
    putpixel(cx - y, cy - x, 15);
    if (l % 20 == 0) {
    ddaline(cx + x, cy - y, cx - x, cy + y);
    ddaline(cx - y, cy - x, cx + y, cy + x);
    }
    l++;
}


void mcircle(int cx, int cy, int r)
{
    int x = 0, y, p;

    y = r;
    p = 1 - r;


    while (x < y) {
    plotpoints1(x, y, cx, cy);
    x++;
    if (p < 0)
        p += 2 * x + 1;
    else {
        y--;
        p += 2 * (x - y) + 1;
    }
    }



    x = y + 1;
    while (abs(x) > 0) {
    plotpoints2(x, y, cx, cy);
    x--;
    if (p >= 0)
        p = p - 2 * x - 1;
    else {
        y++;
        p = p - 2 * (x - y) - 1;
    }
    }
}

void main()
{
    int gd = DETECT, gm = DETECT;
    int i = 0;
    initgraph(&gd, &gm, "..\\bgi");

    while (!kbhit()) {
    if (i > 640)
        i = -200;
    cleardevice();
    mcircle(100 + (i++), 200, 100);
    delay(90);
    i++;
    }
    getch();
}

Animation circel Using Programmign C

Program 1:
 
#include<stdio.h>
#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
void main()
{int p,q,r;
int x,y;
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, "..\\bgi");

x=getmaxx()/2;
y=getmaxy()/2;
for(q=1;q<15;q++)
{
setcolor(q);
for(p=400;p>1;p--)
{
circle(x,y,p);
}
setcolor(q+2);
for(r=1;r<400;r++)
{
circle(x,y,r);
}
}
getch();
}



Program 2:

#include<graphics.h>
#include<stdio.h>
#include<dos.h>
#include<conio.h>

main()
{
int gd=DETECT,gm,col=0;
initgraph(&gd,&gm,"..\\bgi");
while(!kbhit())
{
setcolor(15);
circle(col,100,50);
delay(50);

col++;
if(col>=600)
col=0;
cleardevice();
}
}


Program 3:

#include<conio.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>

void main()
{
    int gd=DETECT,gm;
    initgraph(&gd,&gm,"..\\bgi");
    int x=100,y=100,r=20;
    float c=.1;
    for(float i=0;i<100;i=i+.1)
    {
        delay(50);
        cleardevice();
        line(x+i,y,x+i+r*cos(i),y+r*sin(i));
        line(x+i,y,x+i+r*cos(90+i),y+r*sin(90+i));
        line(x+i,y,x+i+r*cos(135+i),y+r*sin(135+i));
        line(x+i,y,x+i+r*cos(180+i),y+r*sin(180+i));
        line(x+i,y,x+i+r*cos(225+i),y+r*sin(225+i));
        line(x+i,y,x+i+r*cos(315+i),y+r*sin(315+i));
        circle(x+i,y,r);
        if(kbhit())
        {
            if(getch())
            {
                printf("break");
                if(getch()){}
             }

        }

    }
       //    getch();
}

Circle using Programmign C

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>

void main ()
{
 int gd=DETECT, gm=DETECT, i, x=100, y=150;
 initgraph(&gd, &gm, "..\\bgi");
 setcolor(RED);

 while(1)
 {
x=100;
y=150;

 for(i=0; i<250; i+=5)
 {
 circle(x+i, y+i, 10);
 delay(100);
 setcolor(BLACK);
 circle(x+i, y+i, 10);
 setcolor(RED);
 }
 x=350;
 y=400;
 for(i=0; i<250; i+=5)
 {
 circle(x+i, y-i, 10);
 delay(100);
 setcolor(BLACK);
 circle(x+i, y-i, 10);
 setcolor(RED);
 }

 x=600;
 y=150;
 for(i=0; i<500; i+=5)
 {
 circle(x-i, y, 10);
 delay(100);
 setcolor(BLACK);
 circle(x-i, y, 10);
 setcolor(RED);
 }

  }

getch();
}

Smile face in Programming C

#include<graphics.h>
#include<dos.h>
#include<conio.h>
#include<stdlib.h>

void main()
{
   int gd = DETECT, gm, area, temp1, temp2, left = 25, top = 75;
   void *p;

   initgraph(&gd,&gm,"..\\bgi");

   setcolor(YELLOW);
   circle(50,100,25);
   setfillstyle(SOLID_FILL,YELLOW);
   floodfill(50,100,YELLOW);

   setcolor(RED);
   setfillstyle(SOLID_FILL,RED);
   fillellipse(44,85,2,6);
   fillellipse(56,85,2,6);

   ellipse(50,100,205,335,20,9);
   ellipse(50,100,205,335,20,10);
   ellipse(50,100,205,335,20,11);

   area = imagesize(left, top, left + 50, top + 50);
   p = malloc(area);

   setcolor(WHITE);
   settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
   outtextxy(155,451,"Smiling Face Animation");

   setcolor(BLUE);
   rectangle(0,0,639,449);

   while(!kbhit())
   {
      temp1 = 1 + random ( 588 );
      temp2 = 1 + random ( 380 );

      getimage(left, top, left + 50, top + 50, p);
      putimage(left, top, p, XOR_PUT);
      putimage(temp1 , temp2, p, XOR_PUT);
      delay(200);
      left = temp1;
      top = temp2;
      delay(200);
   }

   getch();
   closegraph();
}

Program to display circles within circle

#include<graphics.h>
#include<conio.h>
#include<stdio.h>

void main()
{
   int gd = DETECT, gm, x, y, color, angle = 0;
   struct arccoordstype a, b;

   initgraph(&gd, &gm, "..\\bgi");
   //delay(2000);

   while(angle<=360)

   {
   setcolor(BLACK);
      arc(getmaxx()/2,getmaxy()/2,angle,angle+2,50);
      setcolor(BLUE);
      getarccoords(&a);
      circle(a.xstart,a.ystart,25);
      setcolor(BLACK);
      arc(getmaxx()/2,getmaxy()/2,angle,angle+2,100);
      setcolor(RED);
      getarccoords(&a);
      circle(a.xstart,a.ystart,25);
      setcolor(BLACK);
      arc(getmaxx()/2,getmaxy()/2,angle,angle+2,150);
      getarccoords(&a);
      setcolor(GREEN);
      circle(a.xstart,a.ystart,25);
      angle = angle+5;
     // delay(50);
   }

   getch();
   closegraph();
   }

C graphics program to display Indian National Flag.

#include <stdio.h>
#include <graphics.h>
#include <stdlib.h>
#include<conio.h>

void main()
{
int gd=DETECT,gm,i,j=0;
clrscr();
initgraph(&gd,&gm,"c:\\TurboC3\\bgi");
//delay(100);
setcolor(6);
rectangle(225,125,355,155);
while(j<=30)
{
for (i=0;i<125;i++)
outtextxy(225+i,125+j,"Û");
j++;
}
//delay(300);
setcolor(7);
rectangle(225,155,355,185);
j=0;
while(j<=30)
{
for (i=0;i<125;i++)
outtextxy(225+i,155+j,"Û");
j++;
}
//delay(300);
setcolor(2);
rectangle(225,185,355,215);
j=0;
while(j<=30)
{
for (i=0;i<125;i++)
outtextxy(225+i,185+j,"Û");
j++;
}
//delay(300);
setcolor(9);
rectangle(220,120,225,440);
j=0;
while(j<=312)
{
for (i=0;i<1;i++)
outtextxy(220+i,120+j,"Û");
j++;
}
//delay(300);
rectangle(200,440,245,450);
rectangle(190,450,260,460);
rectangle(175,460,275,470);
//delay(300);
circle(291,170,13);
//delay(300);
line(291,158,291 ,183);
line(279,170,303,170);
line(282,160,300,180);
line(282,180,300,160);
//delay(300);
settextstyle(3,0,7);
setcolor(5);
outtextxy(100,5,"INDIAN FLAG");
//delay(1000);
getch();
closegraph();
}

C graphics program to display a circle.

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void main ()
{
int gd=DETECT, gm=0;
int dx, dy, p, end;
initgraph(&gd, &gm,"c:\\TurboC3\\bgi");
setcolor(RED);
dx=100;
dy=150;
p=25;
circle (dx, dy, p);
getch ();
}

সি প্রোগ্রামিং ল্যাংগুয়েজের ইতিহাস

সি ল্যাংগুয়েজের পূর্বে তথা ১৯৭২ এর পূর্বে যে সকল ল্যংগুয়েজ ডেভেলপ করা হয় ঐ সকল ল্যাংগুজের বেশির ভাগ ল্যাংগুয়েজই নিদিষ্ট কিছু বিষয়ের সমস্যা সমাধানের জন্য তৈরি করা হয়েছিল। কিন্তু সি ল্যাংগুয়েজ তৈরি করা হয় সকল কাজের ব্যবহার উপযোগি করে। যা একই সাথে ব্যবসায়িক কাজে, বৈজ্ঞানিক কাজে, ইঞ্জিনিয়ারিং কাজে ব্যবহার করা যায়। অনন্য প্রোগ্রামিং ল্যাংগুয়েজের চাইতে সি এর লাইব্রেরী ফাংসন অনেক শক্তিশালী ও সমৃদ্ধ।

সি ল্যাংগুয়েজ অনন্য ল্যংগুয়েজের মত হঠাৎ করে আবিষ্কার হয়নি, কিছু ল্যাংগুয়েজের উন্নত সংস্কারই হল সি ল্যাংগুয়েজ। ১৯৬০এর দিকে ALGOL, COBOL, Ada ইত্যাদি ল্যাংগুয়েজ গুল ডেভেলপ করা হয়। তখনকার সময়ে এই সকল ল্যংগুয়েজ গুল এক একটি এক এক কাজের জন্য ব্যবহার করা হত। ফলা ফল হিসেবে একাধিক কাজের জন্য একাধিক ল্যাংগুজের জানার প্রয়োজন হয়। যা কঠিন ও জটিল কাজ। এই সকল সমস্যা দূর করার জন্য ডেভেলপাররা চাইল এমন একটি ল্যাংগুজের তৈরি করব যা দিয়ে সব সমস্যার সমাধান করা যাবে। ফলশ্রুতিতে ডেভেলপাররা সম্মেলিত ভাবে ১৯৬০ তৈরি করেন ALGOL 60(Algorithmic Languge 60). যা খুব শক্তিশালী ছিল না। এরপর Cambridge Univercity ১৯৬৩ সালে ডেভেলপ করে CPL(Combined Programming Languge). CPL এর গঠন ছিল কঠিন ও জটিল তাই সহজেই এই ল্যাংগুয়েজ রপ্ত করা সম্বাভ ছিল না। এর পর আবারো ১৯৬৭ সালের দিকে Cambridge Univercity এর “Martin Richards” CPL কে অনুকরন করে তৈরি করেন BCPL (Basic Combined Programming Languge) . কিন্তু এই ল্যাংগুয়েজ দ্বারা মূল উদ্দেশ্য সাধন হয়নি কারন এই ল্যাংগুয়েজ দিয়ে কিছু নিদিষ্ট বিষয়ের সমাধান করা সম্ভাব হত। এর পর AT & T Bell laboratory এর Ken Thompson পূর্বের CPL এর উন্নত সংস্করন হিসেবে ১৯৭০ সালে তৈরি করেন B নামের প্রোগ্রামিং ল্যাংগুয়েজ। যাতে সমস্যা সমাধানের জন্য অনেক সমস্যা ছিল।

এই সকল ল্যাংগুয়েজের সীমাবদ্ধতা দূর করার লক্ষে ১৯৭২ সালে AT & T Bell laboratory এর “Dennis Ritchie” B ও BCPL অনুকরন করে DEC PDP-11 কম্পিউটারে ব্যবহার উপযোগী করে UNIX অপারেটিং সিষ্টেম ব্যবহার করে তৈরি করেন C ল্যাংগুয়েজ। এতে করে B প্রোগ্রামিং ল্যাংগুজের সকল সিমাবদ্ধতা দূর হয়ে যায়। সেই সময় মাইক্র কম্পিউটারের জনপ্রিয়তা বৃদ্ধির সাথে সাথে সি প্রোগ্রামিং লায়ংগুয়েজ হিসাবে বেশি ব্যবহৃত হত ও একই সাথে ব্যপক জনপ্রিয়তা পায় কারন তখনকার প্রেক্ষাপটে সি ছিল একমাত্র ল্যংগুয়েজ যা যে কম্পিউটারে ডেভেলপ করা হত ঐ কম্পিউটার ছাড়াও অন্য কম্পিউটারে চালানো যেত। সি এর জনপ্রিয়তা বৃদ্ধির কারনে ১৯৮৩ সালে ANSI (American National Standard Institute) C ল্যাংগুয়েজের একটি আদর্শ মান নির্ধারন করে। এই আদর্শ মান সম্বলিত সি ল্যাংগুয়েজই হল ANSI C. ANSI C তে পূর্বের সি এর সকল ফিচার এড করার সাথে সাথে নতুন কিছু ফিচারও যোজ করা হয়। বর্তমেন ব্যবহৃত সকল কম্পাইলার(অনুবাদক) ANSI এর মান আনুযায়ী তৈরি করা।

সি ল্যাংগুয়েজের বৈশিষ্টঃ

সি একটি মিড-লেভেল ল্যাংগুয়েজঃ

এ যাবত কালের আবিষ্কৃত সব ল্যাংগুয়েজ গুলকে যদি লেভেল হিসেবে ধরা হয় তাহলে দেখা যাবে যেঃ-
হাই লেভেল ল্যাংগুয়েজঃ যে সকল ল্যংগুয়েজ বিভিন্ন ধরনের ডাটা টাইপ নিয়ে কারে তাদেরকে হাই লেভেল ল্যংগুয়েজ বলে। যেমনঃ-
  • ADA
  • MODULA-2
  • PASCAL
  • COBOL
  • FORTRAN
  • BASIC
লো লেভেল ল্যংগুয়েজঃ যে সকল ল্যংগুয়েজ বিট-বাইট ও মেমরী এড্রেস নিয়ে কাজ করে তাদেরকে লো লেভেল ল্যাংগুজে বলে। যেমনঃ-
  • Assembly
মিড লেভেল ল্যাংগুয়েজঃ যে সকল ল্যংগুয়েজ হাই লেভেল ল্যাংগুয়েজের মত ডাটা টাইপ ও লো লেভেল ল্যংগুয়েজের মত বিট-বাইট ও মেমরি এড্রেস নিয়ে কাজ করে তাদেরকে মিড লেভেল ল্যাংগুয়েজ বলে। যেমনঃ-
  • C
  • FORTH
  • Macro-Assembler
programming_languages 
সি একই সাথে বিট-বাইট, মেমরি এড্রেস ও একই সাথে বিভিন্ন ডাটা টাইপ নিয়ে কাজ করে তাই সি একটি মিড লেভেল ল্যাংগুয়েজ। মিড লেভেল ল্যাংগুয়েজ হয়ার করনে সি এর জনপ্রিয়তা সবচেয়ে বেশি কারন এই সি ব্যবহার করেই অনেক প্রোগ্রামিং ল্যংগুয়েজ ডেভেলপ করা যায় ও ডেভেলপ হচ্ছে। তেমনই একটি ল্যাংগুয়েজ হচ্ছে জাভা।

সি একটি ষ্টানডার্ড ল্যাংগুয়েজঃ
COBOL, BASIC, Assembly ল্যাংগুয়েজ গুলতে বড় প্রেওগ্রাম গুলকে ছোট ছোট অংশে ভাগ করে যায়না যার কারনে লুপ তথা একই কাজ বার বার করতে গেলে প্রোগ্রাম এলোমেলো হয়ে যায় এবং সঠিক ফলাফল পাওয়া যায়না। COBOL, BASIC, Assembly ল্যাংগুয়েজে লুপ চালনোর জন্য সাধারনত goto এবং jump ব্যবহার করা হয় যার কারনে এসব সমস্যা হয়। কিন্তু সি তে বড় প্রোগ্রামগুলকে ছোট ছোট ভাগে ভাগ করে লিখা যায় এবং লুপ চালানোর জন্য while, do, for ব্যবহার করা হয়। যার কারনে প্রোগ্রাম এক স্থান থেকে অনত্র নেওয়ার প্রয়োজন পরেনা বরং লুপের মধ্যেই থাকে।

সি একটি জেনারেল পারপাস ল্যাংগুয়েজঃ
সি শুধু মাত্র একধনের সমস্যা সমাধান করা উদ্দেশ্য তৈরি করা হয়নি। অসংখ্য ধরনের সমস্যা সমাধানের লক্ষ্যে তৈরি করা সি ল্যাংগুয়েজ। বিট-বাইট, ডাটা টাইপ, মেমরি এড্রেস , অল্প কী-ওয়ার্ড ব্যবহার করে দ্রুত ও দক্ষতার সাথে প্রোগ্রাম পরিচালনার দক্ষতা একমাত্র সি ল্যাংগুয়েজেরই আছে। এ জন্যাই সি একটি জেনারেল পারপাস ল্যাংগুয়েজ।

সি ল্যাংগুয়েজের ব্যবহার ক্ষেত্রঃ

  1. Opareating system Develop
  2. Database Software Develop
  3. Virus and Anti-Virus Develop
  4. Compliers Develop
  5. Interpreters, etc

সি প্রোগ্রামের ফম্যাটঃ

সি তে এক বা একাধিক ফাংশন থাকে তবে তার মধ্য main function থাকে যার মধ্যে মূল প্রোগ্রামটি লিখা হয়। সি মূলত কয়েকটি অংশ/Section মিলে একটি পূর্নাজ্ঞ প্রোগ্রাম হয়। অংশগুল হল।
  1. Documentation Section
  2. Link Section
  3. Definition Section
  4. Global Section
  5. Main Function Section
  6. Sub Program sectio
6.I. Function1 section 6.II. Fuction2 Section 6.III. Function3 Section

সি এর কম্পাইলারঃ

4 

সি এক কম্পিউটারের ভাষায় অর্থাৎ মেশিন ভাষায়(0,1) এ রুপান্তর করার জন্য একাধিক কম্পাইলার তথা অনুবাদক ব্যবহার করা হয়। তারমধ্য Turbo C অন্যতম। যদিও Turbo C একটি পুরনো কম্পাইলার ও এতে কাজ করা অনেক জটিল। আমরা আমাদের এই টিউটোরিয়াল পর্বে Turbo C ব্যবহার না করে CodeBlocks ব্যবহার করব। কারন CodeBlocks প্রোচুর এডভান্স লেভেলের ও শক্তিশালী কম্পাইলার। এতে জটিলতা কয়াটিয়ে সহজেই পপ্রোগ্রাম লিখা যায়। CodeBlocks ওপেন সোর্স কম্পাইলার যা একই সাথে লিনাক্স, ম্যাক ও উন্ডোজে ব্যবহার করা যায়।CodeBlocks এর সাইট লিংক http://www.codeblocks.org/downloads/26 থেকে ডাউনলোড করে নিন এবং অনন্য সব সাধারন আপ্লিকেশনের মত করেই ইন্সটল করুন।

Write a program using Standard Division

Write a program using Standard Division.

Program:


#include <stdio.h>
#include <math.h>
main () {
int n, i, sum=0, a[50] , b[50], avg, sd=0;
float sd1, sd2;
scanf ("%d", &n);

for (i=0; i<n; i++){
scanf ("%d", &a[i]);
sum = sum=a[i];
}
avg = sum/n;
printf ("Avg = %d\n", avg);

for (i=0; i<n; i++){
b[i] = avg-a[i];
printf ("%d\n", &b[i]);
sd = sd+(b[i]*b[i]);
}
sd1 = (sd)/n;
sd2 = sqrt (sd1);
printf ("SD = %f", sd);
}

Find out the maximum value of an array.

Find out the maximum value of an array.

Program:
#include<stdio.h>
main()
{
int n, i, max, x[50], p, c=0;

printf("Enter number: N= ");
scanf("%d", &n);

for(i=0; i<n; i++)
{
printf("Enter number for [id %d]= ",i);
scanf("%d", &x[i]);
}
max=x[0];
p=0;
for(i=0; i<n; i++)
{
if(x[i]>max)
{
max=x[i];
p=i;
}
if(x[i]==max)
c++;
}
/*
for(i=0; i<n; i++)
{
if(x[i]==max)
c++;
}
*/
printf("Maximum number is=%d \n Position=%d", max,p);
printf("\n Total max=%d", c);
}

Find out the range of marks number of N students

Find out the range of marks number of N students .

Program:
#include<stdio.h>
int main()
{
int n, i, m, a[100], max, min;

while(scanf("%d", &n)==1){
//printf("How many students = ");
//scanf("%d", &n);

for(i=0; i<n; i++)
{
printf("Enter mark for [id %d]", i);
scanf("%d", &a[i]);
}

max=a[0];
min=a[0];

for(i=0; i<n; i++)
{
if(a[i]>max)
max=a[i];

if(a[i]<min)
min=a[i];
}
printf("Range %d to %d", min, max);
}
return 0;
}

Write a program using following equation : 1+ 2/2!+3 /3!+4 /4!+⋯

Write a program using following equation : 1+ 2/2!+3 /3!+4 /4!+⋯

Program:
#include<stdio.h>
#include<math.h>
main()
{
int n, i;
float x,sum=0,y;

printf("Enter N = ");
scanf("%d", &n);

printf("Enter X = ");
scanf("%f", &x);
y=(x-1)/x;
for(i=2; i<=n; i++)
{
sum=sum+(pow(y,i)*.5);
}
printf("Sum=%f", sum+y);
}

Write a program using following equation: ⁡((x-1)/x)+1/2⁡((x-1)/x)^2 +1/2 ((x-1)/x)^3+⋯ +1/2⁡((x-1)/x)^n

Write a program using following equation.



Program:
#include<stdio.h>
#include<math.h>
main()
{
int n, i;
float x,sum=0,y;

printf("Enter N = ");
scanf("%d", &n);

printf("Enter X = ");
scanf("%f", &x);
y=(x-1)/x;
for(i=2; i<=n; i++)
{
sum=sum+(pow(y,i)*.5);
}
printf("Sum=%f", sum+y);
}

Write a program for up and down item from matrix diagonal element.

Write a program for up and down item from matrix diagonal element.

Program:
#include<stdio.h>
main()
{
int n, i, j, x[10][10];

printf("Enter number =");
scanf("%d", &n);

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
printf("Enter value for [%d][%d]=", i,j);
scanf("%d", & x[i][j]);
}
}

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(j>i)
printf("\n up element %d", x[i][j]);
else if (j<i)
printf("\n down element %d", x[i][j]);
}
}

}

Write a program for matrix diagonal element.

Write a program for matrix diagonal element.

Program:
#include<stdio.h>
main()
{
int n, i, j, x[10][10];

printf("Enter number =");
scanf("%d", &n);

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
printf("Enter value for [%d][%d]=", i,j);
scanf("%d", & x[i][j]);
}
}

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(i==j)
printf("\t %d", x[i][j]);
}
}

}

Increment output value

Write a program for increment output value

Program:
#include<stdio.h>
main()
{
int n, x[50],j=0,i=0, y;
printf("Enter your value = ");
scanf("%d", &n);

while (n!=0)
{
y=n%10;
y++;
x[i]=y;
i++;
n=n/10;
}
for(j=i-1; j>=0; j--)
{
if (x[j]==10)
printf("0");
else
printf("%d", x[j]);
}
}

Revers sumission

Write a program for Revers sumission.

Program:
#include<stdio.h>
main()
{
int n,x,sum=0,c=0;

printf("Enter your value = ");
scanf("%d", &n);

while (n!=0)
{
x=n%10;
printf("\t%d",x);
sum=sum+x;
n=n/10;
c++;
}
printf("\nAre Sumission is  = %d", sum);
printf("\nTotal count = %d", c);
}
 

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle