ENG 103

Headway Pre-Intermediate The Third Edition work book www.euelibrary.com

 

Advertisements

Math 101 1st semester

Math Integration Class Note All Classes Here www.euelibrary.com

Integration Solution of some mats www.euelibrary.com

Integration Pratic Sit And Question www.euelibrary.com

Maxima And Minima Solution www.euelibrary.com

Formulas Of Calculas www.euelibrary.com

Domain and Range Solution Sit MATH 101 www.euelibrary.com

Differentiation All Pratic Sit www.euelibrary.com

Differentiation All Class Note www.euelibrary.com

Cource outline www.euelibrary.com

Coninuti and Differentiability Solution Sit www.euelibrary.com

Preliminary C programming

  • Write a program to print “Hellow World”.#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    printf(“Hellow World”);
    getch();
    }
  • The length and height of a rectangle and radius of a circle are input through the keyboard.Write a program to find the area & perimeter of the rectangle and circumference of the circle.
    #include<stdio.h>
    #include<conio.h>void main()
    {
    clrscr();
    int length,height,area,per,rad,cir;
    printf(“Enter a length? \n”);
    scanf(“%d”,&length);
    printf(“Enter a height? \n”);
    scanf(“%d”,&height);
    printf(“Enter a radius?\n”);
    scanf(“%d”,&rad);area=length*height;

    per=2*(length+height);
    cir=2*3.1416*rad;
    printf(“The perimiter is: %d\n”,per);

    printf(“The area is: %d\n”,area);
    printf(“The circumference is:%d”,cir);

    getch();
    }

  • Rahim’s basic salary is inpute through the keyboard.His house rent allowarnce is 30% of his basic salary and medical allowance is 5% of basic salary.He gets extra 1000 tk as technical allowance.Write a program to calculate his gross salary and print the result.#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int b,t,g;
    float h,m;
    printf(“input rahim’s basic salary:\n”);
    scanf(“%d”,&b);
    h=(b*30)/100;
    m=(b*5)/100;
    t=1000;
    g=(b)+(h)+(m)+(t);
    printf(“Rahim’s gross salary is:%d”,g);
    getch();
    }
  • Two anumbers  are input  through the keyboard into two locations A and B. Write a program to interchange the contents of A and B.#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int a,b,temp;
    printf(“Enter the value of A:”);
    scanf(“%d”,&a);
    printf(“Enter the value of B:”);
    scanf(“%d”,&b);
    temp=a;
    a=b;
    b=temp;printf(“\n\nAfter interchange the value of A is:%d”,a);
    printf(“\n\nAfter interchange the value of B is:%d”,b);
    getch();
    }
  • If a 5 digit number is input  through the keyboard, Write a program to calculate  and print  the sum of its digits.#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int rem,sum=0;
    int num;
    printf(“A 5 digit number is?\n”);
    scanf(“%d”,&num);
    rem=num%10;
    sum=rem+sum;
    num=num/10;
    rem=num%10;
    sum=rem+sum;
    num=num/10;
    rem=num%10;
    sum=rem+sum;
    num=num/10;
    rem=num%10;
    sum=sum+rem;
    num=num/10;
    sum=sum+num;
    printf(“\nThe sum of the digits of this number is:%d”,sum);
    getch();
    }
  • If  a 5 digit number is input  through the keyboard, Write a program to reverse the number.#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int rem,numb=0;
    long int num;
    printf(“Enter the 5 digit number ?\n”);
    scanf(“%ld”,&num);
    rem=num%10;
    numb=numb+(10000*rem);
    num=num/10;
    rem=num%10;
    numb=numb+(1000*rem);
    num=num/10;
    rem=num%10;
    numb=numb+(100*rem);
    num=num/10;
    rem=num%10;
    numb=numb+(10*rem);
    num=num/10;
    numb=numb+num;
    printf(“The reverse number of this number is:%ld”,numb);
    getch();
    }
  • If  a 4 digit number is input  through the keyboard, Write a program to obtain the sum of the first and last digit of this number.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int rem,sum=0;
    int num;
    printf(“A 4 digit number is?\n”);
    scanf(“%d”,&num);
    rem=num%10;
    sum=rem+sum;
    num=num/10;
    rem=num%10;
    num=num/10;
    rem=num%10;
    num=num/10;
    rem=num%10;
    sum=sum+rem;
    printf(“\nThe sum of the first and last digit of this number is:%d”,sum);
    getch();
    }

Looping C programming

  • x and n are input through keyboard.Write a program to compute xn, n!, nCr, nPr

    xn
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int x,n,res=1;
    int i;
    printf(“Enter the value of x?\n”);
    scanf(“%d”,&x);
    printf(“Enter the value of n?\n”);
    scanf(“%d”,&n);
    for(i=0;i<n;i++)

    res=res*x;
    printf(“Answer:%d”,res);

    getch();
    }

    n!
    #include<stdio.h>
    #include<conio.h>

    void main()
    {
    int n,i,
    res=1;
    clrscr();
    printf(“Enter the n=”);
    scanf(“%d”,&n);
    for(i=n;i>=1;i–)
    res=res*i;
    printf(“n!=%d”,res);
    getch();
    }nCr
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int n,r,sum=1,i,k,p,res=1,x,rem=1,f,ncr;
    printf(“Enter the value of n:”);
    scanf(“%ld”,&n);
    printf(“Enter the value of r:”);
    scanf(“%ld”,&r);
    p=n-r;
    for(i=n;i>=1;i–)
    {
    sum=sum*i;
    }
    for(k=p;k>=1;k–)
    {
    res=res*k;
    }
    for(x=r;x>=1;x–)
    {
    rem=rem*x;
    }
    f=res*rem;
    ncr=sum/f;
    printf(“\nncr=%ld”,ncr);
    getch();
    }
    nPr#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int n,r,sum=1,i,k,p,res=1,l;
    printf(“Enter the value of n:”);
    scanf(“%ld”,&n);
    printf(“Enter the value of r:”);
    scanf(“%ld”,&r);
    p=n-r;
    for(i=n;i>=1;i–)

    sum=sum*i;

    for(k=p;k>=1;k–)
    {
    res=res*k;
    }
    l=sum/res;
    printf(“\nnpr=%ld”,l);
    getch();
    }

  • Write a program to determine the GCD and LCM of 3 numbers.
    GCD#include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int a,b,c,rem;
    printf(“Enter the value of a?\n”);
    scanf(“%d”,&a);
    printf(“Enter the value of b?\n”);
    scanf(“%d”,&b);
    printf(“Enter the value of c?\n”);
    scanf(“%d”,&c);
    while(b>0)
    {
    rem=a%b;
    a=b;
    b=rem;
    }
    while(c>0)
    {
    rem=a%c;
    a=c;
    c=rem;
    }
    printf(“GCD is:%d”,a);
    getch();
    }
    LCM
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int a,b,c,i;
    printf(“Enter the value of a?\n”);
    scanf(“%d”,&a);
    printf(“Enter the value of b?\n”);
    scanf(“%d”,&b);
    printf(“Enter the value of c?\n”);
    scanf(“%d”,&c);
    for(i=1; ;i++)
    {
    if(i%a==0&&i%b==0&&i%c==0)
    break;
    }
    printf(“LCM is:\n%d”,i);
    getch();
    }
  • Find out the sum of each of the following series. n is the input from user for series (4)
    1. 3+11+19+………+1691.
    2. 7+20+33+………(up to 100th term)
    3. 5-11+17-……….(up to 75th term)
    4. 2*7*12*………..*37

    1.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int x=3,sum=0;
    for(x=3;x<=1691;x=x+8)
    {
    sum=sum+x;

    }
    printf(“\n\nSUM:%ld”,sum);
    getch();
    }
    2.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int x=7,sum=0,i;
    for(i=1;i<=100;i++)
    {
    sum=sum+x;
    x=x+13;
    }
    printf(“\n\nSUM:%ld”,sum);
    getch();
    }
    3.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int x=5,sum=0,i;
    for(i=1;i<=75;i++)
    {
    sum=sum+x;
    if(x>0)
    x=(x+6)*-1;
    else
    x=(x-6)*-1;
    }
    printf(“\n\nSUM:%ld”,sum);
    getch();
    }.
    4.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    long int x=2,sum=1;
    for(x=2;x<=37;x=x+5)
    {
    sum=sum*x;

    }
    printf(“\n\nSUM:%ld”,sum);
    getch();
    }

  • Write  a program to determine all prime numberswithin the range [a…….b]
    where a & b are input through keyboard.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int num,num1,i,n,l;
    scanf(“%d”,&num);
    scanf(“%d”,&num1);
    n=2;
    l=num;
    for(i=l;i<=num1;i++)
    {
    while(n<=i/2)
    {
    if(i%n==0)
    break;
    ++n;
    }
    if(n>i/2 && i!=2)
    printf(” %d”,i);
    n=2;
    }
    getch();
    }

  • Construct the following table.Here n is input from the user.
    1             2              3          …..    n
    2             4              6         …….   2n
    3             6              9         …….   3n
    .             .               .           …..     .
    .             .               .          …….    .
    .             .               .           …….   .
    n           2n            3n          …….  nn

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

    void main()
    {
    clrscr();

    int i,n,k;
    scanf(“%d”,&n);

    for(i=1;i<=n;i++)
    {
    for(k=1;k<=n;k++)

    printf(“\t%d”,k*i);

    printf(“\n”);
    }
    getch();
    }

  • Write a program to find out first n perfect number where n is the input from user.

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

    void main()
    {
    clrscr();
    int i,num,sum=0;
    printf(“Enter a num”);
    scanf(“%d”,&num);
    for(i=1;i<=num/2;i++)
    if(num%i==0)
    sum=sum+i;
    if(sum==num)
    printf(“The number is a perfect number”);
    else
    printf(“The number is not a perfect number”);
    getch();
    }

  • Write a program to find first n Fibonacci number where n is the input from user.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int n,a,b,sum,i,rem;
    a=0;
    b=1;
    printf(“Enter the value of n?\n”);
    scanf(“%d”,&n);
    printf(“The fibonacci numbers are:”);
    for(i=1;i<=n;i++)
    {
    sum=a+b;
    rem=sum;
    a=b;
    b=rem;
    printf(“\n%d\n”,sum);
    }
    getch();
    }

  • Write a program to show the following triangle/rectangle of  “*” or numbers.Take n as inpute from user to determine the number of rows of the structure.(eg. n=5)
    1.
    #include<stdio.h>
    #include<conio.h>
    void main()                                                                                   {                                                                                        clrscr();

    int i,k,n;
    scanf(“%d”,&n);

    int c=1;                                                                  
    int s=n-1;

    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s–;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c+2;
    printf(“\n”);
    }

    getch();
    }

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

    void main()
    {
    clrscr();

    int i,k,n;
    scanf(“%d”,&n);
    int c=1;
    int s=n-1;

    for(i=1;i<=n;i++)
    {
    for(k=1;k<=s;k++)
    printf(” “);
    s–;                                                              

    for(k=1;k<=c;k++)

    if(k==1||k==c)
    printf(“*”);
    else if(i==n)
    printf(“*”);
    else
    printf(” “);

    c=c+2;

    printf(“\n”);
    }
    getch();
    }
    4.
    #include<stdio.h>
    #include<conio.h>

    void main()
    {
    clrscr();

    int i,k,n;
    scanf(“%d”,&n);

    int c=1;                                                             
    int s=n-1;

    for(i=1;i<=n;i++)
    {
    for(k=1;k<=s;k++)
    printf(“*”);

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c;
    printf(“\n”);
    }

    getch();
    }
    5.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int i,n,k;
    scanf(“%d”,&n);
    for(i=1;i<=n;i++)                                                       
    {
    for(k=1;k<=n;k++)
    { if(k==1||k==n)
    printf(“*”);
    else if(i==1||i==n)
    printf(“*”);
    else
    printf(” “);
    }
    printf(“\n”);
    }

    getch();
    }

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

    void main()
    {
    clrscr();

    int i,k,n;
    scanf(“%d”,&n);
    int c=1;                                                                    
    int s=n-1;

    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s–;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c+2;
    printf(“\n”);
    }
    c=c-4;
    s=1;
    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s++;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c-2;
    printf(“\n”);
    }

    getch();
    }

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

    void main()
    {
    clrscr();

    int i,k,n;
    scanf(“%d”,&n);
    int c=1;
    int s=n-1;
    for(i=1;i<=n;i++)                                                     
    {
    for(k=1;k<=s;k++)
    printf(” “);
    s–;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c+2;
    printf(“\n”);
    }
    c=c-4;
    s=1;
    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s++;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c-2;
    printf(“\n”);
    }
    getch();
    }

    10.
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();

    int i,k,n;
    scanf(“%d”,&n);

    int c=(2*n)-1;
    int s=0;

    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s++;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c-2;
    printf(“\n”);
    }
    c=3;
    s=n-2;
    n=n-1;
    for(i=1;i<=n;i++)
    {

    for(k=1;k<=s;k++)
    printf(” “);
    s–;

    for(k=1;k<=c;k++)
    printf(“*”);

    c=c+2;
    printf(“\n”);
    }

    getch();
    }

  • Write a program to print out all Armstrong numbers between 1 and 10000.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    clrscr();
    int num,sum=0,k,rem,i;
    for(i=1;i<=10000;i++)
    {
    num=i;
    sum=0;

    for(k=1;k<=i;k++)
    {
    rem=num%10;
    sum=sum+(rem*rem*rem);
    num=num/10;
    }

    if(sum==i)
    printf(“\n%d\n”,i);
    }
    getch();
    }

  • Write a program to calculate how many 5 digit numbers can be created if the following terms apply:
    1. the leftmost digit is even
    2. the second digit is odd
    3. the third digit is a non even prime
    4. the fourth and fifth are two random digits not used before in the number.

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

      long int prime(long int n);

      void main()
      {
      clrscr();
      long int a,b,c,d,e,i,rem,num,count=0;
      for(i=20000;i<=99999;i++)
      {
      rem=i%10;
      e=rem;
      num=i/10;
      rem=num%10;
      d=rem;
      num=num/10;
      rem=num%10;
      c=rem;
      num=num/10;
      rem=num%10;
      b=rem;
      num=num/10;
      a=num;
      if(a%2==0&&b%2!=0&&prime(c)&&d!=a&&d!=b&&d!=c&&e!=d&&e!=a&&e!=b&&e!=c)
      count++;

      }
      printf(” \nRESULT=%ld”,count);
      getch();
      }

      long int prime (long int n)
      {       int m;
      m=2;
      while(m<=n/2)
      {
      if(n%m==0)
      break;
      ++m;
      }
      if(m>n/2&&n!=2&&n!=1&&n!=0)
      return 1;
      else
      return 0;
      }