Q6 (Lab2) Q5 (Lab1)

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

Q6(Lab2) Q5(Lab1)

int main()
{
int num;

cout << "Enter a five-digit number: ";
cin >> num;
cout << num / 10000 << " ";
num = num % 10000;
cout << num / 1000 << " ";
num = num % 1000;
cout << num / 100 << " ";
num = num % 100;
cout << num / 10 << " ";
num = num % 10;
cout << num << endl;
return 0;
}
Q6(Lab1)
int main()
{
int num;
num = 0;
cout << "\nnumber\tsquare\tcube\n"
<< num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
num = num + 1;
cout << num << '\t' << num * num << '\t' << num * num * num << endl;
return 0;
}
Q10(Lab2)
int main()
{
float basic_salary, gross_salary, HR, CA;
cout<<"Enter basic salary of Employee : ";
cin>>basic_salary;
HR=0.4*basic_salary;
CA=0.2*basic_salary;
gross_salary=basic_salary+HR+CA;
cout<<"Gross salary is : "<<gross_salary;
getch();
return 0;
}

Q4(lab1)
int main()
{
char symbol;
cout << "Enter a character: ";
cin >> symbol;
cout << symbol << "'s integer equivalent is "
<< static_cast< int > ( symbol ) << endl;
return 0;








int number, firstDigit, secondDigit, fourthDigit, fifthDigit;

cout << "Enter a five-digit number: ";
cin >> number;

firstDigit = number / 10000;
secondDigit = number % 10000 / 1000;
fourthDigit = number % 10000 % 1000 % 100 / 10;
fifthDigit = number % 10000 % 1000 % 10;

if ( firstDigit == fifthDigit && secondDigit == fourthDigit )
cout << number << " is a palindrome" << endl;
else
cout << number << " is not a palindrome" << endl;

return 0;

You might also like