At the end of this lesson-
- 1. You will be able to write a program for adding two numbers.
- 2. You will be able to write a program for subtracting two numbers.
- 3. You will be able to write a program for multiplying two numbers.
- 4. You will be able to write a program for dividing two numbers.
- 5. You will be able to write a program for converting temperature from Celsius to Fahrenheit.
- 6. You will be able to write a program for converting temperature from Fahrenheit to Celsius.
- 7. You will be able to write a program for determining area of a triangle where base and height have been given.
- 8. You will be able to write a program for determining area of a triangle where three arms have been given.
- 9. You will be able to write a program for determining area of a rectangle.
- 10. You will be able to write a program for determining area of a circle.
1. A program for adding two numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int a, b, c;
printf(“ Enter Two numbers: “);
scanf(“%d %d”,&a,&b);
c = a+b;
printf("Summation = %d",c);
getch();
}
Practice: Write a program for adding five integer numbers.
2. A program for subtracting two numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int a, b, c;
printf(“ Enter Two numbers: “);
scanf(“%d %d”,&a,&b);
c = a-b;
printf("Subtraction= %d",c);
getch();
}
3. A program for multiplying two numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int a, b, c;
printf(“ Enter Two numbers: “);
scanf(“%d %d”,&a,&b);
c= a*b;
printf("Multiplication= %d", c);
getch();
}
Practice: Write a program for multiplying five integer numbers.
4. A program for dividing two numbers.
#include<stdio.h>
#include<conio.h>
main()
{
int a, b;
float c;
printf("Enter Two numbers: ");
scanf("%d %d",&a,&b);
c= a/b;
printf("Division= %f",c);
getch();
}
Practice: Write a program for determining average of five integer numbers.
5. A program for converting temperature from Celsius to Fahrenheit.
Relation among different temperature scale C/5 = F-32 / 9 = K-273 / 5
#include<stdio.h>
#include<conio.h>
main()
{
int c, f;
printf("Enter celcious temperature :");
scanf("%d",&c);
f=9*c/5+32;
printf("Ferhenheight temperature:%d”,f);
getch();
}
Practice: Write a programt for converting temperature from Celsius to Kelvin.
6. A program for converting temperature from Fahrenheit to Celsius.
Relation among different temperature scale C/5 = F-32 / 9 = K-273 / 5
#include<stdio.h>
#include<conio.h>
main()
{
int c, f;
printf("Enter Ferenheight temperature :");
scanf("%d",&f);
c=5*(f-32)/9;
printf("Celcious temperature:%d”,c);
getch();
}
Practice: Write a program for converting temperature from Fahrenheit to Kelvin.
7. A program for determining area of a triangle where base and height have been given.
Theory for determining the area of a triangle where base and height of triangle have been given, Area=1/2×base×height
#include<stdio.h>
#include<conio.h>
main()
{
int b,h;
float area;
printf("Enter Base & Height:");
scanf("%d %d",&b,&h);
area=.5*b*h;
printf("\nThe area is %.2f",area);
getch();
}
8. A program for determining area of a triangle where three arms have been given.
Theory for determining the area of a triangle where three arms of triangle are a, b and c, Area= √(s(s-a)(s-b)(s-c)) [ s= half of perimeter]
half of perimeter, s=(a+b+c)/2
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a, b, c;
float s, area;
printf("Enter three integer values:");
scanf("%d %d %d", &a,&b,&c);
s = (a + b + c)/2;
area = sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of triangle is = %f", area);
getch();
}
9. A program for determining area of a rectangle.
Theory for determining area of rectangle where length and width have been given, Area=length×width
#include<stdio.h>
#include<conio.h>
main()
{
int l,w,area;
printf("Enter the length & width: ");
scanf("%d %d",&l,&w);
area=l*w;
printf("\nThe area is %d",area);
getch();
}
Practice: Write a program for determining area of a parallelogram.
Practice: Write a program for determining area of a square.
10. A program for determining area of a circle.
Theory for determining area of a circle where radius r, Area=πr2
#include<stdio.h>
#include<conio.h>
main ( )
{
int r;
float area;
printf ("Enter integer value for radius:");
scanf ("%d", &r) ;
area = 3.1416*r*r;
printf("\n Area of circle =%f", area);
getch();
}
Lesson Evaluation-
Knowledge Based Questions:
Comprehension Based Questions:
Creative Questions:
Multiple Choice Questions:
Written by,
- Mizanur Rahman (Mizan)
- Lecturer of ICT, Shaheed Bir Uttam Lt. Anwar Girls’ College , Dhaka Cantonment
- Author at www.edupointbd.com
- Software Engineer at mands IT
- Former Lecturer of ICT, Cambrian College, Dhaka
- Email: mizanjust@gmail.com
- Cell: 01724351470