Popular Posts

Chapter 2 Solve E.Balaguruswamy ANSI C

Exercise Solve For 2.1:

#include<stdio.h>

void main()
{
    int n,n_t;
    float h=0;

    printf("Enter the value for n: ");
    scanf("%d", &n_t);

    for(n=1;n<=n_t;n++)
    {
        h+=(1/(float) n);
    }
    printf("The value of harmonic series is = %.2f", h);

}





Exercise Solve For 2.2:

#include<stdio.h>

void main()
{
    float price;

    printf("Enter the price of an item : ");
    scanf("%f",&price);
    price*=100;

    printf("Price amount in paise is = %.2f paise ",price);
}



Exercise Solve For 2.3:

#include<stdio.h>

void main()
{
    float price;

    printf("Enter the price of an item : ");
    scanf("%f",&price);
    price*=100;

    printf("Price amount in paise is = %.2f paise ",price);
}



Exercise Solve For 2.4:

#include<stdio.h>

void main()
{
    int number;
    printf("Even number from 1 to 100 is :\n");

    for(number=1;number<=100;number++)
    {
        if((number%2)==0)
        {
            printf("%d\n", number);
        }
    }
}


Exercise Solve For 2.5:

#include<stdio.h>

void main()
{
    float a,b,div;
    printf("Enter first and second number separated by space: ");
    scanf("%f %f", &a, &b);
    printf("\nFirst number is %.2f\nSecond number is %.2f", a, b);
    div=(a/b);
    printf("\nDivision of %.2f / %.2f = %.2f",a, b, div);
}




Exercise Solve For 2.6:


#include<stdio.h>

void main()
{
    float price_rice,price_sugar;
    printf("Enter the value for RICE :");
    scanf("%f", &price_rice);
    printf("Enter the value for sugar :");
    scanf("%f", &price_sugar);
    printf("\n\nItem\t\tPrice\nRice\t\t%.2f taka\nSugar\t\t%.2f taka",price_rice, price_sugar);
}













1 comment: