Monday, May 24, 2010

Please make program for me at turbo c?

1.) you are going to ask the values of the rows and column respectively. And for each row the larger number will be displayed first then so on (or in descending fashion). For which the output will look like this:


Results:





How many rows: 3





How many columns: 5





The output is as follows:





Row 1: 5 4 3 2 1





Row 2: 5 4 3 2 1





Row 3: 5 4 3 2 1





--------------------------------------...





2.) you are going to input an integer number between 1 to 100. In which the output will look like this:





Results:





Enter an integer between 1 and 100: 15





1 2 3 4 5 6 7 8 9 10





11 12 13 14 15





The sum is: 120

Please make program for me at turbo c?
obviously this is a programming assignment for school, please do not ask someone else to do your homework.
Reply:I gave only pseudo code, write the real code by yursels. And i dont know if this true or not Im not tested it


1


int row,col


for (i=row;i--)


{


print i;


for (j=col;j--)


{


print j;


}


}





2


int input, sum


sum=0;


if ((input%26lt;0)||(input%26gt;100))


print 'Error!'


else


{


for (i=1;i++)


{


print 'i ';


sum+=i;


}


print sum;


}





Hope this help
Reply:Hey Dude,i have written this on Linux,i think program will compile on win too...





Here is the Programs Code:


1.


#include %26lt;iostream%26gt;


#include %26lt;iomanip%26gt;


using namespace std;


int main() {


unsigned int row=0,col=0;


std::cout%26lt;%26lt;"How Many rows:";cin%26gt;%26gt;row;


std::cout%26lt;%26lt;"How Many column:";cin%26gt;%26gt;col;


for(int i=1;i%26lt;=row;i++) {


std::cout%26lt;%26lt;"Row "%26lt;%26lt;" "%26lt;%26lt;i%26lt;%26lt;":";


for(int j=col;j%26gt;0;j--) {


std::cout%26lt;%26lt;setw(2)%26lt;%26lt;j;


}


std::cout%26lt;%26lt;endl;


}


return 0;


}





2.





#include %26lt;iostream%26gt;


using namespace std;


int main() {


unsigned int sum=0;


int count=0,n=0;


std::cout%26lt;%26lt;"Enter the count:";std::cin%26gt;%26gt;count;


std::cout%26lt;%26lt;"Enter the numbers:"%26lt;%26lt;endl;


for(int i=0;i%26lt;count;i++){


cin%26gt;%26gt;n;


sum += n;


}


std::cout%26lt;%26lt;"Sum:"%26lt;%26lt;sum%26lt;%26lt;endl;


return 0;


}





please let me know if u get into trouble while running this.


No comments:

Post a Comment