File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // This code is written for counting digits of a certain number.//
2+ #include < bits/stdc++.h>
3+ using namespace std ;
4+ int main ()
5+ {
6+ int n; // It is that required number.//
7+ int count = 0 ;
8+ cin >> n;
9+ while (n != 0 )
10+ {
11+ n = n / 10 ;
12+
13+ count++;
14+ }
15+ cout << count; // It is total number of digits//
16+ }
Original file line number Diff line number Diff line change 1+ // It shows an alternate number and alphabet pattern printing with n being the number of rows.//
2+ #include < bits/stdc++.h>
3+ using namespace std ;
4+ int main ()
5+ {
6+ int n;
7+ // n being the number of rows//
8+ cout << " The number of rows:" ;
9+ cin >> n;
10+ // user will input the value of n.//
11+ for (int i = 1 ; i <= n; i++)
12+ {
13+ for (int j = 1 ; j <= i; j++)
14+ {
15+ if (i % 2 != 0 )
16+ {
17+ cout << j; // It will print numbers in the odd row.//
18+ }
19+ else
20+ {
21+ cout << char (j + 64 ); // It will print alphabets in the even row.//
22+ }
23+ }
24+ cout << endl; // leave a line after second for loop.//
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments