Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Green University of Bangladesh

Department of Computer Science and Engineering (CSE)


Faculty of Sciences and Engineering
Semester: (Fall , Year:2022), B.Sc. in CSE (Day)

LAB REPORT NO #04


Course Title: Structure Programming Lab
Course Code: 104 Section: DA

Lab Experiment Name: Basic structure and introduction to expression to

C Student Details

Name ID

1. MD.AL-Rouman 223002036

Submission Date : 23-3-2023


Course Teacher’s Name : Fatema Akter

[For Teachers use only: Don’t Write Anything inside this box]
Lab Report Status
Marks: ………………………………… Signature:.....................
Comments:.............................................. Date:..............................

TITLE OF THE LAB EXPERIMENT


1. Write a C program to print all alphabets from a to z.
2. Write a C program to print all even number 1 to 100.
3. Write a C program to enter a number and print its digit in reverse order.
4. Write a C program to find frequency of each digit in a given integer.
5. Write a C program to find sum of first and last digit of any number.
6. Write a C program to swap first and last digits of any number.
7. Write a C program to calculate product of digits of any number.
8. Write a program in C to find the sum of the series 1 +11 + 111 + 1111 + .. n terms.

2. OBJECTIVES/AIM [1]
1. To get better idea about C variables and constants.
2. To learn about arithmetic operations in C programming.
3. To learn about getting input from console.
4. To solve some basic problems using C program.

3. IMPLEMENTATION [2]

Code of problem 01#include <stdio.h>

int main()

char ch='a';

while(ch<='z')

printf("%c\n",ch );
ch++;

return 0;

Code of problem 02 #include <stdio.h>


int main()
{
for (int i = 2; i<=100; i++)
{
if (i%2 == 0)
{
printf("%d\n", i);

}
Code of problem 03#include <stdio.h>int main()

{ int p, reverse = 0, remainder; printf("Enter an integer: ");

scanf("%d", &p);

while (p != 0){

remainder = p % 10 reverse = reverse * 10 p


printf("Reversed number = %d", reverse);

\Code of problem 04

Code of problem 05.


#include <stdio.h>

int main()

int c, sum=0, firstDigit, lastDigit;

printf("Enter number to find sum of first and last digit = ")

scanf("%d", &c);

lastDigit = c % 10;

while(c >= 10)

c = c / 10;

firstDigit = c;

sum = firstDigit + lastDigit;

printf("Sum of first and last digit = %d", sum);


return 0;

Code of problem 06#include <stdio.h>


int main()
{
int c, sum=0, firstDigit, lastDigit;
printf("Enter number to find sum of first and last digit = ");
scanf("%d", &c);

lastDigit = c % 10;

while(c >= 10)


{ c = c / 10; } firstDigit = c; sum = firstDigit + lastDigit;printf("Sum of first=
%d”,sum);
return 0;
}
Code of problem 07#include<stdio.h>
int main()
{
int num, rem, prod = 1;
printf("Enter a number: ");
scanf("%d", &num);
while(num != 0)
{
rem = num % 10;
prod *= rem;
num /= 10;
}
printf("%d", prod);
return 0;
}

Code of problem 08 #include <stdio.h>


void main()
{
int n,i;
long sum=0;
long int t=1;
printf("Input the number of terms : ");
scanf("%d",&n);
for(i=1; i<=n; i++)
{
printf("%ld ",t);
if (i<n)
{
printf("+ ");

}
sum=sum+t;
t=(t*10)+1;
}
printf("\nThe Sum is : %ld\n",sum);

Cod

e of problem 09

5. ANALYSIS AND DISCUSSION [2]

Here included all the problems that we were given was so much easy. So that there was no issue
to solve those problems. After solving those problems this helped me to improve the idea of
using variables and some arithmetic operations.So I had to make an equation. Overall this
assignment helped me to practicing .

You might also like