Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / shubham gupta

#include<stdio.h>
void fun(int n)
{
static int i=1,j;
j=printf("%d\n",i); // when i=100 printf will return 4
// bcoz of 3 difits of 100 and 1 '\n' character
switch(j)
{
case 4:
exit(0);
default: i++;
fun(n) ;
}

}
int main()
{
int n;
n=100;
fun(n);
}

Is This Answer Correct ?    0 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are the __date__ and __time__ preprocessor commands?

1072


How is a null pointer different from a dangling pointer?

973


How do you initialize pointer variables?

1031


How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

16589


Explain pointers in c programming?

1062


What is time complexity c?

940


What is a structure in c language. how to initialise a structure in c?

1019


What is wrong with this program statement?

987


how can f be used for both float and double arguments in printf? Are not they different types?

1013


Explain the use of fflush() function?

1024


Where are c variables stored in memory?

1022


What is the use of typedef in structure in c?

916


c program to compute AREA under integral

2336


In C language what is a 'dangling pointer'?

1062


What is wrong with this initialization?

954