0% found this document useful (0 votes)
1 views9 pages

Research Paper - Nolan

Uploaded by

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

Research Paper - Nolan

Uploaded by

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

/* C++ programs based on control structures

1. if
2. if else
3. nested if else
4. switch
5. condi onal operator (?::)
6. loop
i) while
ii) for
iii) do while
*/

/* // comparision of two int numbers

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

void main()
{
clrscr();

int a, b;

cout<<"Enter any two int numbers: ";


cin>>a>>b;

if(a>b)
cout<<"a is greater than b";

if(b>a)
cout<<"b is greater than a";

if(a==b)
cout<<"a and b both are equal";

getch();

*/

/*

// smallest of 4 int numbers

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

void main()
{
clrscr();
int a, b, c, d;

cout<<"Enter 4 int numbers: ";


cin>>a>>b>>c>>d;

int min = a;

if(b<min)
min = b;
if(c<min)
min = c;
if(d<min)
min = d;

cout<<"Smallest = "<<min;

getch();

}
*/

/* // even or odd

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

void main()
{
clrscr();

int num;

cout<<"Enter any int number: ";


cin>>num;

if(num % 2 == 0)
cout<<"its even number";
else
cout<<"its odd number";

getch();

*/

/*

// Leap year or not

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

void main()
{
clrscr();

int year;

cout<<"Enter any year : ";


cin>>year;

if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)


cout<<"Its a leap year";
else
cout<<"Its not leap year";

getch();

}
*/

/*
// posi ve, nega ve or zero

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

void main()
{
clrscr();

int num;

cout<<"Enter any int number: ";


cin>>num;

if(num > 0)
cout<<"Its posi ve";
else if(num < 0)
cout<<"Its nega ve";
else
cout<<"its zero";

getch();

}
*/

/*
// largest of 3 int numbers

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();

int a, b, c;

cout<<"Enter any three int numbers: ";


cin>>a>>b>>c;

if(a>b)
if(a>c)
cout<<"a is the largest";
else
cout<<"c is the largest";

else if(b>c)
cout<<"b is the largest";
else
cout<<"c is the largest";

getch();

*/

/*
// roots of quad. equa on
#include<iostream.h>
#include<conio.h>
#include<math.h>

void main()
{
clrscr();

float a, b, c, x1, x2, d; // a!=0 bx + c = 0

cout<<"Enter coefficeint a, b, c of quad. equ : ";


cin>>a>>b>>c;

if(a == 0) //if1
{
cout<<"Its linear equa on"<<endl;
x1 = -c/b;
cout<<"Value of X = "<<x1<<endl;

}
else{ // else if 1

d = b*b - 4*a*c;

if(d < 0) //if 2


cout<<"Roots are imaginary";
else // else if 2
if(d == 0) // if 3
{
cout<<"Roots are real and equal"<<endl;
x1 = x2 = -b / (2 * a);
cout<<"X1 = X 2 "<<x1;

else
{
cout<<"Roots are real and
different"<<endl;
x1 = (-b + sqrt(d)) / (2 * a) ;
x2 = (-b - sqrt(d)) / (2 * a);

cout<<"X1 = "<<x1<<" X2 = "<<x2;

getch();
}

*/

You might also like