a simple c program using 'for' loop to display the output

5

4

3

2

1

Answers were Sorted based on User's Feedback



a simple c program using 'for' loop to display the output 5 4 3 2 1..

Answer / prayashjeet chanda

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();

int num,i;

printf("\nEnter a number: ");
scanf("%d",&num);

for(i=num;i>0;i--)
{
printf("\n%d",i);
}

getch();
}

Is This Answer Correct ?    0 Yes 0 No

a simple c program using 'for' loop to display the output 5 4 3 2 1..

Answer / rohit dilip kakade

#include<stdio.h>
#include<conio.h>
void main(void)
{
   int i;
clrscr();
    for(i=5;i>0;i--)
{
      printf("
%d",i);
}
getch();
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

du u know test pattern for robosoft? Plz share

1 Answers   RoboSoft, TATA, Wipro,


void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..

1 Answers  


What is malloc() function?

0 Answers  


What is the heap?

0 Answers  


If an old women's age is the same as her three grand daughters i,mean the number of days old child=the no of weeks old child=no of months old child .The total yrs of all these ppl is 114 yrs...then how old is the old woman? the yr has 365 days..and 30 days each month.

1 Answers   TCS,






why arithmetic operation can’t be performed on a void pointer?

1 Answers  


how to find sum of digits in C?

21 Answers   CTS, Infosys,


int i=0,j; j=++i + ++i ++i; printf(" %d",j);

2 Answers   ME,


What is assert and when would I use it?

0 Answers  


What is the difference between #include and #include 'file' ?

0 Answers  


What is the difference between constant pointer and constant variable?

0 Answers   NIIT,


What is an identifier?

0 Answers  


Categories