loops2-assignmentfinal
loops2-assignmentfinal
#include <bits/stdc++.h>
using namespace std;
int main() {
while ('1' < '2')
cout << "In while loop" << endl;
}
#include <bits/stdc++.h>
using namespace std;
int main( ) {
int t = 10;
while (t /= 2) {
cout << "Hello" << endl;
}
}
#include <bits/stdc++.h>
using namespace std;
int main( ) {
for (int x = 1; x * x <= 10; x++)
cout << "In for loop" << endl;
}
Predict the output
#include <bits/stdc++.h>
using namespace std;
int main( ) {
int x = 10, y = 0 ;
while ( x >= y ) {
x-- ;
y++ ;
cout << x << " " << y << endl ;
}
}
WAP to print the sum of all the even digits of a given number.
Sample Input : 4556
Output: 10
24
120
720
5040
40320
362880
3628800
Output :
1 1 2 3 5 8 13 21 34 55
Write a program to print out all Armstrong numbers between 1 and 500. If the sum of cubes of
each digit of the number is equal to the number itself, then the number is called an Armstrong
number. For example, 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
Output :
153
370
371
407
Note:- Please try to invest time doing the assignments which are necessary to build a strong
foundation. Do not directly Copy Paste using Google or ChatGPT. Please use your brain .