0% found this document useful (0 votes)
26 views

Q1: Write A Program in C++ That Takes A Number As An Input and Prints Its Multiplication Table Up To 10

The document contains 3 C++ programs: 1) A program that takes a number as input and prints its multiplication table up to 10. 2) A program that takes two numbers as input and swaps their values. 3) A program that takes two numbers as input and prints their sum. Each program includes the code with comments to explain what it is doing.

Uploaded by

F Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Q1: Write A Program in C++ That Takes A Number As An Input and Prints Its Multiplication Table Up To 10

The document contains 3 C++ programs: 1) A program that takes a number as input and prints its multiplication table up to 10. 2) A program that takes two numbers as input and swaps their values. 3) A program that takes two numbers as input and prints their sum. Each program includes the code with comments to explain what it is doing.

Uploaded by

F Rahman
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1: Write a program in C++ that takes a number as an input and prints its

multiplication table up to 10.

Solution:
#include <iostream.h>
using namespace std;
int main ()
{
int num;
cout << "Enter Number To Find Multiplication table ";
cin >> num;
for (int a = 1; a <= 10; a++)
{
cout << num << " * " << a << " = " << num * a << endl;
}
return 0;
}

e|1
Q2: Write a program in C++ that takes input and swap two numbers.

Solution:
#include < iostream.h >
using namespace std;
int main ()
{
int a;
cout << "Enter value for a: ";
cin >> a;
int b;
cout << "Enter value for b: ";
cin >> b;
cout << "Value before Swap" << endl;
cout << "The value of a is: " << a << endl;
cout << "The value of b is: " << b << endl;
int c = a;
a = b;
b = c;
cout << "Value after Swap" << endl;
cout << "The value of a is: " << a << endl;
cout << "The value of b is: " << b << endl;
return 0;
}

e|2
Q3: Write a program in C++ that takes input and print the sum of two
numbers.

Solution:
#include < iostream.h >
using namespace std;
int main()
{
int a;
cout<<"Enter the Value of a: ";
cin>>a;
int b;
cout<<"Enter the Value of b: ";
cin>>b;
int sum =a+b;
cout<<"The Sum of a and b is: "<<sum;
return 0;
}

e|3

You might also like