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
Write a code of a general series where the next element is the sum of last k terms.
What is the purpose of clrscr () printf () and getch ()?
What will be the outcome of the following conditional statement if the value of variable s is 10?
What is the use of extern in c?
What is C language ?
Why doesnt that code work?
What is struct node in c?
What is the maximum no. of arguments that can be given in a command line in C.?
What are keywords c?
What is return in c programming?
Write a program to print factorial of given number using recursion?
Explain argument and its types.
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
Differentiate fundamental data types and derived data types in C.
What is the difference between near, far and huge pointers?