Programming Laboratory (BITAIC191) : Dr. Pabitra Pal
Programming Laboratory (BITAIC191) : Dr. Pabitra Pal
B.Sc.
in
Information Technology (Artificial Intelligence)
Submitted by
Aruk Bandyopadhyay
Roll - 30054622005
Course Faculty
Dr. Pabitra Pal
Feb, 2023
Table of Contents
SL Page Date Faculty Signature
Name of the Programs
no
No
1. C Program to calculate area and 1 29/11/2022
Perimeter of a Circle.
Program No: 1
Program Name: C Program to calculate area and Perimeter of a Circle.
Source Code:
//C Program to calculate area and Perimeter of a Circle.
#include <stdio.h>
void main()
{
float radius, perimeter, area;
Output :
Page 2
Program No: 2
Program Name: C program to print area and perimeter of a Triangle.
Source Code:
//C program to print area and perimeter of a Triangle
#include <stdio.h>
void main()
{
int b, h, area, x,y,z, perimeter;
area = (b*h)/2;
printf("Area of the triangle = %d\n", area);
perimeter= x+y+z;
printf("Perimeter of a triangle : %d", perimeter);
}
Output :
Page 3
Program No: 3
Program Name: C Program to convert days into years months and days
Source Code:
//C Program to convert days into years months and days
#include<stdio.h>
int main()
{
int number_of_days, years, months, days;
return 0;
}
Output :
Page 4
Program No: 4
Program Name: C Program to check whether an integer entered by the user is
odd or even
Source Code:
// C Program to check whether an integer entered by the user is odd or even
#include <stdio.h>
int main()
{
int num;
return 0;
}
Output :
Page 5
Program No: 5
Program Name: C Program to find the largest number among three numbers
Source Code:
// C Program to find the largest number among three numbers
#include <stdio.h>
int main()
{
int Num1, Num2, Num3;
return 0;
}
Output :
Page 6
Program No: 6
Program Name: C Program to Find the Largest Number using Conditional
Operator
Source Code:
// C Program to Find the Largest Number using Conditional Operator
#include<stdio.h>
int main()
{
int num1,num2,max;
Program No: 7
Program Name: C Program to find the Largest among Three Variables using
Nested if.
Source Code:
//C Program to find the Largest among Three Variables using Nested if
#include <stdio.h>
int main() {
// outer if statement
if (n1 >= n2) {
// inner if...else
if (n1 >= n3)
printf("%d is the largest number.", n1);
else
printf("%d is the largest number.", n3);
}
// inner if...else
if (n2 >= n3)
printf("%d is the largest number.", n2);
else
printf("%d is the largest number.", n3);
}
return 0;
}
Output :
Page 8
Program No: 8
Program Name: C program to check leap year using conditional Operator
Source Code:
//C program to check leap year using conditional Operator
#include <stdio.h>
int main()
{
int year;
return 0;
}
Output :
Page 9
Program No: 9
Program Name: C program to check alphabets using conditional operator
Source Code:
// C program to check alphabets using conditional operator
#include <stdio.h>
int main()
{
char ch;
return 0;
}
Output :
Page 10
Program No: 10
Program Name: C program to check number is positive, negative, or zero
Source Code:
//C program to check number is positive, negative, or zero
#include <stdio.h>
int main()
{
int Num;
//Taking Input
printf("Enter the number : ");
scanf("%d", &Num);
return 0;
}
Output :
Page 11
Program No: 11
Program Name: C program to check whether entered character is vowel or
consonant.
Source Code:
//C program to check whether entered character is vowel or consonant
#include <stdio.h>
int main() {
char ch;
//Inputting Character
printf("Enter a character: ");
scanf("%c", &ch);
else
{
printf("\n %c is not an alphabet.", ch);
}
return 0;
}
Output :
Page 12
Program No: 12
Program Name: C program to check whether a character is an alphabet, digit, or
special character.
Source Code:
//C program to check whether a character is an alphabet, digit, or special character
#include <stdio.h>
int main()
{
char ch;
//Inputting character
printf("Enter any character: ");
scanf("%c", &ch);
return 0;
}
Output :
Page 13
Program No: 13
Program Name: C program to print the day name of the week
Source Code:
//C program to print the day name of the week
#include <stdio.h>
int main()
{
int weekday;
printf(" Please Enter the Day Number 1 to 7 : ");
scanf("%d", &weekday);
if (weekday == 1)
{
printf("\n Day no %d is Monday",weekday);
}
if ( weekday == 2 )
{
printf("\n Day no %d is Tuesday",weekday);
}
if ( weekday == 3 )
{
printf("\n Day no %d is Wednesday",weekday);
}
if ( weekday == 4 )
{
printf("\n Day no %d is Thursday",weekday);
}
if ( weekday == 5 )
{
printf("\n Day no %d is Friday",weekday);
}
if ( weekday == 6 )
{
printf("\n Day no %d is Saturday",weekday);
}
if ( weekday == 7 )
{
printf("\n Day no %d is Sunday",weekday);
}
else
printf("\n Please enter Valid Number between 1 to 7");
return 0;
}
Page 14
Output :
Page 15
Program No: 14
Program Name: C program to check uppercase or lowercase alphabets.
Source Code:
// C program to check uppercase or lowercase alphabets
#include<stdio.h>
int main()
{
char c;
//Inputting Character
printf ("Enter a character n :");
scanf ("%c", &c);
return 0;
}
Output :
Page 16
Program No: 15
Program Name: C program to accept two integers and check whether they are
equal or not.
Source Code:
//C program to accept two integers and check whether they are equal or not
#include <stdio.h>
int main()
{
int n1, n2;
return 0;
}
Output :
Page 17
Program No: 16
Program Name: C program to determine whether a candidate’s age is eligible for
casting a vote or not.
Source Code:
// program to determine whether a candidate’s age is eligible for casting a vote or not
#include <stdio.h>
int main()
{
int vote_age;
Program No: 17
Program Name: C program to calculate the total marks, percentage, and division
of students.
Source Code:
//C program to calculate the total marks, percentage, and division of students.
#include <stdio.h>
int main()
{
int sub1, sub2, sub3, sub4, sub5, total;
float per;
total = sub1+sub2+sub3+sub4+sub5;
per = total/5;
if(per>=80)
printf("\n Distinction");
else if(per>=60)
printf("\n First Division");
else if(per>=50)
printf("\n Seocnd Division");
else if(per>=40)
printf("\n Third Division");
else
printf("\n Fail");
return 0;
}
Output :
Page 19
Program No: 18
Program Name: C program to enter the month number and print the number of
days in a month
Source Code:
//C program to enter the month number and print the number of days in a month
#include <stdio.h>
int main()
{
int month;
printf("30 days");
}
else if(month==2)
{
printf("28 or 29 days");
}
else
{
printf("Invalid input! Please enter month number between (1-12).");
}
return 0;
}
Output :
Page 20
Program No: 19
Program Name: C program to check whether a triangle can be formed by
the given value for the angles
Source Code:
//C program to check whether a triangle can be formed by the given value for the angles
#include <stdio.h>
int main()
{
int angle1, angle2, angle3, sum;
if(sum == 180 && angle1 > 0 && angle2 > 0 && angle3 > 0)
{
printf("Triangle is valid.");
}
else
{
printf("Triangle is not valid.");
}
return 0;
}
Output :
Page 21
Program No: 20
Program Name: C program to find the sum of first 10 natural numbers.
Source Code:
//C program to find the sum of first 10 natural numbers.
#include <stdio.h>
int main()
{
int i, sum = 0;
Program No: 21
Program Name: C program to read 10 numbers from keyboard and find
their sum and average.
Source Code:
//C program to read 10 numbers from keyboard and find their sum and average.
#include <stdio.h>
int main()
{
int i,n,sum=0;
float avg;
for (i=1;i<=10;i++)
{
printf("Number-%d :",i);
scanf("%d",&n);
sum +=n;
}
avg=sum/10.0;
return 0;
}
Output :
Page 23
Program No: 22
Program Name: C program to display the pattern like right angle triangle
with a number.
Source Code:
//C program to display the pattern like right angle triangle with a number.
#include <stdio.h>
int main()
{
int i,j,rows;
for(i=1;i<=rows;i++)
{
for(j=1;j<=i;j++)
printf("%d", j);
printf("\n");
}
return 0;
}
Output :
Page 24
Program No: 23
Program Name: C program to display the pattern like right angle triangle
with an asterisk.
Source Code:
//C Program to display the pattern like right angle triangle using an asterisk.
#include <stdio.h>
int main()
{
int i,j,rows;
for(i=1;i<=rows;i++)
{
for(j=1;j<=i;j++)
printf("*");
printf("\n");
}
return 0;
}
Output :
Page 25
Program No: 24
Program Name: C program to display the n terms of odd natural number
and their sum .
Source Code:
//C program to display the n terms of odd natural number and their sum .
#include <stdio.h>
int main()
{
int i,n,sum=0;
for(i=1;i<=n;i++)
{
printf("%d ",2*i-1);
sum+=2*i-1;
}
return 0;
}
Output :
Page 26
Program No: 25
Program Name: C program to display the n terms of natural number and
their sum .
Source Code:
//C program to display n terms of natural number and their sum.
#include <stdio.h>
int main()
{
int n , i, sum = 0;
Program No: 26
Program Name: C program to display the multiplication table of a given
integer.
Source Code:
//C program to display the multiplication table of a given integer.
#include <stdio.h>
int main()
{
int n, i;