Answer to Question #153115 in C++ for Sobia Maqbool

Question #153115

1.      Write a program that displays product of all odd numbers from 1 to 10 using for loop1.      Write a program that displays product of all odd numbers from 1 to 10 using for loop



1
Expert's answer
2020-12-31T11:07:07-0500







#include<iostream.h>

int main(){
    // declare variable i to count and increment by 2 from each odd number starting from one
    //declare variable productto store each product.
    //desplay odd numbers and products
    int product=1;
    for(int i=1;i<=10;i=i+2){
        product=product*i;
        cout<<"odd numbers="<<i<<"\tproduct="<<product<<endl;
    
    
    }




return 0;}



















Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog