Jump to content
Sign in to follow this  
Mohamad Afiza

Sentinel-Controlled Loop.

Recommended Posts

Salam.Sesiapa boleh tolong,guna Turbo C++,terima kasih!
1.Write a sentinel-controlled loop (using a sentinel value of -1) that contains statements which input output user integer data.Do not print the number if it is either 7 or 63.

2.Write a C++ program that uses while loop to perform the following steps:
a) Prompt the user two input two integers : firstNum and secondNum. (firstNum must be less than secondNum)
B) Output all even numbers between firstNum and secondNum Edited by Mohamad Afiza

Share this post


Link to post
Share on other sites
[code]
#include <iostream>
using namespace std;

void main()
{
int num;

for (;;) {
cout<<"input integer : ";
cin>>num;

if (num==-1)
break;
else if (num==7||num==63)
continue;
else
cout<<"Your integer is "<<num<<endl;
}
}
[/code] Edited by otai_g

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...