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 |
int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }
¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }
write a origram swaoing valu without 3rd variable
write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).
0 Answers CDAC, College School Exams Tests,
Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
how can u draw a rectangle in C
53 Answers Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,
#if something == 0 int some=0; #endif main() { int thing = 0; printf("%d %d\n", some ,thing); }
Give a oneline C expression to test whether a number is a power of 2?
25 Answers EA Electronic Arts, Google, Motorola,
3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.