Pages
▼
C Program to print series 5, 4, 3, 2, 1 for the given value of N.
C Program to print series 5, 4, 3, 2, 1 for the given value of N.
For example, if N=5, output should be
5, 4, 3, 2, 1
#include<stdio.h>
int main()
{
int i, N;
printf("Enter N:");
scanf("%d", &N);
for(i=N; i>0; i--)
{
printf("%d",i);
//Logic avoid last ,
if(i!=1)
printf(", ");
}
return 0;
}
Output of program
Enter N:5
5, 4, 3, 2, 1
No comments:
Post a Comment