Write a program to accept a number and display the new number after removing all the zeros
sample input : 5400207
Sample output : 5427
Answers
Answered by
36
#include <stdio.h>
#include <string.h>
main()
{
int i, j; char num1[50], num2[50] = "";
printf("input number: ");
scanf("%s", num1);
for (i=0, j=0; num1[i] != '\0' ; i++)
if (num1[i] != '0') num2[j++] = num1[i];
num2[j] = '\0';
printf("new number: %s\n", num2);
}
#include <string.h>
main()
{
int i, j; char num1[50], num2[50] = "";
printf("input number: ");
scanf("%s", num1);
for (i=0, j=0; num1[i] != '\0' ; i++)
if (num1[i] != '0') num2[j++] = num1[i];
num2[j] = '\0';
printf("new number: %s\n", num2);
}
kvnmurty:
:-)
Answered by
3
#include <stdio.h>
#include <string.h>
main()
{
int i, j; char num1[50], num2[50] = "";
printf("input number: ");
scanf("%s", num1);
for (i=0, j=0; num1[i] != '\0' ; i++)
if (num1[i] != '0') num2[j++] = num1[i];
num2[j] = '\0';
printf("new number: %s\n", num2);
}
Similar questions