C++ basic input output


1.Star pattern with simple input output 



#include<iostream>
using namespace std;
int main()
{
  cout<<"*\n"<<"**\n"<<"***\n"<<"****\n"<<"*****\n"<<endl;
  return 0;
}

Output:















2.Character input output




#include <iostream>
using namespace std;
int main()
{
    char name[50];
    cout<<"Enter name:";
    cin>>name;
    cout<<"Hello "<<name<<"!";
    return 0;
}


Output:















3.Simple input output


#include <iostream>
using namespace std;
int main()
{
    int x;
    int y;
    float z;
    x=10;
    y=15;
    z=12.6;
    cout<<x<<" "<<y<<" "<<z<<endl;
    return 0;
}


Output:











4.Ascnding & descending with simple input output




#include <iostream>
using namespace std;
int main()
{
    int valu1;
    int valu2;
    int valu3;
    cout<<"Enter num:"<<endl;
    cin>>valu1>>valu2>>valu3;
    cout<< "Asending num:"<<valu1<<" "<<valu2<<" "<<valu3<<endl;
    cout<<"Dsending num:"<<valu3<<" "<<valu2 <<" "<<valu1<<endl;

return 0;
}

Output:

























Comments

Popular posts from this blog

Simple class example of c++ for beginners

A simple class:This example contains a class and two objects of that class.The program demonstrates the syntax and general features of classes in c++.