Salam,
is ki coding krna koi.. "C" nested for.Loop
or nested.do.While main..
Output:
*
**
***
****
***
**
*
plz help..Thra smjha b daina..
Salam,
is ki coding krna koi.. "C" nested for.Loop
or nested.do.While main..
Output:
*
**
***
****
***
**
*
plz help..Thra smjha b daina..
?
hehehe , exactly issi tarah ka program first semester may baanaaya tha c++ may .. Bohut asaaan hai .. Ap khud try karo , yaqeen karo ,agar issi tarah asaan programs khud nahi banao gay , tu logic banaanay ki aadat apki khatam ho jae gi, aur ap her simple say sawaal may bhi atkay raho gay .. Nested loop may inner loop ko outer loop say control karo, sterick bhi print kervaatay jao ... Aur socho logic . Bohut asaan hai
hmmm.. Ye b hy... Hooo..bht garam kr diya is ny to.. Khair duaon main yad rakhye ga..
abhi cellphone say hun, is liyay roughly idea day raha hun , apkay Oper de gae example may 4 number of stars hain . Tu variable ka naam hi main ne sterick rakh diya hai
for(int i = 1 , i<= sterick, i++)
{ for(int j=1, j<=i, j++)
{ cout<<"*"; }
Cout<<endl; ya phir "\n" new line kay liyay
if i=sterick
break;
agar 4 daffa loop chal jae , tu break operation say ap nested loop kay bahir aa jain gay .
}
int limit = sterick-1;
for(int i=1, i<=sterick-1, i++)
{
for(j=1, j<=limit, j++)
{ cout<<"*";}
cout<<endl;
limit = limit -1;
}
, abhi tu iskay aur bhi bohut say solutions hain .... Jaisay kay apko hint day deta hun , i-- , aur hints jaisay kay ap sterick-i vaali condition bhi rakh saktay ho inner loop may ... Ap socho, aisko aur acha bhi baanaya ja sakta hai
c language may ap cout ki jagah printf ko istimaal kertay ho ..aur baaki cheeezain bhi khud dekh lena ..apko itnay saaray solutions aur hints bhi day diyay hain
bhaaaaai ye kya kr diya.. C++ to abi prhi b nai... Abi jst c start ki hy.. Upr likha b tha k c ka code chahye.. Khair main chk krta hn isi sy e logic daikh laita hn or phr apni b sochta hn.. Thnx
sirf apne printf vaala function istimaal kerna hai . Cout c++ may aata hai ..thats it .simple ..ab itna tu ker hi saktay ho .. Vesay break aik reserved word hai jo apko loop say bahir aaanay may madad kerta hai .is reserved word ki koi zaroorat tu nahi hai, lekin ap phir bhi istimaal ker saktay ho .
thek hy thek hy sir.. main likh k chk krvaon ga ap ko hi pehly.. Thnx alot
its ok .
ye chk krna,
output ye lyni hy...
*
**
***
****
int i,t,a=3;
for(i=1; i<=4; i++)
{
for(t=a; t>1;t--)
{
printf(" ");
}
a--;
for(b=1; b>=1; b++)
{
printf("*");
}
printf("\n");
}
getch();
ye daikho tri-angle bnai hy pr jo 3rd wala for-loop hy jo star print kr rha hy, us ki smj nai aa rahi k kaisy krn.......
Bookmarks