#include<iostream>
#include<vector>
#include<string>
#include<random>
#include<ctime>
void print_pyramid (const std::vector<int>& v)
{
size_t tiers {v.size()}, spaces {1}, row {1};
while (tiers > row)
{
tiers -= row++;
++spaces;
}
tiers = spaces + 1;
std::vector<int>::const_iterator i=v.begin();
for (size_t tier=0; tier!=tiers; ++tier)
{
if (spaces)
std::cout << std::string(spaces--,'\t');
for (size_t num=0; num!=tier && i!=v.end(); ++num)
std::cout << *i++ << "\t\t";
std::cout << std::endl;
}
}
int main()
{
std::default_random_engine generator ((unsigned)time(0));
std::uniform_int_distribution<int> distribution (1,100);
for (size_t loop=0; loop!=5; ++loop)
{
size_t max = distribution (generator);
std::vector<int> v;
v.reserve (max);
for (size_t i=0; i!=max; ++i)
v.push_back (distribution (generator));
print_pyramid (v);
}
}
#include<conio.h>
#include<stdio.h>
main()
{
int n,i,j;
printf("\n ntr n value");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
getch();
}
printf ("x")
unsigned count = 0;unsigned num=1; do { std::cout << num << std::endl; num +=2; } while (++count<50);
You can not print your name in C without a semi colon because according to the rules of C every statement should end with a semi colon.In fact without the semi colon it fails to be a valid C statement.
#include
std::cout<<"computer"<<std::endl;
how do we use loops in c plus plus programing and what are basic differences between do,for and while loop
C++ has no print option. The print option in your IDE allows you to print your C++ source code, thus giving you a "hard" copy of your code.
printf();
bghjg
No.
Write a function that print a triangle of stars.
console.wrikerle("""");
123454321
#include <iostream> int main() { for(int i=51; i <= 100; i+=2) { cout << i << endl; } return 0; }
printf ("x")
sum = a + b + c;
unsigned count = 0;unsigned num=1; do { std::cout << num << std::endl; num +=2; } while (++count<50);