Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 30

Name Muhammad Mudassar

Roll number 17146 BSSE (A)

Submitted to Pro. Muhammad Ahmad Aftab

RIPHA INTERNATIONAL UNIVERSITY FAISALABAD CAMPUS


Programming Fundamentals

Chapter no 1

The Context of Software Development


1.4 Exercise
1. What is a compiler?

Compiler is used to convert source code into machine code. We can say compiler
is a translator that process statements written in high-level-language and turns
these statements into machine language.

2. How is compiled code different from source code?

SOURCE CODE

Source code is written as high-level-language. It is not directly


executed by the program. Machine cannot understand source code directly.
Firstly the source code is converted into machine code and then executed by the
machine.

COMPLIED CODE

Compiled code is written in low level language. It is directly


execute by the program. Compile code is understandable for machine. So
compiled code execute the program faster. In this way the compile code is
different from source code.

3. What tool does a programmer use to produce C++ source code?

Riphah International University Faisalabad campus


A programmer is used compiler to produce C++ source code.

4. What tool(s) does a programmer use to convert C++ source code into
executable machine code?

The tools which is used to produce a C++ program is

 Editor
 Preprocessor
 Compiler
 Linker

These tools are required to convert source code into object code.

5. What does the linker do?

Linker is a program that makes an executable file. Linker combines the compiled
code or pre-compiled library code from other sources to make a complete
executable program.

6. Does the linker deal with files containing source code or machine language
code?

A compiler takes the program code and converts the source code into machine
language module (called an object file). Another specialized program called linker.
Now Linker Combines this object file with other previously compiled object files
(in particular run time modules) to create an executable file.

7. What does the preprocessor do to source code?

The preprocessor is used to include some additional library file in source code
which is more elleborate for the compiler.

Riphah International University Faisalabad campus


8. List several advantages developing software in a higher-level language has
over developing software in machine language?

 High-level-language is like a English language which is near to human while


low-level language are machine language binary language which a human
cannot understand easily.
 We can execute a program written in a high-level language on many
different types of computers with very little or practically no effort of
porting it on different computers.
 High-level languages are easy to learn because they are very similar to the
natural languages used by us in our day-to-day life.
 Writing programs in high-level languages require less time and effort, ultimately
leading to lower program preparation cost

9. How can an IDE improve a programmer’s productivity?

The integrated development environment system is designed to maximize the


programmer productivity by tight-weave components with the same user
interface the ide presents a single program where in all developments are carried
out.

10. Name a popular C++ IDE is used by programmers developing for


Microsoft Windows?

The visual studio and Eclipse are popular C++ IDE that is a fully featured IDE used
by programmers developing by Microsoft Windows.

11. Name a popular C++ IDE is used by programmers developing for Apple
macOS?

XCODE is a development IDE for developing Apple or macOS.

Riphah International University Faisalabad campus


Chapter no 2

Writing a C++ Program


Exercise 2.5
1. What preprocessor directive is necessary to use statements with
the std::cout printing stream object?
The preprocessor directive which is necessary to printing stream object is the
#include <iostream> preprocessor.

2. What statement allows the short name cout to be used instead of


std::cout?
We can also use the only cout instead of std::cout by using ‘using namespace std
at first only once time.

3. What does the name std stands for?


The std name is the abbreviation of “standard “.

4. All C++ programs must have a function named what?


All C++ program used int main () function.

5. The body of main is enclosed within what symbols?


The body of main function is enclosed with the curly braces. Like: {}

6. What operator directs information to the std::cout output stream?


The insertion operator (<<) is used to direct information to the std::cout output
stream

Riphah International University Faisalabad campus


7. Write a C++ program that prints your name in the console window?
#include <iostream>
using namespace std;
int main(){
cout<<"Muhammad Mudassar";

return 0;
}

8. Write a C++ program that prints your first and last name in the
console window. Your first name should appear on one line, and your
last names appear on the next line.
#include <iostream>
using namespace std;
int main(){
cout<<"Muhammad"<<endl<<"Mudassar";

return 0;
}

9. What other files must you distribute with your executable file so
that your program will run on a Windows PC without Visual Studio
installed?

Skiped by sir.

10. Can a single statement in C++ span multiple lines in the source
code?
Yes, we can do this with new line /n.

Riphah International University Faisalabad campus


Chapter no 3

Values and the variables


Exercise 3.7
1. Will the following lines of code print the same thing? Explain why
or why not.
std::cout << 6 << '\n';
std::cout << "6" << '\n';
No it is does not print the same thing because 1st one is the character
and the second one is the strings.so it is not print the same value.

2. Will the following lines of code print the same thing? Explain why
or why not.
std::cout << x << '\n';
std::cout << "x" << '\n';
No it is does not print the same thing because 1st one is the character
and the second one is the strings.so it is not print the same value.

3. What is the largest int available on your system?


The largest data type is “long long int”. Which is consists of 8 bytes.
4. What is the smallest int available on your system?
The “ short int“ is the smallest int variable. Which is consists of 2 bytes.

5. What is the largest double available on your system?


The largest double is “long double”. Which consist of 8 bytes.
6. What is the smallest double available on your system?
The smallest double available is “float” which is consist of 4 bytes.
7. What C++ data type represents nonnegative integers?
The unsigned integers represent the nonnegative integers.
8. What happens if you attempt to use a variable within a program,
and that variable is not declared?
In this way the compiler shows the error “The variable is not declared”.
Because the data type not store in memory.

9. What is wrong with the following statement that attempts to assign


the value ten to variable x?

10 = x;

Value always assigned from right side while variable placed at

Left side like x=10 if any mistake valued error occur.

10. Once a variable has been properly declared and initialized can its
value be changed?

Yes, we can change the value if the value is not constant. Const is a key
word that is used to fix any variable’s value.

11. What is another way to write the following declaration and


initialization?
Int x = 10;
The following ways is
Int x,
X=10;

12. In C++ can you declare more than variable in the same declaration
statement? If so, how?
Yes, we can declare more than one variable in the same statement like
int x,y,z; etc.

13. In the declaration


int a;
int b;
Do a and b represent the same memory location?
No, both variable have different memory location.
15. What can you do if a variable name you would like to use is the
same as a reserved word?
We cannot use reserved words as the variable because reserved words
have a very specific meaning in the language. if we used reserved words
as variable name so program cannot execute and gave an error.

16. Why does C++ require programmers to declare a variable before


using it? What are the advantages of declaring variables?
Because the value is stored in memory and the compiler does not show
the error that the variable is not declared. But when we didn’t declared
a variable so program cannot execute and giving error ‘variable not
declared’

17. What is the difference between float and double?


Float has 4 bytes which 6 digits precision.
Double has 8 bytes which 15 digits precision.
18. How can a programmer force a floating-point literal to be a float
instead of a double?
we can extend as the storage space of int data type is 4 bytes or 32 bits
processor we can increase the range by using long which consists of 8
bytes we can also decrease by using short int.
19. How is the value 2.45×10−5 expressed as a C++ literal?
The value 2.45×10−5 expressed as a C++ literal
as 2.5 E -5.
20. How can you ensure that a variable’s value can never be changed
after its initialization?
We can use a keyword const so that value does not change like
const int a=5.
21. How can you extend the range of int on some systems?
We can use “long” or “long long” int to increase range.
22. How can you extend the range and precision of double on some
systems?
We can use ‘long double’ to increase range and precision.
23. Write a program that prints the ASCII chart for all the values from
0 to 127?
#include <iostream>
using namespace std;
int main(){
char a;
cout<<"enter a character"<<endl;
cin>>a;
cout<<"the assci value is "<<int(a);
return 0;
}
24. Is "i" a string literal or character literal?
It is not a character literal. It is a string literal.
25. Is 'i' a string literal or character literal?
Repeated question.
26. Is it legal to assign a char value to an int variable?
No, it is not legal to assign a character value to an integer value.
27. Is it legal to assign an int value to a char variable?
No, it is not legal to assign integer value to a character value.
28. What is printed by the following code fragment?
int x;
x = 'A';
std::cout << x << '\n';
It will print the value of x which is A and the value to A character is 65
so it will print 65.
29. What is the difference between the character 'n' and the character
'\n'?
‘n’ is a character type while ‘\n’ is a new line character.
30. Write a C++ program that simply emits a beep sound when run?
#include <iostream>
using namespace std;
int main(){
cout<<"\a";
return 0;
}
Riphah International University Faisalabad campus
Chapter no 4

Expressions and Arithmetic


Exercise 4.12
1. Is the literal 4 a valid C++ expression?
Yes 4 is a valid C++ expression.

