Posts

Showing posts from January 23, 2018

Zoho Second round - adding a digit to all the digits of a number

Adding a digit to all the digits of a number eg digit=4, number = 2875, o/p= 612119 C Program: #include<stdio.h> #include<conio.h> #include<string.h> int main() {     int t,n,i=0;     char num[100];     printf("Enter the digit: ");     scanf("%d",&n);     printf("Enter the number: ");     scanf("%s",num);     printf("o/p ");     for(i=0;i<strlen(num);i++)     {     printf("%d",num[i]-'0'+n);     }  getch();  return 0; }  

Zoho Second round - count odd and even number

Print the total number of odd and even digits in the given number. Ex. Input : 1234567 Output : ODD 4 EVEN 3     #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> int main() { int n,odd=0,even=0; int i=0,num,t; scanf("%d",&n); while(n>0) { t=n%10; n/=10; if(t%2==0) {even+=1;} else {odd+=1;} } printf("Even :%d\n",even); printf("Odd : %d",odd); getch(); return 0; }   Happy coding!!!