C++ program that generates output as 5 10 9.

Q33. Write a program that generates the following output:

        5

        10

        9

Assign value 5 to a variable using =. Multiply it with 2 to generate 10 and subtract 1 to generate 9.

Ans.

#include<iostream.h>

#include<conio.h>  //for clrscr()

void main()

{

int value;

value=5;

clrscr();   //for clear screen

cout<<“\n “<<value;

value=value*2;

cout<<” “<<value;

value=value-1;

cout<<” “<<value;

}

 

Output

5 10 9

Leave a Reply

Your email address will not be published. Required fields are marked *

690 Views
%d bloggers like this: