Write a program that will find and print the first integer which is greater than
ID: 3813540 • Letter: W
Question
Write a program that will find and print the first integer which is greater than 1000 and is divisible by 7. Write a program to extract the fractional part of a number input by the user, using the floor() function: fractional part =number -floor(number). For example, if the user inputs 3.5, then the program outputs the fractional part 3.5 -floor(3.5)=3.5-3=0.5; and if the user inputs 7.1, then the program outputs the fractional part 7.1- floor(7.1)=7.1-7=0.1. Write a program to perform rounding on a floating point number input by the user, based on the fractional part of the number. For example, if the user inputs 2.5, then the number to be output is 3; if the user inputs 7.7, then the output is 8; if the user inputs 11.4, then the output is 11. Draft a report for each of the questions after you complete the coding, including the problem description source codes, discussion with the program output captured in screen shots, and conclusions about the lab. Please upload the lab reports to ePortfolio.Explanation / Answer
program2.c
#include<stdio.h>
int main()
{
int i, n;
for(i = 1001; ; i++)
{
if(i % 7 == 0)
{
n = i;
break;
}
}
printf(" First integer which is greater than 1000 and is divisible by 7 :: %d ",n);
return 0;
}
program3.c
#include<stdio.h>
#include<math.h>
int main()
{
float x;
printf(" Enter a number :: "),scanf("%f",&x);
printf(" The fractional part %.1f - floor(%.1f) = %.1f - %.0f = %.1f ", x, x, x, floor(x), (x - floor(x)));
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.