Professional Documents
Culture Documents
Chapter 3 Exercises - DD
Chapter 3 Exercises - DD
printf_s scanf_s
printf_s scanf_s
scanf scanf
scanf_s
scanf
scanf_s
{ }
product *=
product = *
count
"Count is greater than 10"
quotient divisor
quotient
123.4567
3.14159
x int 1
sum int 0
x sum sum
"The sum is: " sum
while
x
x scanf %d
y scanf %d
i 1
power 1
power x power
i 1
i y while
power printf
x y while
while (c <= 5) {
product *= c;
++c;
scanf("%.4f", &value);
if (gender == 1) {
puts("Woman");
}
else; {
puts("Man");
while z
while (z >= 0) {
sum += z;
}
if else while
x = x + 1;
x += 1;
++x;
x++;
product *= 2;
product = product * 2;
if (count > 10) {
puts("Count is greater than 10.");
}
quotient %= divisor;
quotient = quotient % divisor;
printf("%.2f", 123.4567);
123.46
printf("%.3f\n", 3.14159);
3.142
int x = 1;
int sum = 0;
sum += x; sum = sum + x;
printf("The sum is: %d\n", sum);
int main(void) {
int x = 1; // set x
int sum = 0; // set sum
scanf("%d", &x);
scanf("%d", &y);
i = 1;
power = 1;
power *= x;
++i;
while (i <= y)
printf("%d", power);
int main(void) {
printf("%s", "Enter first integer: ");
int x = 0;
scanf("%d", &x); // read value for x from user
printf("%s", "Enter second integer: ");
int y = 0;
scanf("%d", &y); // read value for y from user
int i = 1;
int power = 1; // set power
while
++c;
scanf
.4
else if else
puts
else
z while
z
0
#include <stdio.h>
int main(void) {
int x = 1;
int total = 0;
-1
+ - * / %
scanf
scanf
scanf
Enter sales in dollars (-1 to end):
Salary is: $650.00
Enter sales in dollars (-1 to end):
Salary is: $311.11
Enter sales in dollars (-1 to end):
scanf
scanf
counter
number
largest
\t printf
3 5 7 9
6 8 10 12
9 11 13 15
12 14 16 18
15 17 19 21
#include <stdio.h>
int main(void) {
int count = 1; // initialize count
#include <stdio.h>
int main(void) {
int row = 10; // initialize row
x 9 y 11 x 11 y 9
else if
{}
if else
if (x < 10)
if (y > 10)
puts("*****");
else
puts("#####");
puts("$$$$$");
if (x < 10) {
if (y > 10)
puts("*****");
}
else {
puts("#####");
puts("$$$$$");
}
if (y == 8)
if (x == 5)
puts("@@@@@");
else
puts("#####");
puts("$$$$$");
puts("&&&&&");
x=5 y=8
@@@@@
$$$$$
&&&&&
x=5 y=8
@@@@@
x=5 y=8
@@@@@
&&&&&
x=5 y=7
#####
$$$$$
&&&&&
****
****
****
****
*****
* *
* *
* *
*****
while
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * *
printf("%s", "* ");
printf("%s", " ");
puts(""); // outputs a newline
double
! ! !
! ! !