2. Is the variable x a valid C++ expression?


Yes it x is a valid C++ expression.

3. Is x + 4 a valid C++ expression?


Yes, x+4 is a valid C++ expression.

4. What affect does the unary + operator have when applied to a numeric
expression?
We use the unary + operator just for completeness. When we applied the unary
operator to a numeric expression, there is no difference between original value and
the resulting value the resulting value same as its original value of its operand.

5. Sort the following binary operators in order of high to low precedence: +, -, *,


/, %, =.
high to low precedence:
+,-

*, /, %

+,-

6. Write a C++ program that receives two integer values from the user. The
program then should print the
sum (addition), difference (subtraction), product (multiplication), quotient
(division), and remainder
after division (modulus). Your program must use only integers. Can you explain
the results it produces for all of these operations?

#include <iostream>
using namespace std;
int main()
{
int a,b,sum,substract,multiply,divided,modulus;
cout<<"enter first number";
cin>>a;
cout<<"enter second number";
cin>>b;
sum=a+b;
substract=a-b;
multiply=a*b;
divided=a/b;
modulus=a%b;
cout<<"the sum is = "<<sum<<endl;
cout<<"the substraction is = "<<substract<<endl;
cout<<"the multiplication is = "<<multiply<<endl;
cout<<"the division is = "<<divided<<endl;
cout<<"the modulus is = "<<modulus<<endl;

return 0;
}
7. Write a C++ program that receives two double-precision floating-point values
from the user. The
program then should print the sum (addition), difference (subtraction), product
(multiplication), and
quotient (division). Your program should use only integers. Can you explain the
results it produces for all these operations? What happens if you attempt to
compute the remainder after division (modulus) with double-precision floating-
point values?

#include<iostream>
using namespace std;
int main()
{
float x;
float y;
cout<<"Enter your first num = ";
cin>>x;
cout<<"Enter your second num =";
cin>>y;
cout<<x<<"+"<<y<<"="<<x+y<<endl;
cout<<x<<"-"<<y<<"="<<x-y<<endl;
cout<<x<<"*"<<y<<"="<<x*y<<endl;
cout<<x<<"/"<<y<<"="<<x/y<<endl;
return 0;
}
If we compute the remainder after division (modulus) with double-
precision floating-point values it will give us error.

8. Given the following declaration:


int x = 2;
Indicate what each of the following C++ statements would print.
(a) std::cout << "x"<< '\n';
(b) std::cout << 'x'<< '\n';
(c) std::cout << x << '\n';
(d) std::cout << "x + 1"<< '\n';
(e) std::cout << 'x'+ 1 << '\n';
(f) std::cout << x + 1 << '\n';
(a) it will print x
(b) it will print x
(c) it will print 2
(d) it will print x+1
(e) it will print 121
(f) it will print 3
10. Given the following declarations:
int i1 = 2, i2 = 5, i3 = -3;
double d1 = 2.0, d2 = 5.0, d3 = -0.5;
Evaluate each of the following C++ expressions.

(a) i1 + i2 =7
(b) i1 / i2 =0
(c) i2 / i1 =2
(d) i1 * i3 =-6
(e) d1 + d2 =7
(f) d1 / d2 =0.4
(g) d2 / d1 =2.5
(h) d3 * d1 =-1
(i) d1 + i2 =7.0
(j) i1 / d2 =0.4
(k) d2 / i1 =2.5
(l) i2 / d1 =2.5
(m) i1/i2*d1 =0.8
(n) d1*i1/i2 =0.8
(o) d1/d2*i1 =0.8
(p) i1*d1/d2 =0.8
(q) i2/i1*d1 =4
(r) d1*i2/i1 =5
(s) d2/d1*i1 =5
(t) i1*d2/d1 =5

11. What is printed by the following statement:


cout << /* 5 */ 3 << endl;
The following statement will prints the 3.
12. Given the following declarations:
int i1 = 2, i2 = 5, i3 = -3;
double d1 = 2.0, d2 = 5.0, d3 = -0.5;
Evaluate each of the following C++ expressions.
(a) i1 + (i2 * i3) =-13
(b) i1 * (i2 + i3) =4
(c) i1 / (i2 + i3) =1
(d) i1 / i2 + i3 =-3
(e) 3 + 4 + 5 / 3 =8
(f) (3 + 4 + 5) / 3 =4
(g) d1 + (d2 * d3) =-0.5
(h) d1 + d2 * d3 = -0.5
(i) d1 / d2 - d3 = 0.9
(j) d1 / (d2 - d3) = 0.3
(k) d1 + d2 + d3 / 3 = 6.8
(l) (d1 + d2 + d3) / 3 = 2.1
(m) d1 + d2 + (d3 / 3) =6.8
(n) 3 * (d1 + d2) * (d1 - d3) = 52.5

