Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Using loop plss in c++

0 votes
asked Feb 7, 2018 by Justin Apilado (390 points)
Design a program that will output the following: December 4
a.  jjjjj
jjjj
jjj
jj
j
b. 0123456789
012345678
:
0

1 Answer

0 votes
answered Feb 8, 2018 by Laxaman Pal (440 points)

A)

#include <iostream>

#include <cstdlib>

using namespace std;

int main()
{
    int ch;
    int a, b;
    float res;
    cout<<"Enter two numbers : ";
    cin>>a>>b;
    cout<<"\nEnter operation you want to perform : "<<endl;
    cout<<"\t1. Addition..."<<endl;
    cout<<"\t2. Subtraction..."<<endl;
    cout<<"\t3. Multiplication..."<<endl;
    cout<<"\t4. Division..."<<endl;
    cout<<"\t5. Exit..."<<endl;
    cout<<"Enter your choice!!!"<<endl;
    cin>>ch;
    switch(ch)
    {
        case 1: res = a+b;
                break;
        case 2: res = a-b;
                break;
        case 3: res = a*b;
                break;
        case 4: res = (float)a/b;
                break;
        case 5: cout<<"Thanks for stopping by!!!";
                exit(0);
    }
    cout<<"\n\nResult is :"<<res<<" !!!"<<endl;
    return 0;
}

B)

#include <iostream>

#include <cstdlib>

using namespace std;

int main()
{
    int i, j;
    for(i=9;i>=0;i--)
    {
        for(j=0;j<=i;j++)
        {
            cout<<j;
        }
        cout<<endl;
    }
    return 0;
}

Cheers yes

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...