Answer:
#include <iostream>
using namespace std;
void printmultiples(int n) //function to print first five multiples between 3168 and 376020
{
int a =3168,c=1;
cout<<"First five multiples of "<<n<<" are : ";
while(a%n!=0 && a<=376020) //finding first mutiple of n after 3168.
{
a++;
}
while(c<6)//printing multiples.
{
cout<<a<<" ";
a+=n;
c++;
}
cout<<endl;
}
int main() {
int t,n;
cin>>t;//How many times you want to check.
while(t--)
{
cin>>n;
printmultiples(n);//function call..
}
return 0;
}
Input:-
3
15
43
273
Output:-
First five multiples of 15 are : 3180 3195 3210 3225 3240
First five multiples of 43 are : 3182 3225 3268 3311 3354
First five multiples of 273 are : 3276 3549 3822 4095 4368
Explanation:
I have used a function to find the first five multiples of the of the numbers.The program can find the first five multiples of any integer between 3168 and 376020.In the function I have used while loop.First while loop is to find the first multiple of the integer n passed as an argument in the function.Then the next loop prints the first five multiples by just adding n to the first multiple.
In the main function t is for the number of times you want to print the multiples.In our case it is 3 Then input the integers whose multiples you want to find.
Answer:
quicksort.cpp
void quickSort(int arr[], int left, int right) {
int i = left, j = right;
int tmp;
int pivot = arr[(left + right) / 2];
/* partition */
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
};
/* recursion */
if (left < j)
quickSort(arr, left, j);
if (i < right)
quickSort(arr, i, right);
}
Answer:
I think it is the last 2 but i am not 100% sure.
Explanation:
Answer:
totally
awesome
Explanation:
You can evaluate the expressions in the statements by hand:
if (a*b!=c) evaluates to
if (2*3 != 11)
if (6 != 11)
if (true)
so the next line is executed (it prints 'totally')
Likewise, the other if statement also evaluates to true.