Webhosting in Pakistan
Page 1 of 2 12 LastLast
Results 1 to 12 of 20

Thread: help loop

  1. #1
    Muzafar_B is offline Advance Member
    Last Online
    3rd August 2019 @ 09:30 PM
    Join Date
    24 Jul 2013
    Location
    hyderabad
    Age
    28
    Gender
    Male
    Posts
    650
    Threads
    101
    Credits
    42
    Thanked
    15

    Default help loop

    Webhosting in Pakistan
    is code se me ne single loop se ye pattern generate kya he

    #include<constream.h>

    *
    **
    ***
    ****
    *****

    void Main()
    {
    char s = "";

    for (int i = 1; i <= 5; ++i)
    {
    s += "*";
    cout<<s;
    }

    getch();
    }

    so plz mujahe is tarah ka pattern chayea wo b single loop me to plz help urgent
    ye pattern single loop me bana k dain
    *****
    ****
    ***
    **
    *
    Good of luck

  2. #2
    Dianat is offline Member
    Last Online
    14th November 2016 @ 06:44 PM
    Join Date
    18 Aug 2015
    Age
    29
    Gender
    Male
    Posts
    251
    Threads
    46
    Thanked
    17

    Default

    for (int i = 1; i <= 5; i)

    ki jaga ye for (int i = 5; i >= 1; --i) past krdo baqi coding same hai


    If YOU Liked it then please Click Thanks button to incourage me

  3. #3
    Muzafar_B is offline Advance Member
    Last Online
    3rd August 2019 @ 09:30 PM
    Join Date
    24 Jul 2013
    Location
    hyderabad
    Age
    28
    Gender
    Male
    Posts
    650
    Threads
    101
    Credits
    42
    Thanked
    15

    Default

    Quote Dianat said: View Post
    for (int i = 1; i <= 5; i)

    ki jaga ye for (int i = 5; i >= 1; --i) past krdo baqi coding same hai


    If YOU Liked it then please Click Thanks button to incourage me
    ni horah ye chk kr chuka hon and pahle ap khud chk kr k phir post karain

  4. #4
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Thanked
    5

    Default

    Quote Muzafar_B said: View Post
    is code se me ne single loop se ye pattern generate kya he

    #include<constream.h>

    *
    **
    ***
    ****
    *****

    void Main()
    {
    char s = "";

    for (int i = 1; i <= 5; ++i)
    {
    s += "*";
    cout<<s;
    }

    getch();
    }

    so plz mujahe is tarah ka pattern chayea wo b single loop me to plz help urgent
    ye pattern single loop me bana k dain
    *****
    ****
    ***
    **
    *

    You are creating your first program also in wrong manner.

    Here is correct solution of your first program:

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        int lines;
        cout << "Enter the lines of stars you want: ";
        cin >> lines;
        for(int i = 1; i <= lines; i++)
        {
            for(int j=1; j<=i; j++)
            {
               cout<<"* ";
            }
    
    		cout << "\n";
    	}
    
    	cout << "\n";
    
        system("pause");
        return 0;
    }
    Screen Shot


  5. #5
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Credits
    132
    Thanked
    5

    Default

    Ab, dosri problem ko solve krty han

  6. #6
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Credits
    132
    Thanked
    5

    Default

    Quote Muzafar_B said: View Post
    ni horah ye chk kr chuka hon and pahle ap khud chk kr k phir post karain

    Here is the solution of second problem:

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
    	int lines;
    
    	cout << "How many line of stars you want in descending order: ";
    	cin >> lines;
    
    	for (int i = lines; i >= 1; i--)
    	{
    		for (int j = 1; j <= i; j++)
    		{
    			cout << "* ";
    		}
    
    		cout << "\n";
    	}
    
    	cout << "\n";
    
        system("pause");
        return 0;
    }
    Screen Shot


  7. #7
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Credits
    132
    Thanked
    5

    Exclamation

    Quote Dianat said: View Post
    for (int i = 1; i <= 5; i)

    ki jaga ye for (int i = 5; i >= 1; --i) past krdo baqi coding same hai


    If YOU Liked it then please Click Thanks button to incourage me

    You are doing little bit different.
    Last edited by Z.Programmer; 25th February 2016 at 09:52 AM.

  8. #8
    Dianat is offline Member
    Last Online
    14th November 2016 @ 06:44 PM
    Join Date
    18 Aug 2015
    Age
    29
    Gender
    Male
    Posts
    251
    Threads
    46
    Credits
    1,009
    Thanked
    17

    Default

    Quote Z.Programmer said: View Post
    You are little bit wrong.
    s+="*"; kia jga s-="*"; kro tu ho jana chahye yaara

  9. #9
    Z.Programmer is offline Member
    Last Online
    11th October 2016 @ 11:38 AM
    Join Date
    06 Feb 2016
    Gender
    Male
    Posts
    158
    Threads
    13
    Credits
    132
    Thanked
    5

    Default

    Quote Dianat said: View Post
    s+="*"; kia jga s-="*"; kro tu ho jana chahye yaara


    Ap data type CHAR ko ks thara add kr skty ho. Ya koe INTEGER hy.
    Kch smjh ayi?
    Last edited by Z.Programmer; 25th February 2016 at 09:52 AM.

  10. #10
    Muzafar_B is offline Advance Member
    Last Online
    3rd August 2019 @ 09:30 PM
    Join Date
    24 Jul 2013
    Location
    hyderabad
    Age
    28
    Gender
    Male
    Posts
    650
    Threads
    101
    Credits
    42
    Thanked
    15

    Default

    Quote Z.Programmer said: View Post
    You are creating your first program also in wrong manner.

    Here is correct solution of your first program:

    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
        int lines;
        cout << "Enter the lines of stars you want: ";
        cin >> lines;
        for(int i = 1; i <= lines; i++)
        {
            for(int j=1; j<=i; j++)
            {
               cout<<"* ";
            }
    
    		cout << "\n";
    	}
    
    	cout << "\n";
    
        system("pause");
        return 0;
    }
    Screen Shot

    Brother ap me to bataya he wo pahle e pta he but mujahe single loop me chayea

  11. #11
    Muzafar_B is offline Advance Member
    Last Online
    3rd August 2019 @ 09:30 PM
    Join Date
    24 Jul 2013
    Location
    hyderabad
    Age
    28
    Gender
    Male
    Posts
    650
    Threads
    101
    Credits
    42
    Thanked
    15

    Default

    Quote Dianat said: View Post
    s+="*"; kia jga s-="*"; kro tu ho jana chahye yaara
    Brother "*" charactor he kabhe minus ni hota jo mene += use kya he ye plus ka kam ni kr rah assign kr ra he s me or ap ne Minus = ka bataya he us pe error ge ga q k charactor he

  12. #12
    Ali_shanbani's Avatar
    Ali_shanbani is offline Senior Member+
    Last Online
    28th July 2018 @ 12:52 PM
    Join Date
    14 Dec 2015
    Location
    @ITDunya.com
    Gender
    Male
    Posts
    474
    Threads
    47
    Credits
    3,213
    Thanked
    34

    Default

    Webhosting in Pakistan


    - - - Updated - - -


Page 1 of 2 12 LastLast

Similar Threads

  1. Class # 3.2 => Do-While Loop
    By Abdul Moeed in forum C++
    Replies: 48
    Last Post: 1st March 2016, 01:13 PM
  2. Solved Nested for loop C++
    By Muzafar_B in forum C++
    Replies: 10
    Last Post: 8th April 2014, 11:13 PM
  3. Class # 3.3 => For loop
    By Abdul Moeed in forum C++
    Replies: 45
    Last Post: 1st October 2013, 09:38 PM
  4. While and For loop
    By alims in forum Ask an Expert
    Replies: 2
    Last Post: 24th February 2011, 12:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •