CSE1002 Assessment 1 Solution
CSE1002 Assessment 1 Solution
Board
C1 C2 C3 C4 C5 C6 C7 C8
19BEC0550
C1 C2 C3 C4 C5 C6 C7 C8
R1 A B C D A B C D
R2 C D A B C D A B
R3 A B C D A B C D
R4 C D A B C D A B
R5 A B C D A B C D
R6 C D A B C D A B
R7 A B C D A B C D
R8 C D A B C D A B
CSE-1002- Problem Solving and Object-Oriented Programming
Assessment-1 A
Sr.No. Questions Marks
#include "CSE1002.h"
//#include <iostream>
using namespace std;
int main()
{
int divisor, dividend, quotient, remainder;
return 0;
}
#include "CSE1002.h"
//#include <iostream>
//#include <cmath>
int main()
{
long long n;
cout << "Enter a binary number: ";
cin >> n;
cout << n << " in binary = " << convertBinaryToDecimal(n) << " in
decimal";
return 0;
}
B.1 How many types of constant in C++? Define each type with at least three examples. 2
Primary
• Integer
• Real
• Char
Secondary
• Array
• String
• Pointer
• Union
• Structure
• Enumerator
• Class
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
int main()
{
int n;
if ( n % 2 == 0)
cout << n << " is even.";
else
cout << n << " is odd.";
return 0;
}
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
cout << "H.C.F of " << n1 << " & " << n2 << " is: " << hcf(n1,
n2);
return 0;
}
1. Encapsulation
2. Data Hiding
3. Abstraction
4. Polymorphism
5. Inheritance
#include "CSE1002.h"
//#include<iostream>
//using namespace std;
int main()
{
int n;
cout << "Factorial of " << n << " = " << factorial(n);
return 0;
}
int factorial(int n)
{
if(n > 1)
return n * factorial(n - 1);
else
return 1;
}
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
int main()
{
int n, num, digit, rev = 0;
do
{
digit = num % 10;
rev = (rev * 10) + digit;
num = num / 10;
} while (num != 0);
cout << " The reverse of the number is: " << rev << endl;
if (n == rev)
cout << " The number is a palindrome.";
else
cout << " The number is not a palindrome.";
return 0;
}
CSE-1002- Problem Solving and Object-Oriented Programming
Assessment-1 D
Sr.No. Questions Marks
Unsigned
0 to (2n-1)
Signed
-2(n-1) to (2(n-1)-1)
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
int main()
{
int n1, n2;
while(n1 != n2)
{
if(n1 > n2)
n1 -= n2;
else
n2 -= n1;
}
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
int main()
{
int n1, n2, hcf;
cout << "Enter two numbers: ";
cin >> n1 >> n2;
#include "CSE1002.h"
//#include <iostream>
//using namespace std;
int main()
{
int n, i;
cout << "Factors of " << n << " are: " << endl;
for(i = 1; i <= n; ++i)
{
if(n % i == 0)
cout << i << endl;
}
return 0;
}//