Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
Program that take 2 numbers from user print them their squares and sum of their squares
+1
vote
asked
Apr 21, 2018
by
Mehmood Ul Hassan
(
130
points)
Write a program that uses while loop to perform the following steps:
a. Prompts user to input two integers Num1 and Num2. Num1 must be less than Num2. If not then Swap values of both numbers.
b. Output all numbers between Num1 and Num2.
c. Output Sum of all numbers between Num1 and Num2.
d. Output numbers and their squares between Num1 and Num2.
e. Output sum of squares of odd numbers between Num1 and Num2.
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
6 Answers
0
votes
answered
Apr 23, 2018
by
Kito Termilien
(
170
points)
what language?
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 7, 2018
by
anonymous
#include<stdio.h>
main()
{
int i,j;
printf("enter the numbers to print between them");
scanf("%d%d",&i,&j);
for(c=i;c<j;i++)
printf("%d", i);
sum+=i;
printf("%d",i*i);
}
commented
May 14, 2018
by
Ernest Nyambane
(
100
points)
it is not working
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 11, 2018
by
Archit Garg
(
220
points)
Answer of a and b part
#include <iostream>
using namespace std;
int main()
{
double num1,num2,temp,i;
cin>>num1;
cin>>num2;
i=num1;
if(num1>num2)
{
temp=num1;
num1=num2;
num2=temp;
}
while(i<num2)
{
if(i==num1)
{}
else
cout<<i<<endl;
i++;
}
return 0;
}
commented
May 14, 2018
by
Ernest Nyambane
(
100
points)
perfect one, it worked
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 11, 2018
by
Archit Garg
(
220
points)
Answer of C part
#include <iostream>
using namespace std;
int main()
{
double num1,num2,temp,i,sum=0;
cin>>num1;
cin>>num2;
i=num1;
if(num1>num2)
{
temp=num1;
num1=num2;
num2=temp;
}
while(i<num2)
{
if(i==num1)
{}
else
sum+=i;
i++;
}
cout<<sum;
return 0;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 11, 2018
by
Archit Garg
(
220
points)
#include <iostream>
using namespace std;
int main()
{
double num1,num2,temp,i;
cin>>num1;
cin>>num2;
i=num1;
if(num1>num2)
{
temp=num1;
num1=num2;
num2=temp;
}
while(i<num2)
{
if(i==num1)
{}
else
cout<<i<<" "<<i*i<<" "<<endl;
i++;
}
return 0;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
May 11, 2018
by
anonymous
import math
num1 = int(input())
num2 = int(input())
if num1>num2:
num1_ant = num1
num1 = num2
num2 = num1_ant
for numa in range(num1+1,num2):
print(numa)
print(math.sqrt(numa))
print(num1 + num2)
print(math.sqrt(num1) + math.sqrt(num2))
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...