code of a program in c language that ask a number and print
its decremented and incremented number..
sample output:

input number : 3
321123



code of a program in c language that ask a number and print its decremented and incremented number..

Answer / kurt s

#include <stdio.h>

int main() {
int n, ncpy;

printf("Input number: ");
scanf("%d", &n);

ncpy = n;

while (ncpy > 0) printf("%d", ncpy--);
while (ncpy < n) printf("%d", ++ncpy);
printf("\n");

return 0;
}

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }

1 Answers  


Design an implement of the inputs functions for event mode

0 Answers   Wipro,


void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }

1 Answers  


Derive expression for converting RGB color parameters to HSV values

1 Answers  


write a c-program to find gcd using recursive functions

5 Answers   HTC, Infotech,






Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.

1 Answers   Samar State University,


How to read a directory in a C program?

4 Answers  


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); }

2 Answers   Persistent,


main() { char a[4]="HELL"; printf("%s",a); }

3 Answers   Wipro,


To Write a C program to remove the repeated characters in the entered expression or in entered characters(i.e) removing duplicates. String contains only lowercase characters ['a'-'z']

0 Answers  


main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above

2 Answers   HCL,


Categories