‹ back to Programming C++

NotesProgramming C++ · 3 January 2016

For Loop 2

Write a program that ask user to intake two number and prints number between them

Now in this program we need two values that user , need to enter , and we should return him back in between values

#include<iostream>

using namespace std;

main()

{

cout<<“My 2nd Program”<<endl;

int input1=0;

int input2=0;

cout<<“Input value 1 : “<<endl;

cin>>input1;

cout<<“Input value 2 : “<<endl;

cin>>input2;

for(input1;input1<=input2;input1++)

{

cout<<“the number is “<<input1<<endl;

}

}

Write a program that ask user to intake two number and prints number backwards

#include<iostream>

using namespace std;

main()

{

cout<<“My thrid Program”<<endl;

int input1=0;

int input2=0;

cout<<“Input value 1 (lare value)): “<<endl;

cin>>input1;

cout<<“Input value 2 (small value ): “<<endl;

cin>>input2;

for (input1; input1 >= input2; –input1)

{

cout<<“the number is “<<input1<<endl;

}

}

First Iteration

Second Iteration

Third Iteration

Fourth Iteration

Fifth Iteration

The loop will not execute

First published on fatsup.wordpress.com ↗