Using a for statement to print out every integer divisible by 5 from 1 to 50. Us
ID: 3936530 • Letter: U
Question
Using a for statement to print out every integer divisible by 5 from 1 to 50. Using a continue statement to skip priming the integers "20" and "30". Using a programmer-defined function REVERSE to take a 2-digits integer value and returns the number with its digits reversed when this integer is larger than 40. Show the results for both cases. (For example, given the number 12, the function should return 12. Given the number 45, the function should return 54.) Define two arrays x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and y = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, each of size 10, using call-by-reference (that is, use pointers), to pass the array to a function, named sum. In main: define array, pass arrays, print out the array and the results on screen In function sum: take arrays from main and sum the arrays using the formula below: sum = 3 sigma_i = 1^size-1 (x_i + 1 + x_i)(y_i + 1 + y_i - 1)Explanation / Answer
1- #include<stdio.h>
#include<conio.h>
void main()
{
int i;
for(i=1;i<=50;i++)
{
if(i%5==0)
{
if(i==20 || i==30)
{
continue;
}
else()
{printf("%d ",i);}
}}}
2- #include<stdio.h>
#include<conio.h>
void reverse(int n);
void main()
{
int i,j,temp=0,num;
int arr[2];
printf("enter a two digit number");
scnaf("%d",&num);
if(num>40)
{
reverse(num);
}
else
{
printf("%d",num);
}
void reverse(int n)
{while(n!=0){
temp=temp*10;
temp=temp+(n%10);
n=n/10;}
printf("%d",temp);}
getch();
}
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.