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
Explain continue keyword in c
How can I generate floating-point random numbers?
hi, which software companys will take,if d candidate's % is jst 55%?
Explain how can you be sure that a program follows the ansi c standard?
Is there a built-in function in C that can be used for sorting data?
Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
how to build a exercise findig min number of e heap with list imlemented?
Explain the difference between call by value and call by reference in c language?
What will be the outcome of the following conditional statement if the value of variable s is 10?
Does free set pointer to null?
What is a file descriptor in c?
Write a program to check whether a number is prime or not using c?
What are the two forms of #include directive?
What is this pointer in c plus plus?
Why we use int main and void main?