Write a program PyramidUp.c that reads an integer from the user and outputs the
ID: 3668596 • Letter: W
Question
Write a program PyramidUp.c that reads an integer from the user and outputs the following pattern where the number of stars at the bottom is equal to the number read. Write a program PyramidDown.c that reads an integer from the user and outputs the following pattern alternating stars and equal signs where the number of stars at the top is equal to the number read Write a program CubicRoot.c that reads four decimals from the user: a, b, c, d and tries to find if the equation ax^3 + bx^2 + cx + d = 0 has any roots in the range -100.. 100. Your program should try decimals in the given range in small steps (eg. 0.01) and evaluate the equation at every step. If the equation evaluates to 0, the program should output the corresponding value of x. Compile all programs and produce and executable with the same name as the program. Submit through the handin system your C code and the executables generated. The "handin " system has options to allow you to review your files online and to download them. You Should always verify that you submitted the correct files and they were received by the handin system. You can submit files as many times as you like for a particular assignment. Handin will only keep the last version of each file. Remember to submit your files prior to the deadline as you won't be able to use handin if the deadline has passed.Explanation / Answer
PyramidUp.c
#include <stdio.h>
int main()
{
int j, area, lines, l=0 ;
printf (" Please give number of lines you wants to print: " ) ;
scanf ( "%d", &lines ) ;
for ( j = 1; j < = lines; ++j )
{
for ( area = 1; area < = lines - j; ++area )
{
printf ( " " ) ;
}
while ( l != 2 * j-1 )
{
printf ( "* " ) ;
++l ;
}
l = 0 ;
printf ( " " ) ;
}
return 0 ;
}
PyramidDown.c
#include<stdio.h>
int main()
{
int lines, j, k, area ;
printf ( " Please give number of lines you wnats to print : " ) ;
scanf ( "%d", &lines ) ;
for ( j = lines; j > = 1; --j )
{
for ( area = 0; area < lines - i; ++area )
printf ( " " ) ;
for ( k = j; k < = 2 * j - 1; ++k )
printf ( "* " ) ;
for ( k = 0; k < j - 1; ++k )
printf ( "* " ) ;
printf ( " " ) ;
}
return 0 ;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.