Need someone can do the coding in language c -- 3
Budget: $10 – $30 USD
project 1
Write a program called hourglass.c that prompts the user to enter an integer n and prints an nxn pattern containing an hourglass. This hourglass will contain positive integers that decrease from the middle, all surrounded by hyphens "-".
Please enter a size: 9
- - - - - - - - -
- 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 - -
- - - 3 3 3 - - -
- - - - 4 - - - -
- - - 3 3 3 - - -
- - 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 -
- - - - - - - - -
You can assume n is odd and >= 3.
Make your program match the examples below exactly.
This exercise is designed to give you practice with while loops and if statements. Do not use arrays for this exercise!
Note: you are not permitted to use an array in this exercise.
./hourglass
Please enter a size: 3
- - -
- 1 -
- - -
./hourglass
Please enter a size: 7
- - - - - - -
- 1 1 1 1 1 -
- - 2 2 2 - -
- - - 3 - - -
- - 2 2 2 - -
- 1 1 1 1 1 -
- - - - - - -
./hourglass
Please enter a size: 15
- - - - - - - - - - - - - - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 2 2 2 2 2 2 - -
- - - 3 3 3 3 3 3 3 3 3 - - -
- - - - 4 4 4 4 4 4 4 - - - -
- - - - - 5 5 5 5 5 - - - - -
- - - - - - 6 6 6 - - - - - -
- - - - - - - 7 - - - - - - -
- - - - - - 6 6 6 - - - - - -
- - - - - 5 5 5 5 5 - - - - -
- - - - 4 4 4 4 4 4 4 - - - -
- - - 3 3 3 3 3 3 3 3 3 - - -
- - 2 2 2 2 2 2 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - - - - - - - - - - - - - -
./hourglass
Please enter a size: 25
- - - - - - - - - - - - - - - - - - - - - - - - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - -
- - - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - - -
- - - - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 - - - -
- - - - - 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 - - - - -
- - - - - - 6 6 6 6 6 6 6 6 6 6 6 6 6 - - - - - -
- - - - - - - 7 7 7 7 7 7 7 7 7 7 7 - - - - - - -
- - - - - - - - 8 8 8 8 8 8 8 8 8 - - - - - - - -
- - - - - - - - - 9 9 9 9 9 9 9 - - - - - - - - -
- - - - - - - - - -1010101010 - - - - - - - - - -
- - - - - - - - - - -111111 - - - - - - - - - - -
- - - - - - - - - - - -12 - - - - - - - - - - - -
- - - - - - - - - - -111111 - - - - - - - - - - -
- - - - - - - - - -1010101010 - - - - - - - - - -
- - - - - - - - - 9 9 9 9 9 9 9 - - - - - - - - -
- - - - - - - - 8 8 8 8 8 8 8 8 8 - - - - - - - -
- - - - - - - 7 7 7 7 7 7 7 7 7 7 7 - - - - - - -
- - - - - - 6 6 6 6 6 6 6 6 6 6 6 6 6 - - - - - -
- - - - - 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 - - - - -
- - - - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 - - - -
- - - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - - -
- - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - - - - - - - - - - - - - - - - - - - - - - - -
project 2
Write a program called loop_sum.c that reads an integer n from standard input, and then scans in n integers from standard input, adds them together, then prints the sum.
You can assume that n is non-negative (≥ 0).
You can assume that you are given exactly n+1 integers.
You can assume that scanf succeeds (you do not need to check for errors).
Make your program match the examples below exactly.
Note: you are not permitted to use an array in this exercise.
dcc loop_sum.c -o loop_sum
./loop_sum
How many numbers: 2
1
2
The sum is: 3
How many numbers: 3
-3
4
13
The sum is: 14
How many numbers: 5
-2
-1
0
1
2
The sum is: 0
Write a program called hourglass.c that prompts the user to enter an integer n and prints an nxn pattern containing an hourglass. This hourglass will contain positive integers that decrease from the middle, all surrounded by hyphens "-".
Please enter a size: 9
- - - - - - - - -
- 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 - -
- - - 3 3 3 - - -
- - - - 4 - - - -
- - - 3 3 3 - - -
- - 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 -
- - - - - - - - -
You can assume n is odd and >= 3.
Make your program match the examples below exactly.
This exercise is designed to give you practice with while loops and if statements. Do not use arrays for this exercise!
Note: you are not permitted to use an array in this exercise.
./hourglass
Please enter a size: 3
- - -
- 1 -
- - -
./hourglass
Please enter a size: 7
- - - - - - -
- 1 1 1 1 1 -
- - 2 2 2 - -
- - - 3 - - -
- - 2 2 2 - -
- 1 1 1 1 1 -
- - - - - - -
./hourglass
Please enter a size: 15
- - - - - - - - - - - - - - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 2 2 2 2 2 2 - -
- - - 3 3 3 3 3 3 3 3 3 - - -
- - - - 4 4 4 4 4 4 4 - - - -
- - - - - 5 5 5 5 5 - - - - -
- - - - - - 6 6 6 - - - - - -
- - - - - - - 7 - - - - - - -
- - - - - - 6 6 6 - - - - - -
- - - - - 5 5 5 5 5 - - - - -
- - - - 4 4 4 4 4 4 4 - - - -
- - - 3 3 3 3 3 3 3 3 3 - - -
- - 2 2 2 2 2 2 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - - - - - - - - - - - - - -
./hourglass
Please enter a size: 25
- - - - - - - - - - - - - - - - - - - - - - - - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - -
- - - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - - -
- - - - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 - - - -
- - - - - 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 - - - - -
- - - - - - 6 6 6 6 6 6 6 6 6 6 6 6 6 - - - - - -
- - - - - - - 7 7 7 7 7 7 7 7 7 7 7 - - - - - - -
- - - - - - - - 8 8 8 8 8 8 8 8 8 - - - - - - - -
- - - - - - - - - 9 9 9 9 9 9 9 - - - - - - - - -
- - - - - - - - - -1010101010 - - - - - - - - - -
- - - - - - - - - - -111111 - - - - - - - - - - -
- - - - - - - - - - - -12 - - - - - - - - - - - -
- - - - - - - - - - -111111 - - - - - - - - - - -
- - - - - - - - - -1010101010 - - - - - - - - - -
- - - - - - - - - 9 9 9 9 9 9 9 - - - - - - - - -
- - - - - - - - 8 8 8 8 8 8 8 8 8 - - - - - - - -
- - - - - - - 7 7 7 7 7 7 7 7 7 7 7 - - - - - - -
- - - - - - 6 6 6 6 6 6 6 6 6 6 6 6 6 - - - - - -
- - - - - 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 - - - - -
- - - - 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 - - - -
- - - 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 - - -
- - 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 - -
- 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -
- - - - - - - - - - - - - - - - - - - - - - - - -
project 2
Write a program called loop_sum.c that reads an integer n from standard input, and then scans in n integers from standard input, adds them together, then prints the sum.
You can assume that n is non-negative (≥ 0).
You can assume that you are given exactly n+1 integers.
You can assume that scanf succeeds (you do not need to check for errors).
Make your program match the examples below exactly.
Note: you are not permitted to use an array in this exercise.
dcc loop_sum.c -o loop_sum
./loop_sum
How many numbers: 2
1
2
The sum is: 3
How many numbers: 3
-3
4
13
The sum is: 14
How many numbers: 5
-2
-1
0
1
2
The sum is: 0