Write a program to print columns of numbers: number, the Square, the Square Root
ID: 3800058 • Letter: W
Question
Write a program to print columns of numbers: number, the Square, the Square Root, and the Sine. The focus will be on printing the columns exactly as specified. INPUT/OUTPUT DESCRIPTION: The input will be: two numbers from the keyboard, a Start and End. The output will consist of words forming column headers and followed by columns of numbers lined up correctly under the column headers. ALGORITHM DEVELOPMENT: Write a comment block with your name and the assignment name. Include the three pre-processor directives that will be needed: stdio.h, stdlib.h, math.h. Write the first line and the opening brace {. Add variables as needed. Loop counters may be one letter. Other variables should be self-documenting. Use printf/scanf combinations to get your Start and End numbers. Print your column headers as shown in the Output. Use a for loop that begins with Start and endsExplanation / Answer
Here is the program:
------------------------------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int Start,End,i;
double Sine;
printf("Enter your Start Number: ");
scanf("%d",&Start);
printf(" ");
printf("Enter your End Number: ");
scanf("%d",&End);
printf(" ");
printf(" N Squared Square Root Sine ");
printf("----- ------- ----------- -------- ");
for(i=Start; i<=End; i++) {
if((double)sin(i) < 0)
printf(" %d %.0f %.3f %0.3f ",i,(double)pow(i,2),(double)sqrt(i),(double)sin(i));
else
printf(" %d %.0f %.3f %0.3f ",i,(double)pow(i,2),(double)sqrt(i),(double)sin(i));
};
return 0;
}
--------------------------------------------------------------------------------------------------------------------
PLEASE THUMBS UP IF SATISFIED ^_^
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.