Question
print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Question Submitted By :: Solidcube
I also faced this Question!!
Rank
Answer Posted By
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 1
simple !
create a loop by main()
.i.e call main(previous_num) from main.
till break char is hit.
Grasshopper
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 2
plz explain above answer ......
Nain
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 3
#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();
}
Srividhya
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 4
main()
{
int n;
printf("enter limit:");
scanf("%i",&n);
print(n);
}
print(int n)
{
n>0?print(n-1):printf("");
printf("\n%d",n);
}
Prince
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 5
//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;
}
Raghuram.A
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 6
main()
{
static int i;
printf("%d \n",i++);
main();
}
Vijay
Re: print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
Answer
# 7
//To print 1-50 without using any loops or condition statement
main()
{
static int i;
printf("%d \n",i++);
(i%51)&&main();
}
Anil
Other C Code Interview Questions
Question Asked @ Answers Is this code legal?
int *ptr;
ptr = (int *) 0x400; 1 main ( )
{
static char *s[ ] = {“black”, “white”, “yellow”,
“violet”};
char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf(“%s”,*--*++p + 3);
} 1 main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16 HCL 1 void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(“%c %d \n“, ch, ch);
} 1 main()
{
int i =0;j=0;
if(i && j++)
printf("%d..%d",i++,j);
printf("%d..%d,i,j);
} 1 #include<stdio.h>
main()
{
const int i=4;
float j;
j = ++i;
printf("%d %f", i,++j);
} 1 #include <stdio.h>
main()
{
char * str = "hello";
char * ptr = str;
char least = 127;
while (*ptr++)
least = (*ptr<least ) ?*ptr :least;
printf("%d",least);
} 1 Write a procedure to implement highlight as a blinking
operation 1 How can u say that a given point is in a triangle?
1. with the co-ordinates of the 3 vertices specified.
2. with only the co-ordinates of the top vertex given. 1 main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
} 1 Program to find the largest sum of contiguous integers in
the array. O(n) 7 Is the following code legal?
typedef struct a
{
int x;
aType *b;
}aType 1 main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
} 1 #define assert(cond) if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s,
line %d \n",#cond,\
__FILE__,__LINE__), abort())
void main()
{
int i = 10;
if(i==0)
assert(i < 100);
else
printf("This statement becomes else for if in
assert macro");
} 1 How will u find whether a linked list has a loop or not? Microsoft 6 #include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
} 1 What is wrong with the following code?
int *foo()
{
int *s = malloc(sizeof(int)100);
assert(s != NULL);
return s;
} 1 main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
} 1 Write a function to find the depth of a binary tree. Adobe 8 main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
} 1 For more C Code Interview Questions Click Here