how to print
1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1
using any loop(for or while) only once(only 1 loop) and
maximum 2 variables using C.
Answers were Sorted based on User's Feedback
Answer / vipasha agarwal
main()_
{
int i = 1,j=1;
do
{
printf("%d",i);
if (j<10)
i++;
else
i--;
j++;
}while(j<20);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / shaik musthafa
#include<stdio.h>
main()
{
int i,j=1;
for(i=1;i<=10;i++)
{
printf("%d",i);
}
j=i-2;
label:
if(j>=1)
{
printf("%d",j);
j--;
goto label;
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashish kapoor
I can share logic
int i=1;
int j=0;
while(i<0)
{
printf("%d",i);
if(i==10)
{
j=1;
}
if(j==0)
{
i++;
}
else
{
i--;
}
}
Is This Answer Correct ? | 18 Yes | 21 No |
Answer / misha
int arr[20] = {1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1}
int i;
for(i = 0; i< 20; i++)
print("%d ", arr[i]);
Is This Answer Correct ? | 5 Yes | 8 No |
Answer / prateek jain
for(a=1;a<=19;a++)
{
printf("%d",&a);
if(a>10)
{
a--;
printf("%d",&a);
}
}
Is This Answer Correct ? | 0 Yes | 5 No |
Answer / ragavarajan. j
void main()
{
int i,j;
for(i=1;i<=10;i++)
{
printf("%d",i);
if(i==10)
{
i=i-1;
printf("%d",i);
}
i=i-1;
}
Is This Answer Correct ? | 5 Yes | 15 No |
Answer / dinesh balu
int i=1,a;
while(i<=20)
{
printf("%d",(a%10));
i++;
}
Is This Answer Correct ? | 10 Yes | 21 No |
Answer / dinesh balu
int i=1;
while(i<=20)
{
printf("%d",(i%10));
i++;
}
Is This Answer Correct ? | 1 Yes | 14 No |
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }
plz tell me the solution.......... in c language program guess any one number from 1 to 50 and tell that number within 8 asking question in yes or no...............
What is wrong with the following code? int *foo() { int *s = malloc(sizeof(int)100); assert(s != NULL); return s; }
func(a,b) int a,b; { return( a= (a==b) ); } main() { int process(),func(); printf("The value of process is %d !\n ",process(func,3,6)); } process(pf,val1,val2) int (*pf) (); int val1,val2; { return((*pf) (val1,val2)); }
given integer number,write a program that displays the number as follows: First line :all digits second line : all except the first digit . . . . Last line : the last digit
main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
WAP to display 1,2,3,4,5........N
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }
Write a program to model an exploding firecracker in the xy plane using a particle system
write a simple calculator c program to perform addition, subtraction, mul and div.
0 Answers United Healthcare, Virtusa,
main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5