Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 20-09-2005, 09:31 PM   #1 (permalink)
In The Zone
 
Join Date: Aug 2004
Posts: 387
Default a c program.. how to do it???


Today I got a program which I think maybe easy or maybe too difficult.. lets see can anyone help me...

If a student is asked what is the value of the fraction 26/65.. what he does is cuts the two 6s i.e. one in the numerator and one in the denominator... and says 2/5.. whereas the answer is actually also 2/5.. so the problem in now to find all fractions with numerator b/w 10-99 and denomitor also 10-99... i.e. both numerator and denominators and two digits... and then print it... you can only check and cut in a cross way i.e. in case of 11/21 you can cut the first 1 of 11 with teh second one of 21... ie. cross wise X.. u cannot cut 13/12 bcause 1 in numerator is below 1 in denomirnator...
Please somebody code it...
__________________
www.digizeal.org
Tech support + JAVA and Cisco dedicated subforums..
Come and check
anubhav_har is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 20-09-2005, 09:49 PM   #2 (permalink)
Wise Old Owl
 
siriusb's Avatar
 
Join Date: May 2005
Location: Chennai, India, Asia, the Earth, the Solar system, the Milky Way, the Local group, this Universe.
Posts: 1,171
Default

I.can.give.you.a.hint.though.
Just.do.a.itoa().on.each.number.and.put.each.numbe r.into.a.string.buffer.
Check.if.strlen().is.2.
Next,just.check.the.zeroth.element.of.the.first.bu ffer.and.the.first.element.of.the.second.number.
If.they.are.equal.to.'one'.then.just.output.the.re maining.chars.of.the.array.
__________________
http://myxp.blogspot.com
-----------------------
Winchester 3200+ @2,500MHz
LeadTek 7900GT VOLT MODDED @ 680 core, 1800 mem
2x1GB Transcend DDR400 @ DDR454 2.5,3,3,5,1T
siriusb is offline  
Old 21-09-2005, 07:09 AM   #3 (permalink)
In The Zone
 
Join Date: Aug 2004
Posts: 387
Default

1hey man i think you do not get the sum... the lengh of the nuimerator and denominator will always be two since you you are starting at 10 and ending at 99 always. Next if the numerator and denminator are equal crosswise then u have to check the remaining two characters when divided is equal to the actual answer i.e.
Quote:
let the fraction be ab/cd then if a=d or b=c then we check that if b/c or a/d respectively whichever is not cut off or whichever is left is equal to ab/cd or not...
I have written the program today and want to share it my frenz here.. This program was a code segment to be written in a qualifying paper of an IT company's recruitment exam which wanted to check logical skills of the ppl sitting in the exam.
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
	int i,j;
	double x,y;
	for(i=10;i<=99;i++)
	{
		for(j=10;j<=99;j++)
		{
			y=i*1.0/j;
			if((i/10)==(j%10))
			{
				x=(i%10)*1.0/(j/10);
				if(x/y==1.0)
				{
					printf(" %d",i);
					printf("---");
					printf("%d",j);
					printf("\t");
				}
			}
			else if((i%10)==(j/10))
			{
				x=(i/10)*1.0/(j%10);				
				if(x/y==1.0)
				{
					printf(" %d",i);
					printf("---");
					printf("%d",j);
					printf("\t");
				}
			}
		}
	}
}
anubhav_har is offline  
Old 21-09-2005, 09:21 AM   #4 (permalink)
In The Zone
 
#/bin/sh's Avatar
 
Join Date: Apr 2004
Location: 42.65 N 73.76 W
Posts: 213
Default

Classwork?
__________________
\"99 little bugs in the code, 99 bugs in the code, fix one bug, compile it again, 148 little bugs in the code. 148 little bugs in the code....\"
#/bin/sh is offline  
Old 21-09-2005, 11:54 AM   #5 (permalink)
In The Zone
 
Join Date: Aug 2004
Posts: 387
Default

No yaar just normal.... a guy gave me this prob...
__________________
www.digizeal.org
Tech support + JAVA and Cisco dedicated subforums..
Come and check
anubhav_har is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by topgear
- by Charan

Advertisement




All times are GMT +5.5. The time now is 06:38 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2