if a 5 digit no. is input thru keyboard, write a program to print a new no. by adding 1 to each of its digits.
C language problem...?
int a;
. . .
scanf("%d", %26amp;a);
printf("%d", a + 11111);
. . .
Reply:u shud create an array that is of length 5 and once the user inputs it create a loop that will cycle to each array and add 1 to each member of the array
Reply:#include %26lt;stdio.h%26gt;
#define MAX 5
int main(int argc,char *argv[]){
int cnt;
int num[MAX];
for(cnt =0; cnt %26lt; MAX; cnt++){
printf("\nEnter number: ");
scanf("%d",%26amp;num[cnt]);
}
for(cnt =0; cnt %26lt; MAX; cnt++)
printf("\nNumber %d is %d",cnt+1,num[cnt]+1);
return 0;
}
is this your homework?
love song
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment