We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>
+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion
How to Add New Discussion in Study Group ? Step By Step Guide Click Here.
CS201 Pre-Assignment Solution & Discussion Fall 2015
Pre – Assignment practice program (Graded)
Problem statement:
You are required to write a program in which the program will ask the user to enterLower limit and Upper limit for a loop. It means that loop will start from the lower limit and will execute till the upper limit. After taking the input, the program should show the sum of all the numbers from lower limit to upper limit in each iteration of the loop. For example if the user enters 3 as lower limit and 8 as upper limit. The output should be as:
3 7 12 18 25 33
What you are doing here is you are adding the lower limit into the number next to it and showing it in the same iteration.
Also the program will count the even and odd numbers in the output. In this example, the count of the even numbers will be 2 and the odd numbers will be 4. So the final output would be
Sample Output:
Enter the lower limit for the loop: 3
Enter the upper limit for the loop: 8
3 7 12 18 25 33
Even numbers: 2
Odd numbers: 4
__________________________________________
Tags:
+ How to Follow the New Added Discussions at Your Mail Address?
+ How to Join Subject Study Groups & Get Helping Material? + How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators? + VU Students Reserves The Right to Delete Your Profile, If?.
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)Please Discuss here about this assignment.Thanks
Our main purpose here discussion not just Solution
We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions.
#include <iostream>
using namespace std;
int main()
{
int sum;
int lowerlimit;
int upperlimit;
int even;
int odd;
sum=0;
cout"please enter the lowerlimit";
cin>>lowerlimit;
cout"please enter the upperlimit";
cin>>upperlimit;
while(lowerlimit<=upperlimit)
{
sum=sum+lowerlimit;
lowerlimit=lowerlimit+1;
coutsum"\t";
if((sum%2)==0)
{
even=even+1;
}
else
{
odd=odd+1;
}
}
cout"even numbers "evenendl;
cout"odd numbers"oddendl;
}
#include<iostream>
using namespace std;
main()
{
int lowerLimit,upperLimit,i,sum=0,even=0,odd=0;
cout"Please enter lowerLimit:";
cin>>lowerLimit;
cout"Please enter upperLimit:";
cin>>upperLimit;
for(int i=lowerLimit;i<upperLimit;i++)
{
sum=sum+i;
coutsum"\t";
}
if((sum%2)==0)
{
even++;
}
else{
odd++;
}
lowerLimit++;
}
This is ur omplete code ayyzzi bhai
#include<iostream>
using namespace std;
main()
{
int lowerLimit,upperLimit;
int sum=0,even=0,odd=0;
cout"Please enter lowerLimit:";
cin>>lowerLimit;
cout"Please enter upperLimit:";
cin>>upperLimit;
for(int i=lowerLimit;i<=upperLimit;i++)
{
sum=sum+i;
coutsum"\t";
if((sum%2)==0)
{
even=even+1;
}
else
{
odd=odd+1;
}
}
cout "even numbers "even endl;
cout "odd numbers"odd endl;
}
#include<iostream>
using namespace std;
int main()
{
int lowerLimit,upperLimit,i,sum=0,even=0,odd=0;
cout"Please enter lowerLimit:";
cin>>lowerLimit;
cout"Please enter upperLimit:";
cin>>upperLimit;
for(int i=lowerLimit;i<=upperLimit;i++)
{
sum=sum+i;
lowerLimit++;
coutsum"\t";
if((sum%2)==0)
{
even++;
}
else{
odd++;
}
}
cout"even numbers "evenendl;
cout"odd numbers"oddendl;
}
No assignment exists for this course.
hey,
ive tried to write this code,ive taken help from your comments as well
but the result which im getting is without any space
like for the same limits 3 and 8 my result is coming as
3712182533even numbers are2odd numbers are4
heres the code,can u please check it?
#include <iostream>
using namespace std;
int main()
{
int sum;
int odd;
int even;
int upperlimit;
int lowerlimit;
sum=0,odd=0,even=0;
cout"Please enter the lower limit : ";
cin>> lowerlimit;
cout"please enter the upper limit : ";
cin>> upperlimit;
while(lowerlimit<=upperlimit)
{
sum=sum+lowerlimit;
lowerlimit=lowerlimit+1;
coutsum;
if((sum%2)==0)
{
even=even+1;
}
else
{
odd=odd+1;
}
}
cout"even numbers are"even;
cout"odd numbers are"odd;
}
Hi Friends In this video help of new students of CS201 and discus first program of C++
Plz wtch This video for Learn and write first program.
watch other video of C++
© 2019 Created by + M.Tariq Malik. Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
VU Students reserves the right to delete profile, which does not show any Activity at site nor has not activity more than 01 month.
We are user-generated contents site. All product, videos, pictures & others contents on vustudents.ning.com don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com or Contact us at contact Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post