Draw flowcharts of 03 above programs 0.5 point.
Trang 1Số hiệu: BM3/QT-PĐBCL-RĐTV Trang: 1/8
Process examination (Semester 2nd 2016-2017) Course: Introduction to C programming language
Duration time: 60 minutes (permitted documents)
Question 1: (2 points): Show results on the screen after
performing a following program:
#include <stdio.h>
void main()
{
int c = 2;
int a = -10;
float b = 4.5;
b += ++a / c;
printf("%d %f ", a, b);
}
Question 2 (2 points): Write flowchart (1 point); and show results on the screen after performing a following program ( 1 point):
#include <stdio.h>
void main() {
int a = 15, b = 5, c = 1;
if (a > b)
if (c > b)
a = b + c;
else
b = ++a - c ;
printf ("%d %d %d", a, b, c);
}
Question 3: (2 points) Read a following program:
#include <stdio.h>
void main()
{
int a, b;
scanf("%d%d", &a, &b);
int kq = (a == b);
switch (kq)
{
case 0:
printf("different !");
break;
default:
printf("equal! ");
}
}
Rewrite above program using if …else such that the
program function is not changed
Question 4 (2 points): Write Pseudocode (0.5 point); flowchart (0.5 point); and show results on the screen after performing a following program ( 1 point):
#include <stdio.h>
void main() {
int i, a = 0;
for (i = 1; i < 20; i++)
if (i % 3 != 0)
a += i +1;
else
break; printf("%d %d", ++a, i );
}
Question 5 (2 points): Show results on the screen after performing a following program (0.5 point):
#include <stdio.h>
void main()
{
int i = 0, a = 4;
do
{
a += i;
i++;
} while (i < 6 && a < 13);
printf("%d %d", a, i);
}
Rewrite the above program using: a) While (0.5 point); b) For (0.5 point)
Draw flowcharts of 03 above programs (0.5 point)
Trang 2Số hiệu: BM3/QT-PĐBCL-RĐTV Trang: 2/8