Programming in C Lab. (BCA Semester-I, BCA-52P-102) Practical Lab Manual 2024

Programming in C Lab.

Part-A

Program No. 1:

Write a C program to read radius of a circle and to find area and circumference.

Source Code:

/* C-Program Area and Circumference of Circle */
#include <stdio.h>
int main()
{
    float r,area, circum;

    printf("Enter the Radius of circle: \n");
    scanf("%f", &r);
    area = 22/7.0*r*r;
    circum = 2*22/7.0*r;

    printf("\n");
    printf("Area    = %7.2f \n", area);
    printf("circum  = %7.2f \n", circum);
             return 0;
  }

Output
1. 
   Enter the Radius of circle:
   7
   Area   = 154.00
   circum = 44.00

2. Enter the Radius of circle:
   13.6
   Area = 581.30
   circum = 85.49

Program No. 2:

Write a C program to read three numbers and find the biggest of three.

Source Code:

/* Read any three real numbers and find largest number using nested if */
#include <stdio.h>
#include <conio.h>
int main()
{
    float a, b, c, l;
    printf("Enter Any three Numbers (a, b, c): \n");
    scanf("%f%f%f", &a,&b,&c);

    if(a > b)             /* nested if */
         if(a > c)
               l = a;
         else
               l = c;
    else if(b > c)       /* else if ladder */
               l = b;
         else
               l = c;

    printf("\nLargest Number = %.2f\n",l);
    return 0;
}

Output:
1.
    Enter Any three Numbers (a, b, c): 
    45
    25
    89

    Largest Number = 89

2.Enter Any three Numbers (a, b, c): 
    -45.98
    -892.00
    -23.67

Largest Number = -23.67

 

Leave a Reply