Top Banner

of 18

Programming Language on C

Apr 07, 2018

Download

Documents

Alamin Mohammad
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/6/2019 Programming Language on C

    1/18

    ASSIGNMENT

    ONPROGRAMMING ON C++LANGUAGE.

  • 8/6/2019 Programming Language on C

    2/18

    DEPARTMENT OF ACCOUNTING & INFORMATION SYSTEMS

    FACULTY OF BUSINESS STUDIES

    UNIVERSITY OFDHAKA

    Submitted to:

    Minhaj Ferdous

    Assistant teacher

    Department of Accounting and Information Systems.

    Submitted by:

    The Gladiator

    Serial No Name ID No

    01 Md. Al-amin(Group Leader) 14032

    02 Md.Akter Hossain 14021

    03 Farhana Yasmin 14024

    04 Md. Din Islam 14031

    05 Moniruzzaman 14035

    06 Md. Kowser Bhuiyan 14083

    Date of submission: 23 December, 2010

  • 8/6/2019 Programming Language on C

    3/18

    Table of Contents

    Sl. No. Programs Page

    No.1 Program to Find out the temperature in Fahrenheit.

    2 Factorial of a Number.

    3 Program for standard deviation.

    4 Whether a year is a leap year or not.

    5 Whether a Number is Prime or Not.

    6 Program to find Fibonacci series.

    7 A program for string copying.

    8 Two strings are equal or not.

    9 Program for finding the length of a string.

    10 Program for string concatanation.

    11 Finding power value.

    12 Conversion of Decimal Number to Binary Number.

    13 Program to find NPV, PV.

    14 Whether a particular character exists in a string.

    15 Program to sort some numbers in ascending order.

    16 A program to find whether a number is even or odd.

    17 A program to find bigger number among three numbers.

    18 A program to find the value of a quadratic equation.

  • 8/6/2019 Programming Language on C

    4/18

    1. Program to Find out the temperature in Fahrenheit.

    #include

    #include

    void main()

    {

    float f,c;

    clrscr();

    printf("Enter centigrade:");

    scanf("%f",c);

    f=1.8*c+32;

    printf("\nThe Fahrenheit is :%.2f",f);

    getch();

    }

  • 8/6/2019 Programming Language on C

    5/18

    2. Factorial of a Number.

    #include

    #include

    void main()

    {int i,n,fact;

    clrscr();

    printf("Enter a numbet to get factorial:");

    scanf("%d",&n);

    if(n==0)

    printf("\nThe factorial is 1.");

    else

    for(i=1;i

  • 8/6/2019 Programming Language on C

    6/18

    3. Program for Standard Deviation.

    #include

    #include

    #include

    void main()

    {

    int i,n;

    float list[50],sum,avg,d,sd;

    clrscr();

    printf("How Many Numbers");

    scanf("%d",&n);

    sum=0;

    for(i=0;i

  • 8/6/2019 Programming Language on C

    7/18

    sd=sqrt(sum/n);

    printf("\nThe standard Deviation is %f",sd);

    getch();

    }

    4. Whether a year is a leap year or not.

    #include

    #include

    void main()

    {

    int a;

    clrscr();

    printf("Enter data to test");

    scanf("%d",&a);

    if((a%4)==0)

    printf("\nLeap year");

    else

    printf("\nNot Leap Year");

    getch();

    }

  • 8/6/2019 Programming Language on C

    8/18

    5.Wheather a Number is Prime or Not.

    #include

    #include

    void main()

    {

    int i,num,result;

    clrscr();

    printf("Enter number to test");

    scanf("%d",&num);

    result=1;

    for(i=2;i,num/i;i++)

    if((num%i)==0)result=0;

    if(result==1)

    printf("\nThe Number Is Prime");

    else

    printf("\nThe number is Not Prime");

    getch();

    }

  • 8/6/2019 Programming Language on C

    9/18

    6. Program to find Fibonacci series.

    #include

    #include

    void main()

    {

    int i,n,a[50];

    clrscr();

    printf("How Many Numbers?");

    scanf("%d",&n);

    a[0]=1;

    a[1]=1;

    for(i=2;i

  • 8/6/2019 Programming Language on C

    10/18

    7. A program for string copying

    #include

    #include

    #include

    void main()

    {

    char str1[20],str2[20];

    clrscr();

    printf("Enter a strig:");

    scanf("%s",str1);

    strcpy(str2,str1);

    printf("The original string is:%s",str1);

    printf("\nAnd the copy is:%s",str2);

    getch();

    }

  • 8/6/2019 Programming Language on C

    11/18

    8. Two strings are equal or not

    #include

    #include

    #include

    void main()

    {

    char x[30],y[30];

    int f;

    clrscr();

    printf("Enter a string:");

    scanf("%s",x);

    printf("Enter another string:");

    scanf("%s",y);

    f=strcmp(x,y);

    if(f!=0)

    printf("\nTwo strings are not equal.");

    else

    printf("\nTwo strings are equal.");

    getch();

    }

  • 8/6/2019 Programming Language on C

    12/18

    9. Program for finding the length of a string

    #include

    #include

    #include

    void main()

    {

    char str[30];

    int l;

    clrscr();

    printf("Enter a strig:");

    scanf("%s",str);

    l=strlen(str);

    printf("\nThe length of the string is:%d",l);

    getch();

    }

  • 8/6/2019 Programming Language on C

    13/18

    13. Program to find NPV,PV

    #include

    #include

    #include

    void main()

    {

    int i,n;

    float a[20],cof,d,in,sum=0,npv;

    clrscr();

    printf("\nEnter the cash outflow");

    scanf("%f",cof);

    printf("Enter the enterest rate");

    scanf("%f",&in);

    printf("\nEnter the number of cash inflow");

    scanf("%d",&n);

    for(i=0;i

  • 8/6/2019 Programming Language on C

    14/18

    getch();

    }

    14. Whether a particular character exists in a string.

    #include

    #include

    #include

    void main()

    {

    char *ch,*find,*str;

    clrscr();

    printf("Enter a string");

    scanf("%s",str);

    printf("Enter a chracter");

    scanf("%s",ch);

    find=strstr(str,ch);

    if(find)

    printf("\nThe charater exists in the string");

    else

    printf("\nThe chracter doesnot exist in the string");

    getch();

    }

  • 8/6/2019 Programming Language on C

    15/18

    15. Program to sort some numbers in ascending order

    #include

    #include

    void main()

    {

    int i,j,n,list[30],temp;

    clrscr();

    printf("how many numbers");

    scanf("%d", &n);

    for(i=0;i

  • 8/6/2019 Programming Language on C

    16/18

    }

    printf("\n");

    for(i=0;i

  • 8/6/2019 Programming Language on C

    17/18

    void main()

    {

    int list[3],i,max;

    for(i=0; i

  • 8/6/2019 Programming Language on C

    18/18

    {

    int a,b,c;

    float d,root_1,root_2;

    clrscr();

    printf("\n Enter values for a");

    scanf("%d",&a);

    printf("\n Enter values for b");

    scanf("%d",&b);

    printf("\n Enter values for c");

    scanf("%d",&c);

    d=(b*b-4*a*c);

    if(d