13. How are single-line comments different from block comments?


Single line comments are used only for in single line.
It is denoted by //.
The block comments are used to comment for multiple lines.
It is written as /* at the first before line and */ at the end of line.
Like. /* After the computation is completed the result is displayed. */

14. Can block comments be nested?


Never, a block statement cannot be nested.

15. Which is better, too many comments or too few comments?


We use comment only for understanding the logics. Sometimes the logic of
program are very difficult so we write a statement in comment for easily
understanding the logics.

16. What is the purpose of comments?


The purpose of comments are understanding the logics of a program when
someone open your program when we write the comment so other person
easily understand the logics of program easily.

17. The programs in Listing 3.4 (variable.cpp), Listing 4.3


(reformattedvariable.cpp), and Listing 4.4
(reformattedvariable2.cpp) compile to the same machine code and
behave exactly the same. What makes one of the programs clearly better
than the others?
Listing 3.4 (variable.cpp), is more clear than ), Listing 4.3
(reformattedvariable.cpp), The type of formatting can makes our program
more clear and more readable. Same as we see that 3.4 listening is more
clear and readable than 4.3 listening. So it mean formatting can change the
look of our program.

18. Why is human readability such an important consideration?


A. Human readability is an important consideration because by using
human readability reading, understanding and debugging of the program
easy. If code is easy to read, it will be easy to understand which makes it
easy to debug, maintain and extend.

19. Consider the following program which contains some errors. You may
assume that the comments
within the program accurately describe the program’s intended behavior .
#include <iostream>
using namespace std;
int main() {
int n1, n2, d1; // 1
// Get two numbers from the user
cin << n1 << n2; // 2
// Compute sum of the two numbers
cout << n1 + n2 << endl; // 3
// Compute average of the two numbers
cout << n1+n2/2 << endl; // 4
// Assign some variables
d1 = d2 = 0; // 5
// Compute a quotient
cout << n1/d1 << endl; // 6
// Compute a product
n1*n2 = d1; // 7
// Print result
cout << d1 << endl; // 8
}
For each line listed in the comments, indicate whether or not a compile-
time, run-time, or logic error is present. Not all lines contain an error.
Line number 6 gave the compile time error because where the operator <<
is used with cin it is wrong the correct operator is >>.
Line number 12 they gave a compile time error because d2 was not
declared.
Line number 16 is also gave us a compile time error because the value is
assigned from the right side while the value is assign from left side.

20. What distinguishes a compiler warning from a compiler error? Should


you be concerned about warnings? Why or why not?
When system gave us a compiler warning the compiler will run the
program and create an executable file and gave us a compiler warning
again. But when system gave us a compiler error then program does not
run it will not create an executable file and force us to solve the error
before preceding the program.
Yes, We should be concerned about the warning because it may gave us
wrong results.

21. What are the advantages to enhancing the warning reporting


capabilities of the compiler?
The advantages to enhancing the warning reporting capabilities of the
compiler is that When we developing the new code, it will helps us to find
errors.

22. Write the shortest way to express each of the following statements.
(a) x = x + 1;
(b) x = x / 2;
(c) x = x - 1;
(d) x = x + y;
(e) x = x - (y + 7);
(f) x = 2*x;
(g) number_of_closed_cases = number_of_closed_cases + 2*ncc;
(a) x++
(b) x /= 2;
(c) x -=1
(d) x += y;
(e) x -= (y + 7);
(f) x *= 2;
(g) number_of_closed_cases += 2*ncc;

23. What is printed by the following code fragment?


int x1 = 2, y1, x2 = 2, y2;
y1 = ++x1
y2 = x2++;
cout << x1 << " " << x2 << endl;
cout << y1 << " " << y2 << endl;
Why does the output appear as it does?
The output will be
3 3
3 2
This is because the formatting of code done to display the output.

24. Consider the following program that attempts to compute the


