print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!

Answers were Sorted based on User's Feedback



print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / raghuram.a

//Simple.use recursion!
#include<stdio.h>
int f(int i,int n)
{
i<=n&&printf("\t%d",i)&&f(++i,n);
return 1;
}
main()
{
f(1,100);
return 0;
}

Is This Answer Correct ?    13 Yes 6 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / anil

//To print 1-50 without using any loops or condition statement
main()
{
static int i;
printf("%d \n",i++);
(i%51)&&main();
}

Is This Answer Correct ?    11 Yes 11 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / pree

i wnt to print 1 to 15 without using any loop,conditional
statments ,ternary operators,if conditions
nothing.........is dere any way now to print the numbers????/

Is This Answer Correct ?    2 Yes 2 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / uday

Console.WriteLine(
String.Join(
", ",
Array.ConvertAll<int, string>(
Enumerable.Range(1, 100).ToArray(),
j => j.ToString()
)
)
);

Is This Answer Correct ?    0 Yes 0 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / grasshopper

simple !
create a loop by main()

.i.e call main(previous_num) from main.

till break char is hit.

Is This Answer Correct ?    9 Yes 10 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / prince

main()
{
int n;
printf("enter limit:");
scanf("%i",&n);
print(n);
}

print(int n)
{
n>0?print(n-1):printf("");
printf("\n%d",n);
}

Is This Answer Correct ?    10 Yes 11 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / nain

plz explain above answer ......

Is This Answer Correct ?    3 Yes 5 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / srujana

#include<stdio.h>
void main()
{
int i=0;
printf("value of i",(i>=100)?exit(0):i);
i++;
continue;
}
OR
by using recursion
#include<stdo.h>
int rec(int i)
{
if(i>=100)
return;
else
i++;
return i;
}
void main()
{
rec(1);
}

Is This Answer Correct ?    0 Yes 4 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / srividhya

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
int i=0,n,x;
scanf("%d",&n);
label1:
{
printf("%d",i);
i++;
x=i<n?i:0;
exit(x);
continue;
}
getch();
}

Is This Answer Correct ?    8 Yes 15 No

print numbers till we want without using loops or condition statements like specifically(for,do wh..

Answer / akshay babar

#include<stdio.h>
int print(int i)
{
if(i>0)
return print(printf("%d", i--));
else
return 1;
}
main()
{
print(100);
return 0;
}

Is This Answer Correct ?    2 Yes 11 No

Post New Answer

More C Code Interview Questions

main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

9 Answers   Microsoft,


What is the hidden bug with the following statement? assert(val++ != 0);

1 Answers  






plz send me all data structure related programs

2 Answers  


main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256

2 Answers   HCL,


how to return a multiple value from a function?

2 Answers   Wipro,


What are segment and offset addresses?

2 Answers   Infosys,


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.

2 Answers  


create a C-code that will display the total fare of a passenger of a taxi if the driver press enter,the timer will stop. Every 10 counts is 2 pesos. Initial value is 25.00

0 Answers   Microsoft,


Categories