0% found this document useful (0 votes)
16 views3 pages

Practical 2 B

The document contains a C++ program that uses control structures like if-else statements and switch case. The program takes user input for a choice - to print a pattern, check voting eligibility, find the greatest of 3 numbers, print a word for a given number of times or exit. Based on the choice, appropriate control logic is implemented - like loops to print patterns, if-else to check age for voting, nested if-else to find greatest number etc. The program uses basic input, output and control flow statements of C++.

Uploaded by

Sairaj Borawake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views3 pages

Practical 2 B

The document contains a C++ program that uses control structures like if-else statements and switch case. The program takes user input for a choice - to print a pattern, check voting eligibility, find the greatest of 3 numbers, print a word for a given number of times or exit. Based on the choice, appropriate control logic is implemented - like loops to print patterns, if-else to check age for voting, nested if-else to find greatest number etc. The program uses basic input, output and control flow statements of C++.

Uploaded by

Sairaj Borawake
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* PRACTICAL 2 B */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* NAME : SAIRAJ BORAWAKE */

/* ENROLL NO : 2206017 */

/* DIVISION : G2 */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

/* Use Control Structure in C++ */

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

#include<iostream.h>

#include<conio.h>

void main()

int a, i, j, k, num1, num2, num3, time, age;

char word[100];

clrscr();

cout<<"\nEnter : \n\n 1) FOR PRINTING A PATTERN \n 2) AGE VERIFICATION FOR VOTING \n 3)


FINDING GREATER NUMBER BETWEEN 2 NUMBERS \n 4) FOR PRINTING ONE WORD FOR FINITE
TIME\n 5) EXIT \n\n\n ";

cin>>a;

switch(a)

case 1:

for(i=0;i<6;i++)

for(j=6;j>i;j--)

cout<<" ";

for(k=0;k<=i;k++)
{

cout<<"$ ";

cout<<"\n";

break;

case 2 :

cout<<"\nENTER YOUR AGE : ";

cin>>age;

if(age>18)

cout<<"\nYOU CAN VOTE...!";

else{

cout<<"\nYOU CAN'T VOKE :(";

break;

case 3 :

cout<<"\nENTER TWO NUMBERS : ";

cin>>num1>>num2>>num3;

if(num1>num2)

if(num1>num3)

cout<<"\n"<<num1<<"IS A GREATEST NUMBER";

else{

cout<<"\n"<<num3<<"IS A GREATEST NUMBER";

}
else if(num2>num3)

cout<<"\n"<<num3<<"IS A GREATEST NYUMBER ";

else{

cout<<"\n"<<num2<<"IS AGREATEST NUMBER";

break;

case 4 :

cout<<"\nENTER THE WORD: ";

cin>>word;

cout<<"\n HOW MANY TIMES TO PRINT : ";

cin>>time;

for(i=0;i<=time;i++)

cout<<"\n"<<word;

break;

case 5:

cout<<"\nEXIT SUCCESSFUL....!!!";

break;

default: cout<<"\n INVALID OPTION....!!!";

getch();

You might also like