مـنـامـي وافتخر Posted مارس 28, 2006 Report Share Posted مارس 28, 2006 Write a c++ program that inputs an integer large than zero (0) and calculates the sum of the powers from 1 to that integer. For example, if the integer equals to 4, the sum of the powers is 288 (11 + 22 + 33 + 44 ). Your program should display an error message if the input number is not valid. Your program RUN (Input\Output) should be as follows: Enter a number greater than zero: 4 288 Quote Link to comment Share on other sites More sharing options...
مغرور جدا Posted مارس 29, 2006 Report Share Posted مارس 29, 2006 (edited) بحل جاهز لكن ما بتستفيدون منه بالاضافة للحركة الجديدة الي مسوينها ان الاجوبة المنسوخة يوزعون درجتها على الطلاب الي جايبينها.. حاول على الاقل تغير فيه شوي. #include <iostream> using namespace std; void main(){ int x,sum=0,r=1; cout<<"Enter a number greater than zero: "; cin>>x; if(x>0){ for (int i=1;i<=x;i++){ r=1; for (int j=1;j<=i;j++) r=r*i; sum=sum+r;} cout<<sum<<endl; } else cout<<"Wrong number"<<endl; } وانصحك جربه في البرنامج اول.. Edited مارس 29, 2006 by مغرور جدا Quote Link to comment Share on other sites More sharing options...
صاحبة السمو Posted ابريل 2, 2006 Report Share Posted ابريل 2, 2006 السلام عليكم تسلم اخوي على الحل بس مافهمت يعني احين هالجواب غلط والا انة مخي اللي فيه خلل !! Quote Link to comment Share on other sites More sharing options...
الحصان الأسود Posted ابريل 2, 2006 Report Share Posted ابريل 2, 2006 الجواب صحيح Quote Link to comment Share on other sites More sharing options...
سعد الذابح Posted ابريل 2, 2006 Report Share Posted ابريل 2, 2006 مشكووووووووووووووووووووووور .. منامي ..على الموضوع .. ومشكووووووووووووووووووووووور مغرور جدا على الحل .. ويعطيكم العافية كلكم ... Quote Link to comment Share on other sites More sharing options...
صاحبة السمو Posted ابريل 4, 2006 Report Share Posted ابريل 4, 2006 تسلمون على التوضيح مشكورين وماتقصرون Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.