Lab 07
Lab 07
Run the following examples, see different variations of the output and show
the output
--1
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
main()
{
int numb;
cout<<endl<<endl;
cout<<endl<<setw(25)<<"Relational Operators"<<endl;
cout<<endl;
cout<<setw(20)<<"Number < 100 :"<<setw(5)<<(numb<100)<<endl
<<setw(20)<<"Number > 100 :"<<setw(5)<<(numb>100)<<endl
<<setw(20)<<"Number == 100 :"<<setw(5)<<(numb==100)<<endl
<<setw(20)<<"Number != 100 :"<<setw(5)<<(numb!=100)<<endl
<<setw(20)<<"Number <= 100 :"<<setw(5)<<(numb<=100)<<endl
<<setw(20)<<"Number >= 100 :"<<setw(5)<<(numb>=100)<<endl;
getch();
}
--2
#include<iostream.h>
#include<conio.h>
main()
{
bool var1=55, var2=-55, var3=0;
cout<<var1<<endl<<var2<<endl<<var3;
getch();
}
--3
#include<iostream.h>
#include<conio.h>
main()
{
bool var1=5;var2=3;
float var3=5.5, var4=3;
int var5=5, var6=6;
cout<<var1%var2<<endl;
cout<<var3%var4<<endl; // error here
cout<<var5%var6<endl;
getch();
}
--4
#include<iostream.h>
#include<conio.h>
main()
{
int var1=5, var2=6;
cout<<var1++<<endl;
cout<<--var1<<endl;
cout<<++var1<<endl;
cout<<var1--<<endl;
getch();
}
--5
/*The following program uses library function sqrt() to calculate the square
root of a number entered by the user.*/
main()
{
double number, answer; //sqrt() requires type double
cout << "Enter a number: ";
cin >> number; //get the number
answer = sqrt(number); //find square root
cout << "Square root is "<< answer << endl; //display it
getch();
}
--6
#include <iostream>
#include<conio.h>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double r=5.0; // radius
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE<<"This is new line";
getche();
return 0;
}
--7
#include <iostream>
#include<conio.h>
using namespace std;
#define PI 3.14159
#define NEWLINE '\n'
int main ()
{
double r=5.0; // radius
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE<<"This is new line";
return 0;
getche();
}
--8
#include <iostream>
#include<conio.h>
using namespace std;
#define PI 3.14159
int main ()
{
char NEWLINE='\n';
double r=5.0; // radius
double circle;
circle = 2 * PI * r;
cout << circle;
cout << NEWLINE<<"This is new line";
getche();
return 0;
}
Task 01
A library function, islower(), takes a single character (a letter) as an argument and returns
a nonzero integer if the letter is lowercase, or zero if it is uppercase. This function
requires the header file CTYPE.H. Write a program that allows the user to enter a letter,
and then displays either zero or nonzero, depending on whether a lowercase or uppercase
letter was entered.