Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

20 AIS 044 (Tonmoy Debnath)

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

University of Barishal

ASSIGNMENT

Course Title: Fundamentals of Programming

Course Code: AIS 3205

Topics : Analysis of the Flowchart

Submitted To:

Dr. Tania Islam

Assistant Professor

Department of Computer Science and


Engineering

University of Barishal

Submitted By:

Tonmoy Debnath; Roll No: 20 AIS 044

Department of Accounting and


Information Systems; Session: 2021-2022

Session: 2021-22

Date of Submission: 19-10-2023.


1.The average of three numbers:

Algorithm:

Step 0 : Start

Step 1:Input first number into variable A

Step 2: Input first number into variable B

Step 3: Input first number into variable C

Step 4:Compute sum = A+B+C

Step 5:Computelay average average=sum/3

Step 6:Display average

Step 7:End

Flowchart:
start

Input A

Input B

Input C

Sum=A+B+C

Average=sum/3

Display average

end
Programming:

#include<stdio.h>
int main()

int a,b,c,sum,average;

printf(“enter three numbers”);

scanf(“%d%d%d”,&a,&b,&c);

sum=a+b+c;

average=sum/3;

printf(“average=%d”,average);

return 0;

2.Devide one number by another and find the quotient:

Algorithm:

Step 0 : Start

Step 1:Input first number into variable a

Step 2: Input first number into variable b

Step 3:Quotient=a/b

Step 4:Display quotient

Step 5:End

Flowchart:
Star

Input A
Input B

quotient=a/b

Display quotient

End

Programming:

#include<stdio.h>

int main()

int a,b,quotient;

printf(“enter two numbers”);

scanf(“%d%d”,&a,&b);

quotient=a/b;

printf(“quotient=%d”,quotient);

return 0;

3.Find the maximum of two numbers inputs by the users:

Algorithm:
Step 0 : Start

Step 1:Input first number into variable A

Step 2: Input first number into variable B

Step 3: If A>B then

Max=A

Else

Max=B

end if

Step 4:Display max

Step 5:End

Flowchart star

Input A

Input B

No
Is Max=B
A>B?

Yes
Max=A

Display max

Programming: End

#include<stdio.h>
int main()

int a,b;

printf(“enter two numbers”);

scanf(“%d%d”,&a,&b);

if(a>b)

printf("max=%d",a);

else

printf("max=%d",b);

return 0;

4.Find the sum of the first N natural numbers where N would be input by the users:

Algorithm:

Step 0 : Start

Step 1:Input N

Step 2: I=1,sum=0

Step 4: While I<=N repeat step 5

Step 5: Sum=sum+I, I=I+1

Step 6:Display sum

Step 7:End

Flowchart: star

Input N
I=1,sum=0

Yes No
Is
I<=N?

Sum=sum+i

I=I+1

Display sum

end

Programming:

#include<stdio.h>

int main()

int n,i,sum;

printf(“enter the value of n”);

scanf(“%d%,&n);

sum=0;

for (i = 1; i <= n; i = i + 1)

sum=sum+i;

printf("total sum=%d\n", sum);

return 0;
}

5.Find the sum of only the even numbers out of N numbers input by the users:

Algorithm:

Step 0 : Start

Step 1:Input N

Step 2: i=1,sum=0

Step 4: While I<=N repeat step 5

Step 5: mod=i%2

If(mod=0)

Sum=sum+i

i=i+1

Step 6:Display sum

Step 7:End

Flowchart: star

Input N
I=1,sum=0

No
Is
I<=N?

Yes

Mod=i%2

No
Is
Yes
mod=0?

Yes

Sum=sum+i

i=i+1

Display sum

end

Programming:

#include<stdio.h>
int main()

int n,i,sum,mod;

printf(“enter the value of n”);

scanf(“%d%,&n);

sum=0;

for (i = 1; i <= n; i = i + 1)

mod=i%2

if(mod==0)

sum=sum+i;

printf("total sum=%d\n", sum);

return 0;

You might also like