Green University of Bangladesh
Department of Computer Science and Engineering (CSE)
Faculty of Sciences and Engineering
Semester: (Fall, Year: 2021), B.Sc. in CSE (Day)
LAB REPORT NO #01
Course Title: Structure Programming
Course Code: CSE 104 Section: 212DC
Lab Experiment Name: Introduction to C program
Student Details
Name ID
1.
Lab Date : 19th October, 2021
Submission Date : 25th October, 2021
Course Teacher’s Name :
[For Teachers use only: Don’t Write Anything inside this box]
Lab Report Status
Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................
TITLE OF THE LAB EXPERIMENT:
This experiment includes an introduction to the c programming.
4. Write a C program to multiply two numbers (4 and 5) and display its product.
5. Write a C program to add two numbers (5 and 8) and display its sum like (5 + 8 =
13).
6. Write a C program to input two numbers and display those numbers.
7. Write a C Program to input two numbers as input and display its sum.
8. Write a C Program to input two numbers as input and display its product.
9. Write a C Program to input two float numbers as input and display its sum [Follow
the printing style of problem 5].
OBJECTIVES/AIM:
To be familiar with syntax and structure of C-programming.
To learn problem solving techniques using C.
Answer to the question number 4:
Procedure:
Algorithm:
1) Start the program
2) Take input a=4 ,b=5
3) Multiply both the numbers
4) Print the result.
5) End
Implementation:
#include<stdio.h>
int main()
{
int a, b, multiply;
a = 4;
b = 5;
multiply = a*b;
printf("Multiply is: %d\n", multiply);
}
Output:
Answer to the question number 5:
Procedure:
Algorithm:
1) Start the program
2) Take input a=5 ,b=8 and sum=13
3) Print the result.
4) End
Implementation:
#include<stdio.h>
int main()
{
int a, b, sum;
a = 5;
b = 8;
sum=13;
printf("5+8=: %d\n", sum);
}
Output:
Answer to the question number 6:
Procedure:
Algorithm:
1. Start the program
2. Take a, b
3. Enter the two numbers
4. print the two numbers
5. End
Implementation:
#include<stdio.h>
int main()
{
int a, b;
printf("Enter the first number:");
scanf("%d",&a);
printf("Enter the second number:");
scanf("%d",&b);
printf("The two numbers are:%d\t%d",a,b);
}
Output:
Answer to the question number 7:
Procedure:
Algorithm:
1. Start the program
2. Take input a, b,
3. Enter the two numbers
4. Sum the two numbers
5. Print the sum
Implementation:
#include<stdio.h>
int main()
{
int a, b, sum;
printf("Enter the first number:");
scanf("%d",&a);
printf("Enter the second number:");
scanf("%d",&b);
sum=a+b;
printf("The sum is:%d\n",sum);
}
Output:
Answer to the question number 8:
Procedure:
Algorithm:
1. Start the program
2. Take input a, b,
3. Enter the two numbers
4. Product the two numbers
5. Print the product
Implementation:
#include<stdio.h>
int main()
{
int a, b, product;
printf("Enter the first number:");
scanf("%d",&a);
printf("Enter the second number:");
scanf("%d",&b);
product=a*b;
printf("The product is:%d\n",product);
}
Output:
Answer to the question number 9:
Procedure:
Algorithm:
1. Start the program
2. Take input a, b,
3. Enter the two numbers
4. Product the two numbers
5. Print the product
Implementation:
#include<stdio.h>
int main()
{
float a, b, sum;
printf("Enter the first number:");
scanf("%f",&a);
printf("Enter the second number:");
scanf("%f",&b);
sum=a+b;
printf("2.36+3.36=:%.2f\n",sum);
}
Output:
Analysis and Discussion:
This experiment is the first code written in C program. The program is focused on the
syntax and structure of C programming. From this lab, I understood the basic structure
of C programming including the meaning of header files & steps of problem solving.
Hence, sum, multiplication of numbers are calculated and displayed.