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...

Just came across this question, felt worth sharing, so here
it is
I want you to make a C/C++ program that for any positive
integer n will print all the positive integers from 1 up to
it and then back again!
Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1.
Too easy you say?
Okay then... You can ONLY USE:
1 for loop
1 printf/cout statement
2 integers( i and n)
and as many operations you want.
NO if statements, NO ternary operators, NO tables, NO
pointers, NO functions!

Answer Posted / manohar reddy

int main()
{
int i, j;
for(i = 1, j = 0;j < 9;j++, i += int(j/5)*-2 + 1)
printf("%d ",i);
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the process to create increment and decrement stamen in c?

1068


There is a practice in coding to keep some code blocks in comment symbols than delete it when debugging. How this affect when debugging?

1314


What the different types of arrays in c?

1077


explain what are actual arguments?

1099


How would you use the functions fseek(), freed(), fwrite() and ftell()?

1169


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

1253


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1092


In C programming, how do you insert quote characters (‘ and “) into the output screen?

1542


What is the size of enum in bytes?

1096


What is your stream meaning?

1252


Why doesnt the call scanf work?

1206


What are the scope of static variables?

1204


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5965


Where is c used?

1108


What is the difference between int main and void main in c?

1191