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


Please Help Members By Posting Answers For Below Questions

What is the auto keyword good for?

636


Explain how do you override a defined macro?

598


Why do we need a structure?

603


Tell me what is null pointer in c?

621


A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

741






Explain the properties of union.

619


What are the types of unary operators?

670


What are integer variable, floating-point variable and character variable?

615


Can you tell me how to check whether a linked list is circular?

787


Is c is a middle level language?

606


write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.

1991


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3003


What is this pointer in c plus plus?

606


Between macros and functions,which is better to use and why?

1578


What is the difference between union and anonymous union?

843