circumference of a circle given the radius entered by the user. Given a
circle’s radius, r, the circle’s circumference, C is given by the
formula:
C = 2pr
#include <iostream>
int main() { double C, r;
const double PI = 3.14159;
// Formula for the area of a circle given its radius
C = 2*PI*r;
// Get the radius from the user
cout >> "Please enter the circle's radius: ";
cin << r;
// Print the circumference
std::cout << "Circumference is " << C << '\n'; }

(a) The compiler issues a warning. What is the warning?


(b) The program does not produce the intended result. Why?
(c) How can it be repaired so that it not only eliminates the warning but also
removes the logic
error?

A. the warning is that wrong operator was used.

B. The program does not produce the intended result. We write cin after
the formula first we write the radius that we collect from user than we
write the formula
C. We need to change operators that used wrong in line 7 and 8 and then
correct the position of (from user taker) and the formula then program run
accurately.
Chapter no 5
Conditional Execution

Exercise 5.10
1.What values can a variable of type bool assume?

A bool type variable can assume only two types of values

 True(1)
 False(0)

2. Where does the term bool originate?

The term Boolean originates from a British mathematician George Bool.

3. What is the integer equivalent to true in C++?

When integer is equivalent to TRUE in C++ then integer is equal to 1.

4. What is the integer equivalent to false in C++?

When the integer is equivalent to FALSE in C++ then integer is equal to 0 .

5. Is the value -16 interpreted as true or false?

The value 16 will be TRUE because any non-zero integer will be taken as TRUE.

6. May an integer value be assigned to a bool variable?

Yes, we can assign an integer value to a bool variable.

7. Can true be assigned to an int variable?


YES! We can assign to an int variable.

8. Given the following declarations:


int x = 3, y = 5, z = 7;
bool b1 = true, b2 = false, b3 = x == 3, b4 = y < 3;
evaluate the following Boolean expressions:
(a) x == 3 true
(b) x < y () true
(c) x >= y false
(d) x <= y true
(e) x != y – 2 false
(f) x < 10 true
(g) x >= 0 && x < 10 true
(h) x < 0 && x < 10 false
(i) x >= 0 && x < 2 false
(j) x < 0 || x < 10 true
(k) x > 0 || x < 10 false
(l) x < 0 || x > 10 false
(m) b1 true
(n) !b1 false
(o) !b2 true
(p) b1 && b2 false

9. Express the following Boolean expressions in simpler form; that is, use fewer
operators. x is an int.
(a) !(x == 2) ans; (x!=2)
(b) x < 2 || x == 2 ans;(x<=2)
(c) !(x < y) ans;(x!<y)
(d) !(x <= y) ans;(x!<y && x!=y)
(e) x < 10 && x > 20 ans; (x<!=10 && x>!=20)
(f) x > 10 || x < 20 ans; (x>!10 || x<!=20)
(g) x != 0 ans; (x>0||x<0)
(h) x == 0 ans; (x!<0 && x!>o)

10. What is the simplest tautology?

A Boolean expression that is always true. This is the simplest tautology.

11. What is the simplest contradiction?

A Boolean expression that is always false. This is the simplest contradiction.

12. Write a C++ program that requests an integer value from the user. If the
value is between 1 and 100
inclusive, print “OK;” otherwise, do not print anything.

#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"Enter a value Between 1 to 100 = ";
cin>>x;
if(x>=1 && x<=100)
{
cout<<"ok";
}
else {
}
return 0;
}

13. Write a C++ program that requests an integer value from the user. If the
value is between 1 and 100
inclusive, print “OK;” otherwise, print “Out of range.”
#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"Enter a value Between 1 to100 = ";
cin>>x;
if(x>=1 && x<=100)
{
cout<<"OK";
}
else
{
cout<<”Out of range”;
}
return 0;
}

