1. Question:C program for area of equilateral triangle 

    Answer
    #include<stdio.h>
    #include<math.h>
    
    int main(){
    
        float a;
        float area;
    
        printf("Enter size of side of the equilateral triangle : ");
        scanf("%f",&a);
    
        area = sqrt(3)/4*(a*a);
    
        printf("Area of equilateral triangle is: %.3f",area);
    
        return 0;
    }
    Sample output: Enter size of side of the equilateral triangle: 5 Area of equilateral triangle is: 10.825

    1. Report
  2. Question:C program for area of right angled triangle 

    Answer
    #include<stdio.h>
    int main(){
        float h,w;
        float area;
    
        printf("Enter height and width of the right angled triangle : ");
        scanf("%f%f",&h,&w);
    
        area = 0.5 * h * w;
        printf("Area of right angled triangle is: %.3f",area);
        return 0;
    }
    Sample output: Enter height and width of the right angled triangle: 10 5 Area of right angled triangle is: 25.000

    1. Report
  3. Question:C program for area of a rectangle 

    Answer
    #include<stdio.h>
    
    int main(){
    
        float l,w;
        float area;
    
        printf("Enter size of each sides of the rectangle : ");
        scanf("%f%f",&l,&w);
    
        area = l * w;
        printf("Area of rectangle is: %.3f",area);
    
        return 0;
    }
    [b]Sample output:[b] Enter size of each sides of the rectangle: 5.2 20 Area of rectangle is: 104.000

    1. Report
  4. Question:C program for area of a trapezium 

    Answer
    #include<stdio.h>
    
    int main(){
    
        float b1,b2,h;
        float area;
    
        printf("Enter the size of two bases and height of the trapezium : ");
        scanf("%f%f%f",&b1,&b2,&h);
    
        area = 0.5 * ( b1 + b2 ) * h ;
        printf("Area of trapezium is: %.3f",area);
        return 0;
    }
    Sample output: Enter the size of two bases and height of the trapezium: 5 8 3 Area of trapezium is: 19.500

    1. Report
  5. Question:C program for area of a cube 

    Answer
    #include<stdio.h>
    
    int main(){
    
        float a;
        float surface_area,volume;
    
        printf("Enter size of any side of a cube : ");
        scanf("%f",&a);
    
        surface_area = 6 * (a * a);
        volume = a * a * a;
    
        printf("Surface area of cube is: %.3f",surface_area);
        printf("\nVolume of cube is : %.3f",volume);
    
        return 0;
    }
    Sample output: Enter size of any side of a cube: 3 Surface area of cube is: 54.000 Volume of cube is: 27.000

    1. Report
  6. Question:C program for area of a cuboids 

    Answer
    #include<stdio.h>
    int main(){
    
        float w,l,h;
        float surface_area,volume,space_diagonal;
    
        printf("Enter size of width, length and height of a cuboids : ");
        scanf("%f%f%f",&w,&l,&h);
    
        surface_area = 2*(w*l + l*h + h*w);
        volume = w * l * h;
        space_diagonal = sqrt(w*w + l*l + h*h);
    
        printf("Surface area of cuboids is: %.3f",surface_area);
        printf("\nVolume of cuboids is : %.3f",volume);
        printf("\nSpace diagonal of cuboids is : %.3f",space_diagonal);
    
        return 0;
    }
    Sample output: Enter size of width, length and height of cuboids: 5 10 4 Surface area of cuboids is: 220.000 Volume of cuboids is: 200.000 Space diagonal of cuboids is: 11.874

    1. Report
  7. Question:C program for area of a cylinder 

    Answer
    #include<stdio.h>
    #include<math.h>
    
    int main(){
    
        float r,h;
        float surface_area,volume;
    
        printf("Enter size of radius and height of a cylinder : ");
        scanf("%f%f",&r,&h);
    
        surface_area = 2 * M_PI * r * (r + h);
        volume = M_PI * r * r * h;
    
        printf("Surface area of cylinder is: %.3f",surface_area);
        printf("\nVolume of cylinder is : %.3f",volume);
    
        return 0;
    }
    Sample output: Enter size of radius and height of a cylinder: 4 10 Surface area of cylinder is: 351.858 Volume of cylinder is: 502.655

    1. Report
  8. Question:Write a c program or code to find or calculate the volume and surface area of cone 

    Answer
    #include<stdio.h>
    #include<math.h>
    
    int main(){
    
        float r,h;
        float surface_area,volume;
    
        printf("Enter size of radius and height of a cone : ");
        scanf("%f%f",&r,&h);
    
        surface_area = M_PI * r * (r + sqrt(r*r + h*h));
        volume = (1.0/3) * M_PI * r * r * h;
    
        printf("Surface area of cone is: %.3f",surface_area);
        printf("\nVolume of cone is : %.3f",volume);
    
        return 0;
    }
    Sample output: Enter size of radius and height of a cone: 3 10 Surface area of cone is: 126.672 Volume of cone is: 94.248

    1. Report
  9. Question:C program for area of a sphere 

    Answer
    #include<stdio.h>
    #include<math.h>
    
    int main(){
    
        float r;
        float surface_area,volume;
    
        printf("Enter radius of the sphere : ");
        scanf("%f",&r);
    
        surface_area =  4* M_PI * r * r;
        volume = (4.0/3) * M_PI * r * r * r;
    
        printf("Surface area of sphere is: %.3f",surface_area);
        printf("\nVolume of sphere is : %.3f",volume);
    
        return 0;
    }
    Sample output: Enter radius of the sphere: 5 Surface area of sphere is: 314.159 Volume of sphere is: 523.599

    1. Report
  10. Question:How to get multiplication of two very large numbers larger or beyond than long int in c programming language 

    Answer
    #include<stdio.h>
    #include<math.h>
    #include<stdlib.h>
    #include<string.h>
    #define MAX 10000
    
    char * multiply(char [],char[]);
    int main(){
        char a[MAX];
        char b[MAX];
        char *c;
        int la,lb;
        int i;
        printf("Enter the first number : ");
        scanf("%s",a);
        printf("Enter the second number : ");
        scanf("%s",b);
        printf("Multiplication of two numbers : ");
        c = multiply(a,b);
        printf("%s",c);
        return 0;
    }
    
    char * multiply(char a[],char b[]){
        static char mul[MAX];
        char c[MAX];
        char temp[MAX];
        int la,lb;
        int i,j,k=0,x=0,y;
        long int r=0;
        long sum = 0;
        la=strlen(a)-1;
            lb=strlen(b)-1;
       
            for(i=0;i<=la;i++){
                    a[i] = a[i] - 48;
            }
    
            for(i=0;i<=lb;i++){
                    b[i] = b[i] - 48;
            }
    
        for(i=lb;i>=0;i--){
             r=0;
             for(j=la;j>=0;j--){
                 temp[k++] = (b[i]*a[j] + r)%10;
                 r = (b[i]*a[j]+r)/10;
             }
             temp[k++] = r;
             x++;
             for(y = 0;y<x;y++){
                 temp[k++] = 0;
             }
        }
       
        k=0;
        r=0;
        for(i=0;i<la+lb+2;i++){
             sum =0;
             y=0;
             for(j=1;j<=lb+1;j++){
                 if(i <= la+j){
                     sum = sum + temp[y+i];
                 }
                 y += j + la + 1;
             }
             c[k++] = (sum+r) %10;
             r = (sum+r)/10;
        }
        c[k] = r;
        j=0;
        for(i=k-1;i>=0;i--){
             mul[j++]=c[i] + 48;
        }
        mul[j]='\0';
        return mul;
    }
    Sample output of above code: Enter the first number: 55555555 Enter the second number: 3333333333 Multiplication of two numbers: 185185183314814815

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd