Loops in C++
(While Loop)
Q1. write a program in C++. your program should print all the numbers from 0-100 on the console screen?

Q2. write a program in C++. your program should print the the table of 2?

Q3. write a program in C++. your program should print the sum of all firs 0-100 numbers on the console?

Q4. what will be the output of the program:
while( 1&& (1||(-100)))
{
    cout<<"Good"<<endl;
}

Q5. write a program in C++ to print the sum of all even numbers?

For help:
                    Help Me 


48 Comments

  1. #include
    using namespace std;
    int main()

    {
    int a=0;

    while(a<100)
    {
    cout<<"the number is"<<a;

    a=a+1;
    }
    system("pause");


    }

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Q1
    #include
    using namespace std;
    int main()
    {
    int num=0;
    while (num<=100)
    {
    cout<
    using namespace std;
    int main()
    {
    int multipleir=1;
    while (multipleir<=10)
    {
    cout<<"2 x "<
    using namespace std;
    int main()
    {
    int num=0;
    int sum=0;
    while (num<=100)
    {
    sum=sum+num;
    num++;
    }
    cout<<"The Sum of First 0-100 numbers is "<
    using namespace std;
    int main()
    {
    int num=0;
    int sum=0;
    while (num<=20)
    {
    sum=sum+num;
    num=num+2;
    }
    cout<<"The sum of First 10 Even Numbers is "<<sum<<endl;
    return 0;
    }

    ReplyDelete
  4. #include
    using namespace std;
    int main()

    {
    int a,b;
    a=2,b=1;
    while(b<=10)
    {
    cout<<a<<"*"<<b<<"="<<a*b<<endl;
    b++;
    }
    system("pause");
    return 0;
    }

    ReplyDelete
  5. #include
    using namespace std;
    int main()
    {
    int a=0;


    while(a<=100)
    {
    cout<<"a";
    a++;
    }

    system("pause");
    return 0;
    }

    umairilyas853@gmail.com
    cms no. 405837

    ReplyDelete
  6. #include
    using namespace std;
    int main()

    {
    int a=0,b=0;
    while(a<=100)
    {
    b=a+b;
    a++;
    }
    cout<<b<<endl;
    system("pause");
    return 0;
    }

    ReplyDelete
  7. #include
    using namespace std;
    int main()

    {
    int a=10,b=0;
    while(a<=20)

    {
    b=a+b;
    a++;

    }
    cout<<b<<endl;

    system ("pause");
    return 0;
    }

    ReplyDelete
  8. #include
    using namespace std;
    void main()
    {
    int a=0;
    while(a<=100)
    {
    cout<<a<<endl;
    a++;
    }
    system("pause");
    }

    Muhammad Bilal
    Section A2
    CMS # 406670

    ReplyDelete
  9. #include
    using namespace std;
    void main()
    {
    int a=0;
    while(a<=100)
    {
    cout<<a<<endl;
    a++;
    }
    system("pause");
    }

    Muhammad Bilal
    Section A2
    CMS # 406670

    ReplyDelete
  10. unlimited time good
    Name :Muhammad Wasif Nazir
    section:BSCS section A1
    CMS NO.406084.

    ReplyDelete
  11. #include
    using namespace std;
    void main()
    {
    int a=2,b=1;
    while(b<=10)
    {
    cout<<a<<"*"<<b<<"="<<a*b<<endl;
    b++;
    }
    system("pause");
    }

    Muhammad Bilal
    Section A2
    CMS # 406670

    ReplyDelete
  12. #include
    using namespace std;
    void main()
    {
    int a=0,b=0;
    while(a<=100)
    {
    b=a+b;
    a++;
    }
    cout<<"Sum of first 100 num is = "<<b<<endl;
    system("pause");
    }

    Muhammad Bilal
    Section A2
    CMS # 406670

    ReplyDelete
  13. the output of the program is
    unlimited times Good

    ReplyDelete
  14. #include
    using namespace std;
    void main()
    {
    int a=10,b=0;
    while(a<=20)
    {
    if(a%2==0)
    {
    b=a+b;
    }
    a++;
    }
    cout<<"Sum of 10 to 20 even numbers = "<<b<<endl;
    system("pause");
    }

    Muhammad Bilal
    Section A2
    CMS # 406670

    ReplyDelete
  15. OUTPUT "GOOD" IS DISPLAYED INFINITY TIMES
    MUHAMMAD AAMIR SHABBIR
    CMS: 406125
    SECTION A1

    ReplyDelete
  16. you all guys should mention your name and cms with your code and please comment Question 4 output Question till 11:59 pm

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. #include
    using namespace std;
    void main()
    {
    int a=0;
    while(a<=100)
    {
    cout<<a<<endl;
    a++;
    }
    system("pause");
    }

    Muhammad Sheraz
    CMS 405646

    ReplyDelete
  19. #include
    using namespace std;
    int main ()
    {
    int a=0;
    while( 1&& (1||(-100)))
    {
    cout<<"Good"<<endl;
    }
    getchar();


    return 0;
    }




    Muhammad Dawood
    405909

    ReplyDelete
  20. the output displayed
    QNO 4;


    "GOOD"............

    many time print i dont count this

    AQEEL EJAZ
    405875

    ReplyDelete
  21. This comment has been removed by the author.

    ReplyDelete
  22. #include
    using namespace std;
    int main()
    {
    int a;
    cout<<"enter any number"<>a;
    while(1&&(1||(-100)))
    {
    cout<<"Good"<<endl;
    }
    system ("pause");
    return 0;
    }
    unlimited time Good
    Ahtsham Malik(A1)
    BSCS

    ReplyDelete
  23. Question no 1=
    #include
    using namespace std;
    int main()
    {
    int a=0;
    cin>>a;
    while(a<=100)
    {
    cout<<a<<endl;
    a=a+1;
    }
    system ("pause");
    return 0;
    }

    ReplyDelete
  24. #include
    using namespace std;
    int main()
    {


    int a=0;

    while (a<100)

    {cout<<"The No. is:"<<a<<endl;

    a++;


    }


    system("pause");

    return 0;


    }

    By: M. Fahad Abid
    CMS NO:405998

    ReplyDelete
  25. #include
    using namespace std;
    int main()
    {
    int a=0;
    while (a<100)
    {
    cout<<"The No. is:"<<a<<endl;
    a++;
    }


    system("pause");

    return 0;

    }
    Name: Mujeeb ur Rahman
    CMS NO: 407191

    ReplyDelete
  26. "#include
    using namespace std;
    int main()
    {
    int loopindex=0,sumofall=0,summofeven=0;

    cout<<"Q#1 ...."<<endl;

    while(loopindex<=100)
    {
    sumofall=loopindex+sumofall;
    cout<<","<<loopindex;
    if (loopindex%2 == 0)
    {
    summofeven=loopindex+summofeven;
    }
    loopindex++;
    }

    cout<<endl<<endl<<"Q#2 ...."<<endl;

    loopindex=1;
    while(loopindex<=10)
    {
    cout<<"2 x "<<loopindex << " = "<< 2*loopindex <<endl;
    loopindex++;
    }

    cout<<endl<<"Operation on Numbers [ 0 - 100 ] "<<endl<<endl;
    cout<<"Q#3 The Sum Of All Numbers : "<<sumofall<<endl;
    cout<<endl<<"Q#4 Good will print on every line, infinite time."<<endl;
    cout<<endl<<"Q#5 The Sum Of Even Numbers: "<<summofeven<<endl;

    system ("pause");
    return 0;
    }"
    Name: Muhammad Umer

    ReplyDelete
  27. Name::Ahsan Waheed
    Section::A
    Cms#::406147

    Q#1,
    #include
    using namespace std;
    Int main()
    {
    Int a=0;
    While (a<100)
    {
    Cout<
    using namespace std;
    Int main()
    {
    Int a=2;
    Int b=1;
    While (b<=20)
    {
    Cout<
    using namespace std;
    Int main()
    {
    Int a=0;
    While (a<=10)
    {
    If (a%2==0)
    a=a+1; }
    Cout<<a<<endl;
    System("pause");
    Return 0;
    }

    ReplyDelete
  28. Q#4
    Code will run and output"Good"...
    Name:: Ahsan Waheed
    Cms#:: 406147

    ReplyDelete
  29. #include
    using namespace std;
    void main()
    {
    int a=0;
    while(a<=100)
    {
    cout<<a<<endl;
    a++;
    }
    system("pause");
    }
    Huzaifa khalid
    CMS 406172
    section A2

    ReplyDelete
  30. "Good" will continue till infinity appear on console screen.
    by M SAMEER SOHAIL (406423)

    ReplyDelete
  31. Lab Assignment:4

    Q1. write a program in C++. your program should print all the numbers from 0-100 on the console screen?

    Solution:




    #include
    using namespace std;

    int main()
    {
    int a=1;

    while (a <= 100)
    {
    cout << a << "\n";

    a++;
    }

    return 0;

    }



    Q2. write a program in C++. your program should print the the table of 2?


    Solution:


    #include
    using namespace std;


    int main()
    {
    int counter = 1;
    int input;

    cout << "Enter an integer: ";
    cin >> input;

    cout << endl;

    while (counter < 11)
    {

    cout << input << "x" << counter << "= " << input * counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }



    Q3. write a program in C++. your program should print the sum of all firs 0-100 numbers on the console?

    Solution:

    #include
    using namespace std;


    int main()
    {
    int counter = 1;
    int input=1;

    cout << endl;

    while (counter <= 99)
    {

    cout << input << "+" << counter << "= " << input + counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }



    Q4. what will be the output of the program:
    while( 1&& (1||(-100)))
    {
    cout<<"Good"<
    using namespace std;


    int main()
    {
    int counter = 0;
    int input = 2;

    cout << endl;

    while (counter >=0)
    {

    cout << input << "+" << counter << "= " << input + counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }


    JAWAD AHMED-1A-1

    406285

    ReplyDelete
  32. Q NO 4:-"GOOD" will continue till infinity.
    Huzaifa Khalid
    CMS 406172

    ReplyDelete
  33. Q#4.output:
    "good" will show unlimited times.
    Sarmad Hassan
    CMS#406324
    Section A2

    ReplyDelete
  34. #include
    using namespace std;
    int main()
    {
    int x=0;

    while(x < 100)
    {
    cout<<"Number is: "<<x <<endl;

    x=x+1;
    }
    system("pause");


    }
    MUHAMMAD UMAIR ANJUM
    CMS : 406266
    SECTION : A2

    ReplyDelete
  35. In Q no.4 infinite loop will execute.
    ~406402

    ReplyDelete
  36. QNO#4
    "GOOD"
    will continued infinity time.
    MUHAMMAD UMAIR ANJUM
    CMS NO: 406266
    SECTION : A2

    ReplyDelete
  37. #include
    using namespace std;
    int main()
    {
    int count = 1;
    int a;

    cout << "Enter Value: ";
    cin >> a;

    cout << endl;

    while (count < 11)
    {

    cout << a << "*" << count << "=" << a * count << endl;
    count=count+1;

    }
    system("pause");
    return 0;
    }
    MUHAMMAD UMAIR ANJUM
    CMS NO: 406266
    SECTION : A2

    ReplyDelete
  38. quest #5


    #include
    using namespace std;
    int main()
    {
    int x=40,y=80;
    while(x<=80)
    {
    if(x%2==0)
    {
    y=x+y;
    }
    x++;
    }
    cout<<"Sum of 40 - 80 even numbs = "<< y << endl;
    system("pause");
    }
    MUHAMMAD UMAIR ANJUM
    CMS NO: 406266
    SECTION : A2

    ReplyDelete
  39. Lab Assignment:4

    Q1. write a program in C++. your program should print all the numbers from 0-100 on the console screen?

    Solution:




    #include
    using namespace std;

    int main()
    {
    int a=1;

    while (a <= 100)
    {
    cout << a << "\n";

    a++;
    }

    return 0;

    }



    Q2. write a program in C++. your program should print the the table of 2?


    Solution:


    #include
    using namespace std;


    int main()
    {
    int counter = 1;
    int input;

    cout << "Enter an integer: ";
    cin >> input;

    cout << endl;

    while (counter < 11)
    {

    cout << input << "x" << counter << "= " << input * counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }



    Q3. write a program in C++. your program should print the sum of all firs 0-100 numbers on the console?

    Solution:

    #include
    using namespace std;


    int main()
    {
    int counter = 1;
    int input=1;

    cout << endl;

    while (counter <= 99)
    {

    cout << input << "+" << counter << "= " << input + counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }



    Q4. what will be the output of the program:
    while( 1&& (1||(-100)))
    {
    cout<<"Good"<
    using namespace std;


    int main()
    {
    int counter = 0;
    int input = 2;

    cout << endl;

    while (counter >=0)
    {

    cout << input << "+" << counter << "= " << input + counter << endl;
    counter++;

    }
    system("pause");
    return 0;
    }
    Huzaifa Khalid
    CMS 406172

    ReplyDelete
  40. ques # 3


    #include
    using namespace std;
    int main()
    {
    int x=0,y=100;
    while(x<=100)
    {
    if(x+y)
    {
    y=x+y;
    }
    x=x+1;
    }
    cout<<"Sum of 0 - 100 numbs = "<< y << endl;
    system("pause");
    }

    MUHAMMAD UMAIR ANJUM
    CMS NO: 406266
    SECTION : A2

    ReplyDelete
  41. Sharafat ali
    cms: 406401
    1st semester
    #include
    using namespace std;
    int main()
    {
    int a=2;
    cout<<" now I'm showing the table of 2 "<<endl;
    while(a<=20)
    {
    cout<<"the next value is : "<<a<<endl;
    a=a+2;
    }
    system("pause");
    return 0;
    }

    ReplyDelete
  42. Question#4:
    Output:
    "Good"
    It will display unlimited times.
    Madni Fareed
    CMS#406323
    Section: A2

    ReplyDelete
  43. Q no:4

    the output is:
    "Good"
    This output will show unlimited times.
    Abdul Rehman
    406311
    A2

    ReplyDelete
  44. Question No 4
    The Output is
    "Good"
    It will show infinite times
    Saim Bashir
    CMS...406979
    A2

    ReplyDelete
  45. #include
    using namespace std;
    void main()
    {
    int a=2,b=1;
    while(b<=10)
    {
    cout<<a<<"*"<<b<<"="<<a*b<<endl;
    b++;
    }
    system("pause");
    }




    Name:Sheheryaar
    cms: 406231

    ReplyDelete

Post a Comment

Previous Post Next Post