15. The following program attempts to print a message containing the English
word corresponding to a given integer input. For example, if the user enters the
value 3, the program should print
"You entered a three". In its current state, the program contains logic errors.
Locate the
problems and repair them so the program will work as expected.
#include <iostream>
using namespace std;
int main() {
cout << "Please in value in the range 1...5: ";
int value;
cin >> value;
// Translate number into its English word
if (value == 1)
{
cout << "You entered a";
cout << "one";
cout << endl;
}

else if (value == 2)
{

cout << "You entered a";


cout << "two";
cout << endl;
}

else if (value == 3)
{

cout << "You entered a";


cout << "three";
cout << endl;
}

else if (value == 4)
{

cout << "You entered a";


cout << "four";
cout << endl;
}

else if (value == 5)
{

cout << "You entered a";


cout << "five";
cout << endl;
}

else // Value out of range


{
cout << "You entered a";
cout << "value out of range";
cout << endl;
}

return 0;

16. Consider the following section of C++ code:

// i, j, and k are ints


if (i < j) {
if (j < k)
i = j;
else
j = k;
}
else {
if (j > k)
j = i;
else
i = k;
}
cout << "i = " << i << " j = " << j << " k = " << k << endl;

What will the code print if the variables i, j, and k have the following values?
(a) i is 3, j is 5, and k is 7
(i=5,j=5,k=7)

(b) i is 3, j is 7, and k is 5
(i=3, j=5, k=5)

(c) i is 5, j is 3, and k is 7
(i=7, j=3, k=7)

(d) i is 5, j is 7, and k is 3
(i=5, j=3, k=3)

(e) i is 7, j is 3, and k is 5
(i=5, j=3, k=5)

(f) i is 7, j is 5, and k is 3
(i=7, j=7, k=3)

17. Consider the following C++ program that prints one line of text:
#include <iostream>
using namespace std;
int main() {
int input;
cin >> input;
if (input < 10) {
if (input != 5)
cout << "wow ";
else
input++;
}
else {
if (input == 17)
input += 10;
else
cout << "whoa ";
}
cout << input << endl;
}
What will the program print if the user provides the following input?
(a) 3 (wow 3)
(b) 21 (whoa 21)
(c) 5 (6)
(d) 17 (27)
(e) -5 (wow -5)

18. Why does the following section of code always print "ByeHi"?
int x;
cin >> x;
if (x < 0);
cout << "Bye";
cout << "Hi" << endl;

Code print always "ByeHi" this is because any number we will enter here it will
be always greater than 0.

19. Write a C++ program that requests five integer values from the user. It then
prints the maximum and
minimum values entered. If the user enters the values 3, 2, 5, 0, and 1, the
program would indicate
that 5 is the maximum and 0 is the minimum. Your program should handle ties
properly; for example,
if the user enters 2, 4 2, 3 and 3, the program should report 2 as the minimum
and 4 as maximum.

#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e;
cout<<"Enter ist number = ";
cin>>a;
cout<<"Enter 2nd number = ";
cin>>b;
cout<<"Enter 3rd number = ";
cin>>c;
cout<<"Enter 4th number = ";
cin>>d;
cout<<"Enter 5th number = ";
cin>>e;

if (a>b && a>c && a>d && a> e )


cout<<a<<" a is maximum";

else if (b>c && b>d && b>e && b> a )


cout<<b<<" b is maximum";

else if (c>b && c>a && c>d && c>e )


cout<<c<<" c is maximum";

else if (d>b && d>c && d> a && d> e )


cout<<d<<" d is maximum";

else if (e>b && e>c && e>d && e>a )


cout<<e<<" e is maximum"<<endl;

if (a<b && a<c && a<d && a< e )


cout<<a<<" a is minimum";

else if (b<c && b<d && b<e && b< a )


cout<<b<<" b is minimum";

else if (c<b && c<a && c<d && c<e )


cout<<c<<" c is minimum";

else if (d<b && d<c && d< a && d< e )


cout<<d<<" d is minimum";

else if (e<b && e<c && e<d && e<a )


cout<<e<<" e is minimum";

return 0;
}

20. Write a C++ program that requests five integer values from the user. It then
prints one of two
things: if any of the values entered are duplicates, it prints "DUPLICATES";
otherwise, it prints
"ALL UNIQUE".

#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,e;
cout<<"enter ist value";
cin>>a;
cout<<"enter 2nd value";
cin>>b;
cout<<"enter 3rd value";
cin>>c;
cout<<"enter 4th value";
cin>>d;
cout<<"enter 5th value";
cin>>e;
if (a!=b && a!=c && a!=d && a!=e && b!=a && b!=c && b!=d && b!=e &&
c!=a && c!=b && c!=d && c!=e && d!=a && d!=b && d!=c && d!=e && e!=a
&& e!=b && e!=c && e!=d ){
cout<<"its all unique";
}
else
cout<<"DOUBLECATE";
}

You might also like