BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan Right Header

Register FAQ Community Calendar New Posts Navbar Right Corner
HOME BZU Mail Box Online Games Radio and TV Cricket All Albums
Go Back   BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan > Institute of Computing > Bachelor of Science in Information Technology > BsIT 2nd Semester > BSIT07-11 2nd > Computer programming for IT

Computer programming for IT Sir Aziz Akhtar


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 24-04-2008, 05:54 PM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Smile Table of 5-10 Using Nested Loops

Table of 5-10 Using Nested Loops

Here is the source code for a Nested loop to write the Table of 5 upto 10


Code:
#include <iostream>
using namespace std;

int tableof=5;
int tablefrom=5;
int tableto=10;
int counter=1;
int main()
    {
    while(tablefrom<=tableto)
        {
        cout<<endl<<"Table of "<<tableof<<endl;
        while(counter<=10)
            {
    
            cout<<tableof<<"x"<<counter<<"="<<tableof*counter<<endl;
            counter++;
            }
        tablefrom++;
        tableof++;    
        counter=1;
/*Here we have freed up the counter ,Because we have to use it
 to write the next loop*/
        }
    return 0;
    }

Reply With Quote
  #2  
Old 24-04-2008, 06:15 PM
!!Ahmad Mushtaq!!'s Avatar
Warning!: Computer Maniac


 
Join Date: Oct 2007
Location: In Umer Hall. Permanent Address : Zahir Pir, RYK, Punjab.
Age: 34
Posts: 237
Contact Number: Sorry. You can contact me through email... Thanks!
Program / Discipline: BSIT
Class Roll Number: 07-45
!!Ahmad Mushtaq!! has a spectacular aura about!!Ahmad Mushtaq!! has a spectacular aura about!!Ahmad Mushtaq!! has a spectacular aura about
User Introduction Re: Syntax Error may occur in Wasif's program!

Assalam-o-Alaikum!

Hi guys! As usual : I copied Wasif's code and pasted it in my Visual C++.

It gave the following error:
PROBLEM:
Quote:
C:\Program Files\Microsoft Visual Studio\MyProjects\Nested Loop\Wasif's program.cpp(16) : error C2059: syntax error : '<'
SOLUTION:
Please remove the space between the two adjacent '<' after <<tableof*counter on the following line:

cout<<tableof<<"x"<<counter<<"="<<tableof*counter< <endl;

REASON:
When I tried to edit Wasif post, I found no blank space there. May be the problem is because of the way this forum formats the text. Well! There is no need to worry!
Reply With Quote
  #3  
Old 24-04-2008, 06:25 PM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default Re: Table of 5-10 Using Nested Loops

Dear Thanks for identifying the Bug,
I've removed the bug now.. What do you think about the method , If you have any other method to solve this problem , Please Share it here.
Reply With Quote
  #4  
Old 24-04-2008, 11:39 PM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Thumbs up Re: Table of 5-10 Using Nested Loops

More Precise Form with three Variables Instead of 4

Code:
#include <iostream>
using namespace std;

int tableof=5;
int tableto=10;
int counter=1;
int main()
    {
    while(tableof<=tableto)
        {
        cout<<endl<<"Table of "<<tableof<<endl;
        while(counter<=10)
            {
    
            cout<<tableof<<"x"<<counter<<"="<<tableof*counter<<endl;
            counter++;
            }
        
        tableof++;    
        counter=1;
        }


    return 0;
    }

Reply With Quote
  #5  
Old 24-04-2008, 11:44 PM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Cool Re: Table of 5-10 Using Nested Loops

Generalized form to write table of a range

:bs2:
Code:
#include <iostream>
using namespace std;

int tableof;
int tableto;
int counter=1;
int main()
    {
    cout<<"Enter the Number from which You want to start Table:";
    cin>>tableof;
    cout<<"Enter the Number UPTO which You want to Write the Table:";
    cin>>tableto;


    while(tableof<=tableto)
        {
        cout<<endl<<"Table of "<<tableof<<endl;
        while(counter<=10)
            {
    
            cout<<tableof<<"x"<<counter<<"="<<tableof*counter<<endl;
            counter++;
            }
        
        tableof++;    
        counter=1;
        }


    return 0;
    }

Reply With Quote
  #6  
Old 25-04-2008, 01:21 AM
.BZU.'s Avatar


 
Join Date: Sep 2007
Location: near Govt College of Science Multan Pakistan
Posts: 9,693
Contact Number: Removed
Program / Discipline: BSIT
Class Roll Number: 07-15
.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute.BZU. has a reputation beyond repute
Default Re: Table of 5-10 Using Nested Loops

Bhai I really miss you in the C++ class last day..
kisi bhi student ko yeh bnana nahi aya tha , aur mujhko bhi nahi aya ..
But main nay kuch banaya tu liya tha ..
Mujhay yeh samjh nahi aa rahi hay kay yeh aap nay iss main akhir main
Quote:
counter=1;
kiyon likha hay
__________________
(¯`v´¯)
`*.¸.*`

¸.*´¸.*´¨) ¸.*´¨)
(¸.*´ (¸.
Bzu Forum

Don't cry because it's over, smile because it happened

Last edited by BSIT07-01; 25-04-2008 at 08:14 AM. Reason: Spell Mistake
Reply With Quote
  #7  
Old 25-04-2008, 08:21 AM
BSIT07-01's Avatar
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 34
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default Re: Table of 5-10 Using Nested Loops

I've Clarified the reason in first post , That is . Counter is the Variable which I used in the Inner While Loop to write the Table , If we don't Give it Value of 1 , The inner loop will not be executed because for that value of counter should be <=10

I think , Now it should be Clear.
Reply With Quote
Reply

Tags
510, loops, nested, table


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binary Table 01 Geeky Table .BZU. Designed Pictures 0 28-04-2011 05:10 AM
Lesson 3: Loops bonfire Introduction to Computing 0 26-02-2011 10:21 PM
Find the AREA of a Home By using Nested Struct C++ shmsa Object Oriented Programming 4 06-09-2008 04:41 AM
Make stars using C++ loops and if statment .BZU. Object Oriented Programming 0 23-08-2008 08:38 PM
Loops & switches BSIT07-01 Web Development 1 21-01-2008 02:38 PM

Best view in Firefox
Almuslimeen.info | BZU Multan | Dedicated server hosting
Note: All trademarks and copyrights held by respective owners. We will take action against any copyright violation if it is proved to us.

All times are GMT +5. The time now is 07:57 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.