0% found this document useful (0 votes)
41 views6 pages

Lab Report: Course Title Course Code

The document is a lab report submitted by Jesmin Chakma to their lecturer Md. Ansarul Islam containing remarks for two coding exercises: the first creates an array of 10 random numbers and calculates the sum using for and while loops, the second performs stack operations like push and pop on an array-implemented stack and prints the popped elements. The report contains the full code for both exercises to demonstrate the required implementations.

Uploaded by

Jesmin Chakma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views6 pages

Lab Report: Course Title Course Code

The document is a lab report submitted by Jesmin Chakma to their lecturer Md. Ansarul Islam containing remarks for two coding exercises: the first creates an array of 10 random numbers and calculates the sum using for and while loops, the second performs stack operations like push and pop on an array-implemented stack and prints the popped elements. The report contains the full code for both exercises to demonstrate the required implementations.

Uploaded by

Jesmin Chakma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Department of Computer Science and Engineering

Lab Report
Course Title: Data Structure Lab
Course Code: CSE 106
Date of submission: 15/10/20

Submitted to: Submitted by


Name: Md. Ansarul Islam Name: Jesmin Chakma
Designation: Lecturer ID: 193002078
Department: CSE Section: DC
Green University of Department: CSE
Bangladesh Green University of
Bangladesh

Remarks
1. Create an array of 10 size and assign 10 random
numbers. Now find the sum of the array using for and
while loop.

#include<stdio.h>
int main()
{
int i, Size, a[10];
int j = 0, Addition = 0;
printf("Please Enter the Size of an Array: ");
scanf("%d", &Size);
printf("\nPlease Enter Array Elements\n");
for(i = 0; i < Size; i++)
{
scanf("%d", &a[i]);
}
while(j < Size )
{
Addition = Addition + a[j];
j++;
}
printf("Sum of All Elements in an Array = %d ", Addition);
return 0;
}
2. For the following Stack operations print the popped
element for each time: The maximum size of the stack is:
3 Push(10), Push(20), Pop(), Pop(), Pop(),Push(50), Pop

#include<stdio.h>p
int arr[3];
int N=3;
int top=-1;
void push(int data)
{
if (top==N-1)
printf("overflow....\n");
else
{
top=top+1;
arr[top]=data;
}
}
void pop()
{
if (top==-1)
printf("underflow...\n");
else
{
printf("%d\n",arr[top]);
top=top-1;
}
}
int main()
{

push(10);
push(20);
pop();
pop();
pop();
push(50);
pop();
}

You might also like