0% found this document useful (0 votes)
17 views5 pages

Lab 07

Here is a program that uses the islower() function to check if a character entered by the user is lowercase or uppercase: #include <iostream> #include <ctype.h> using namespace std; int main() { char ch; cout << "Enter a letter: "; cin >> ch; if(islower(ch)) cout << "Nonzero\n"; else cout << "Zero\n"; return 0; } Task 02 A library function, isdigit(), takes a single character as an argument and returns a nonzero integer if the character is a digit (0-9), or zero if it is not a digit.

Uploaded by

Naveed Iqbal
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)
17 views5 pages

Lab 07

Here is a program that uses the islower() function to check if a character entered by the user is lowercase or uppercase: #include <iostream> #include <ctype.h> using namespace std; int main() { char ch; cout << "Enter a letter: "; cin >> ch; if(islower(ch)) cout << "Nonzero\n"; else cout << "Zero\n"; return 0; } Task 02 A library function, isdigit(), takes a single character as an argument and returns a nonzero integer if the character is a digit (0-9), or zero if it is not a digit.

Uploaded by

Naveed Iqbal
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/ 5

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<<"Enter number: ";


cin>>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.*/

#include <iostream> //for cout, etc.


#include <cmath> //for sqrt()
#include<conio.h>
using namespace std;

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.

You might also like