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
To print natural numbers from 1 to 32767
–4
votes
asked
Jul 2, 2018
by
anonymous
closed
Jun 14, 2020
by
Admin
main()
{
int i=1;
while(i<=32767)
{
printf("\n %d",i);
i=i++;
}
}
closed with the note:
Since it as been answered.
18 Answers
0
votes
answered
Jul 2, 2018
by
Sanjay Ganesh
(
140
points)
#include<stdio.h>
void main()
{
long P=1;
while( P == 32768 )
{
printf("%d",P);
P++;
}
}
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
Jul 4, 2018
by
PRAVEEN
main()
{
for(int i=1;i<=32767;i++)
{
printf("%d",i);
}
commented
Oct 7, 2018
by
Faizan Farooqui
(
120
points)
1 WILL BE PRINTED 32767 TIMES ITS A LOOP
commented
Jun 11, 2020
by
Peter Minarik
(
84,720
points)
No, it will print all the integral numbers from 1 til 32767 (inclusive) just fine.
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
Jul 4, 2018
by
anonymous
#include<stdio.h>
int main()
{
long long int i=1;
while(i<=32767)
{
i++;
}
printf("\n %lld",i);
}
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.
+1
vote
answered
Jul 4, 2018
by
subiksha ks
(
170
points)
#include <iostream>
using namespace std;
int main()
{
for(long int i=1;i<=32767;i++)
cout<<i<<"\t";
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.
+1
vote
answered
Jul 6, 2018
by
anonymous
#include <iostream>
using namespace std;
int main()
{
int limit = 32767;
int x = 1;
while(x <= 32767)
{
cout << x << endl;
x++;
}
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
Jul 6, 2018
by
Raju Prudhvi
(
160
points)
main()
{
int i;
for(i=1;i<32767;i++)
printf("\t%d",i);
}
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
Jul 6, 2018
by
Akhila Mekapothula
(
460
points)
#include<stdio.h>
main()
{
int i,n;
printf("enter no.of natural numbers to print\n");
scanf("%d",&n);
for(I=1;i<=n;i++)
{
printf("%d\t",i);
}
}
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
Jul 6, 2018
by
Akhila Mekapothula
(
460
points)
#include<stdio.h>
main()
{
int i,n;
printf("enter no.of natural numbers\n");
scanf("%d",&n);
do
{
i=1;
printf("%d\t",i);
I++;
}while(I>=n);
}
commented
Jun 11, 2020
by
Peter Minarik
(
84,720
points)
This code has many problems.
1. It does not compile.
2. Assuming you meant 'i' when you wrote 'I' (variables are case sensitive, so they are not the same) the code compiles, but it prints '1' and terminates as long as 'n' is at least 3. If 'n' is less than 3, the loop never terminates, you've got an infinite loop printing '1' forever.
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
Jul 14, 2018
by
yashodha kodag
(
300
points)
#include<stdio.h>
main()
{
int i;
for(i=1;i<=32768;i++)
{
printf("\t%d",i);
}
}
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
Jul 14, 2018
by
yashodha kodag
(
300
points)
main()
{
int i;
for(i=1;i<=32768;i++)
{
printf("\t%d",i);
}
}
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.
Page:
1
2
next »
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.
...