#include<iostream.h>
#include<conio.h>
void main()
{
int j,i,k,l;
char c;
clrscr();
do
{
cout<<"Enter the number of stars in the base..";
cin>>k;
for (i=1;i<=k;i++)
{
for (j=1;j<=i;j++)
cout<<"* ";
cout<<endl;
}
cout<<"\nWant to try more..(y/n)\n";
cin>>c;
}
while(c=='y');
getch();
}
A blog containing C++ programs based on Classes, Objects and related concepts like Inheritance, Polymorphism etc.
100 Contemporary Living Room Designs
Monday, December 7, 2020
C++ program to print an lower triangle using stars.
Monday, November 9, 2020
Program to check if the given Value is of type Int in CPP
#include <iostream>
using namespace std;
bool isNumber(string s)
{
for (int i = 0; i < s.length(); i++)
if (isdigit(s[i]) == false)
return false;
return true;
}
int main() {
// Saving the input in a string
string str = "";
cout << "Enter Value.\n";
cin >> str;
// Function returns 1 if all elements
// are in range '0-9'
if (isNumber(str))
cout << "Entered Value is Integer";
// Function returns 0 if the input is
// not an integer
else
cout << "Entered Value is String";
return 0;
}
Subscribe to:
Posts (Atom)