Write a C++ program without using any loop (if, for, while
etc) to print numbers from 1 to 100 and 100 to 1;
Answer Posted / ravi sagar
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i;
int j=100;
int c=0;
printf("1 to 100 then 99 to 1");
for(i=1;i<=100;i++;)
{ if (c==0)
{
printf("%d",i);
if(i==100)
{
c=1;
}
}
if(c==1)
{
j--;
printf("%d",j);
if(j==0)
{
break;
}
}
}
| Is This Answer Correct ? | 4 Yes | 11 No |
Post New Answer View All Answers
How do you list a file’s date and time?
In a header file whether functions are declared or defined?
With the help of using classes, write a program to add two numbers.
Explain b+ tree?
Why dont c comments nest?
write a program to generate address labels using structures?
Whats s or c mean?
What is c preprocessor mean?
What is the use of sizeof () in c?
How can you increase the allowable number of simultaneously open files?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
Why do we use int main?
What is operator promotion?
I have seen function declarations that look like this
Why is #define used?