TheFestFever.com

Our aim is to connect students from campuses all over Delhi by making them aware of all Technical, Cultural, Management fests, workshops, Seminars organized by every college in Delhi.

Join Us Now

Program 4: Write a C++ program to print the largest even and odd number entered by the user and use 0 to terminate.

#include<iostream.h>
#include<conio.h>

void main()
{
	clrscr();
	int num,leven=0,lodd=1;
	cout<<"enter number ( 0 to terminate )";
	cout<<endl;

	do{
		cin>>num;
		if(num%2==0)
		{
			if(num>leven)
			leven=num;
		}
		else
			if(num>lodd)
				lodd=num;
	}while(num!=0);

	cout<<"\n larget even number ="<<leven;
	cout<<"\n largest odd number ="<<lodd;
	getch();
}



If you have any suggestion or found any error in the above program, then do let us know at [email protected] or just comment below.