+ 4
.. How to write code to print : 1 12 123 1234 12345
Plz i need help i'm beginner ☺️
19 Respuestas
+ 6
#include<iostream>
using name space std;
int main()
{
int n;
cin>>n; // n==5
for(int i=1;i<n;i++)
{
for(int j=1;j<=i;j++)
{
cout<<j<<" ";
}
cout<<endl;
}
return 0;
}
+ 4
C++ with single loop:
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
string s = "";
for (int x=1; x<=5; x++) {
stringstream ss;
ss << s << x;
ss >> s;
cout << s << endl;
}
return 0;
}
+ 2
I will try to write code now
+ 1
Do you know the concept of loops or pattern ?
If no then,
If you see the number of columns=number of rows
And make a counter which increases every column and turns 0 when a row is finished
+ 1
Mohamed Elamin
Try to understand the logic
Even programming language is changed logic remain the same right
In C printf
In CPP cout
In JAVA System.out.println(””);
In PYTHON print()
Method name is changing but logic will be same
+ 1
Mohamed Elamin
Please check and kindly let me know
If any problem
+ 1
Thanks for you 💙👍
+ 1
#include<stdio.h>
printf("%d",1);
printf("%d",12);
printf("%d",123);
printf("%d",1234);
printf("%d",12345);
Simple way - hard-coding 🌞
0
Today is the first lecture in the loop (if) can i coding it just by if loop?
0
#include<iostream.h>
#include<conio.h>
int main()
{
int i, j;
clrscr();
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
cout<<j<<” “;
cout<<endl;
}
getch();
return 0;
}
The above code will generate your requested output
0
{
printf(”%d “,j);
printf(””);
}
This 👆How it in c++??
0
Martin Taylor
It will execute in Linux compiler also
0
#include <iostream>
using namespace std;
int main() {
int i,j;
for (i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
cout<<j;
cout<<"\n";
}
}
0
#include <iostream>
using namespace std;
int main() {
int n;
cout<<"Enter value of n"<<endl;
cin>>n;
int i=1;
while(i<=n)
{
int j=1;
while (j<=i)
{
cout<<j;
j=j+1;
}
cout<<endl;
i=i+1;
}
}
0
Martin Taylor
You mean
Loops
Arrays
Strings
Functions
Pointers
Way of programming and syntax has everything changed after turboc compiler
Kindly let me know
0
#include<stream>
- 1
Oneliner 😉
for i in ("1","12","123","1234","12345"): print(i)
- 1
printf("%d",1);
printf("%d",1)
printf("%d",1)
printf("%d",1)
printf("%d",1)
- 5
Idk😁