You are on page 1of 8

Canadian University of Bangladesh

Assessment Book
Department of Computer Science and Engineering

Quiz Progress Analysis 1 Progress Analysis 2 Final Exam

Semester………SPRING 2021……………..
Course Name …………CSE………………………… Section…………..
Student Name…SAIMA ISLAM…………… ID No.…… 21104022 ….
Student Signature………Saima Islam……..Date: …….17/04/2021..…

...................................... ………………
Examiner’s Signature Date

Instructions:

1. Do not use any unfair means. If you cheat in any form or do not follow faculty
instructions your progress analysis will be cancelled.
2. You must submit the progress analysis within the allowed timeframe.

1
CSE1102: Structured Programming Language Sessional
Spring 2021, Faculty – Dr. Faisal
Progress Analysis - 1, Marks: 10,
Submission deadline: 17/04/2021 (FIXED)
(You must answer right under the question. However, you can add extra page)

Answering guideline:

• Print this file and write your answer on the printed paper, scan the answer
script and submit the scanned version. Add extra pages when the printed space is
not sufficient.
• You may consult textbooks and online sources. However, for online sources,
make sure they are authentic sources, such as they are from journal papers,
conference papers or technical notes from well-known companies (GE, ABB,
etc.). If you give online references, please mention the sources.
• It is not allowed to consult with any person who has knowledge of this subject,
including other students of this course. You may ask question to the instructor if
you do not understand the question, but not more than that. All solutions have to
be your own work.
• Plagiarism checker will be used to verify that someone cheats or not.
• Please add short explanation of each program where applicable in questions.
Careful that, it carries marks.

CODE OF HONOR PLEDGE

I pledge on my honor that I have not given or received any unauthorized assistance
on this assignment.

Signature:_____Saima Islam_______________________

Date :________17/04/2021____________________

2
CSE1102: Structured Programming Language Sessional
Spring 2021, Faculty – Dr. Faisal
Progress Analysis - 1, Marks: 10,
Submission deadline: 17/04/2021 (FIXED)

(You must answer right under the question. However, you can add extra page)

Please read the instructions before you proceed:


• This is an open book assessment.
• However, plagiarism is strictly prohibited. We will use plagiarism checker
to ensure that every one don't copy from some others.
• Please add short explanation of each program where applicable in
questions. Careful that, it carries marks.
• If any one cheats in this assessment, he or she may be marked as zero.
Moreover, you will be scored to zero, if you are late in submitting the
assessment.

3
Progress Analysis 1
Total Marks (10)
1. Rewrite the following program (which attempts to print ALL prime factors of n) after 2.5
correcting the errors and bugs in it. Make the least possible modifications in this program.
Note: function prime(i) returns true(1) or false(0) for actual parameter of i. And, 0 and 1 is not
prime numbers.
#includ <stio.k>

void main()
{
Int i, n, i==0;

scAn("%d; n");
for(,i<2/n,i=+3);
{
if(prime(i))
if[n%prime(i)=0];
print("%d, i");
}

ANS:
#include <stdio.h>
Int main( )
{
int I, n, i==0;
printf(“enter n\n”);
scanf(“%d”, &n);

printf(“All prime factors of %d are: \n”, n);


/*check for every number between 1 to , whether it divides n*/
For (i=1; i<=1; i++)
{
//check if ‘I’ completely divides n, then it is a factor of n
If (n%i==0);
4
{ /*check if I is also a prime number */
2.5
J =0;
For (j=1; j<=i/2; j++);
{ if ( i%j= {
J =0\n;
}
}
}
Printf(“%d\n”,i);
}
Return 0;
}

5
2. Write the output of the following program and show a table that explains each iteration: 5.0
#include <stdio.h> Output:
void main()
{
int a = 6, b = 25;
for(;a <= 21; a+=3){
if(a%2==1){
b-= 3;
continue;
}
printf("a=%d,b=%d\n", a, b);
if(a>b) break;
}
printf("a=%d,b=%d\n", a, b);
}
Table:

ANS:
Output:

3. Write a program that prints the below Floyd’s triangle of n lines. For e.g. for n = 5, the
pattern looks like this and also draw the flowchart for your program.

*
++
***
++++
*****

6
Ans:
#include <stdio.h>
Int main( ) {
//n: total no. of rows
//i: currentRows
//j: currentColumn
//k: elements

Int n, I, j, k=1;
Printf(“Enter total number of rows you
want to print\n”);
Scanf(“%d”, &n);
For(i=1; i<=n; i++){
For(j=1; j<=1; j++){
Printf(“%d”, k);
k++;
Printf(“\t”);
}
Printf(“\n”);
}
Return 0;
}

7
8

You might also like