Question

Question (1) Write for statements that print the following sequences of values a) 30, 20, 10,...

Question (1) Write for statements that print the following sequences of values

a) 30, 20, 10, 0, –10, –20, –30

b) 15, 23, 31, 39, 47, 55

Question (2) Write a function call it cube to find the cube of each number.

Please write this in programming C language and please explain what we are doing in each step.

2 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

#include<stdio.h>
int main()
{
int i;
for(i=30;i>=-30;i-=10) //from i=30 to -30 each time decrease i value by 10
printf("%d ",i);
}

main.c #include<stdio.h> int main() int i; for(i=30;i>=-30;i-=10) //from i=30 to -30 each time decrease i value by 10 printf(

b)

#include<stdio.h>
int main()
{
int i;
for(i=15;i<=55;i+=8) //from i=15 to 55 each time increase i value by 8
printf("%d ",i);
}

main.c #include<stdio.h> int main() 1. int i; for(i=15;i<=55;i+=8) //from i=15 to 55 each time increase i value by 8 printf(

Question 2:

#include<stdio.h>
void cube(int);//function declaration
int main()
{
int num=5; //declare a variable num
cube(num);//call function cube
}
void cube(int n)
{
int c;
c=n*n*n;
printf("Cube of %d = %d ", n , c);

}

main.c 1 #include<stdio.h> 2 void cube (int);//function declaration 3 int main() 4- { int num=5; //declare a variable num cub

Add a comment
Know the answer?
Add Answer to:
Question (1) Write for statements that print the following sequences of values a) 30, 20, 10,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT