Author |
Topic: Divide by 3 - itoa() (Read 5535 times) |
|
kens
Junior Member
Posts: 59
|
|
Divide by 3 - itoa()
« on: Jul 23rd, 2007, 8:33pm » |
Quote Modify
|
Without using /,% and * operators. write a function to divide a number by 3. char *itoa(int) function is available. Please tell me how to do this problem.
|
|
IP Logged |
|
|
|
vinay_sahu
Newbie
Posts: 1
|
hey,,it's too easy man.... ;D # include<stdio.h> # include<conio.h> # include<stdlib.h> # include<string.h> main() { int i,j=0,len; char buffer[30],ch; printf("enter the no that you want to chek "); scanf("%d",&i); itoa(i,buffer,3); len=strlen(buffer); if(buffer[len-1]=='0') printf("number is divisible by 3"); else printf("number is not divisible by 3 "); getch(); }
|
« Last Edit: Aug 18th, 2012, 8:12pm by vinay_sahu » |
IP Logged |
|
|
|
|