RAVIANS COLLEGE OF SCIENCE PATTOKI: Question 3

Question 3

3. Write a program that generates the following output:
10
20
19

Answer: Solved by Mr WAJID
Firsth Method

#include
#include
#define ten 10
void main(void)
{
//int ten = 10; //### use this line in the place of "define"
//int second, third;
//second = 2*ten; third = second-1;
//cout<
using namespace std;

int main()
{
int var = 10;

cout << var << endl; // var is 10
var *= 2; // var becomes 20
cout << var-- << endl; // displays var, then decrements it
cout << var << endl; // var is 19
return 0;
}
BEST OF LUCK

No comments:

Post a Comment

Copyright © RAVIANS COLLEGE OF SCIENCE PATTOKI Urang-kurai