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
What is the auto keyword good for?
Explain how do you override a defined macro?
Why do we need a structure?
Tell me what is null pointer in c?
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
Explain the properties of union.
What are the types of unary operators?
What are integer variable, floating-point variable and character variable?
Can you tell me how to check whether a linked list is circular?
Is c is a middle level language?
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.
Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor
What is this pointer in c plus plus?
Between macros and functions,which is better to use and why?
What is the difference between union and anonymous union?