You are on page 1of 8

Bangladesh University of Business

and Technology

BUBT
Committed to Academic Excellence

Assingment No-02

Course Title: Structured Programming Language(Lab)


Course Code: CSE 102

SUBMITTED TO:
Partho Ghose SUBMITTED BY
Lecturer

Department of CSE Sadman Ishraq

Performance Date: 20/09/2022 ID:22234103212

Intake: 50th , Sec: 06


Submission Date: 18 /10/2022
Q1. Array clement Summation:

1. #include <stdio.h>
2. int main () {
3. int a[5], sum=0;
4. printf("Enter Array Elements: ");
5. for(int i=0; i<5; i++)
6. {
7. scanf("%d",&a[i]);
8. }
9. printf("Sum of Array Element: ");
10. for( int i=0; i<5; i++)
11. {
12. sum=sum+a[i];
13. }
14. printf("%d",sum);
15. return 0;
16.}

Output:
Q2. Add the value of the specified position of 2 arrays.

1. #include<stdio.h>
2. int main(){
3. int p,q,i,j,sum=0,n,m;
4. printf("enter the value of p:");
5. scanf("%d",&p);
6. printf("\nenter the value of q:");
7. scanf("%d",&q);
8. int a[p];
9. int b[q];
10. printf("\nenter the array a:");
11.for (i = 0; i < p; i++)
12.{
13. scanf("%d",&a[i]);
14.}
15. printf("\nenter the array b:");
16.for (j = 0; j < q; j++)
17.{
18. scanf("%d",&b[j]);
19.}
20. printf("\nposition of a array:");
21. scanf("%d",&n);
22. printf("\nposition of b array:");
23. scanf("%d",&m);
24.sum=a[n]+b[m];
25.printf("\nthe result of sum is :%d",sum);
26.return 0;
27.}

Output:
Q3. Array reverse to print:

1. #include<stdio.h>
2.
3. #define N 5
4. int main ()
5. {
6. int a[N];
7. printf("Enter %d integer number: \n",N);
8. for(int i=0;i<N;i++)
9. scanf("%d",&a[i]);
10. printf("Elements of array reverse: \n");
11. for(int i=N-1;i>=0;i--)
12. printf("%d\n",a[i]);
13. return 0;
Output:

Q4. Array multiplication by some value.

1. #include<stdio.h>
2. int main(){
3. int i,m,q;
4. printf("enter the length of array:");
5. scanf("%d",&q);
6. printf("\n");
7. int a[q];
8. for ( i = 0; i < q; i++)
9. {
10. scanf("%d",&a[i]);
11. }
12. for ( i = 0; i < q; i++)
13. {
14. printf("nenter the multiplication value:");
15. scanf("%d",&m);
16. printf("\n");
17.
18. a[i] = a[i]* m;
19. }
20. for ( i = 0; i < q; i++)
21. {
22. printf("%d\n",a[i]);
23. }
24.
25.}
Output:

Q5. Array division by some value.

1. #include<stdio.h>
2. int main(){
3. int i,m,q;
4. printf("enter the length of array:");
5. scanf("%d",&q);
6. printf("\n");
7. int a[q];
8. for ( i = 0; i < q; i++)
9. {
10. scanf("%d",&a[i]);
11. }
12. for ( i = 0; i < q; i++)
13. {
14. printf("\nenter the multiplication value:");
15. scanf("%d",&m);
16. printf("\n");
17.
18. a[i] = a[i] / m;
19. }
20. for ( i = 0; i < q; i++)
21. {
22. printf("%d\n",a[i]);
23. }
24.}
Output:

Q6. Array element swap:

1. #include<stdio.h>
2. int main(){
3. int a,b;
4. printf("Enter One Number A: ");
5. scanf("%d",&a);
6. printf("Enter Two Number B: ");
7. scanf("%d",&b);
8. a=a+b;
9. b=a-b;
10. a=a-b;
11. printf("a=%d\n",a);
12. printf("b=%d",b);
13. return 0;
14.}

Output:

You might also like