Solve the given C Puzzle

Status
Not open for further replies.

Faun

Wahahaha~!
Staff member
restrictions and terms ruined my life *farm3.static.flickr.com/2192/2106525721_b621e4efee_o.png
 

anantkhaitan

Burning Bright
Perhaps he is making the rules after seeing my code :p

@ adi
Listen brother i have just one thing to say "I GIVE UP". Do you know what is the use of kbhit ??? If we use something like while(!kbhit()) the loop keeps on iterating until you press a key i.e. ending up your program whenever you like, Now tell me does it anywhere hampers/interferes with the logic of the code. I have used 4 variables with a string.. I can write the same program using 2-3 variables without using any string but that will elongate the code...
Every programmer has a unique way of writing .. and what I submitted was my way of writing and you cannot it change by imposing those stupid rules (whateva I submitted U made a new rule against that).. And I am feeling proud that I am disqualified.. Waiting for your code..ATB

And yes forgot to mention about printf(" ") replace it by printf("%c",32) :p
 
Last edited:

a_k_s_h_a_y

Dreaming
yeah that's what i meant
a program can be written in many ways !!
he wants us to think exactly as he does !

that can be done using basics of printf thing ... going back and coming forward .. but now who has time to solve it .. exams are on !!
 

Faun

Wahahaha~!
Staff member
a_k_s_h_a_y said:
yeah that's what i meant
a program can be written in many ways !!
he wants us to think exactly as he does !

that can be done using basics of printf thing ... going back and coming forward .. but now who has time to solve it .. exams are on !!
better study for exams dude, ur placement depends on marks.
Alas finally am above all these plcaement tension:D

yay my 600th post*farm3.static.flickr.com/2355/2107305358_394278500c_o.png
 

The_Devil_Himself

die blizzard die! D3?
who said placement depends upon marks?toppers sux and are good for nothing!The guy who got the highest placement in my university in 2005-2006 had 9 backs at the time of interviews!!
 

Faun

Wahahaha~!
Staff member
The_Devil_Himself said:
who said placement depends upon marks?toppers sux and are good for nothing!The guy who got the highest placement in my university in 2005-2006 had 9 backs at the time of interviews!!
exceptions do occur :D

Probably some other qualities helped him, but its a risky matter to depend on this if we can surely secure placement by getting good marks.

After all good marks are not just for placements but also ur parents will be happy that their efforts and resources are not getting wasted.

Btw who said toppers sux ?, i said get good marks just to be on safer side.
 

fun2sh

Pawned!... Beyond GODLIKE
The_Devil_Himself said:
who said placement depends upon marks?toppers sux and are good for nothing!The guy who got the highest placement in my university in 2005-2006 had 9 backs at the time of interviews!!
yeah! u r right! few girls who r topper in my class knows nothin abt programin!! jst mug up the things! but at least 1 need the grace marks for sittin in placement exams!!!

n guys plz dont talk offtopic here(sorry coz i too did just now)!!! its a very nice thread!
 
devil is right in a sense .......toppers sux ..but only who r crammers (unfortunately most toppers are crammers..) and regarding placement, if u fulfill the minimum criteria for a company ... thn it dsnt matter whether u have 71% marks or 91% marks ... it depends solely on ur talent .............
 

Faun

Wahahaha~!
Staff member
ok guys u win, i had the same notion what you hav now but everything changes. I hav seen all this, this very year (people havin high marks were not even asked any questions at interviews but average students were passed thru trials).

Do you think mass recruiters look for talents, agar aisa hota toh india mein aaj hazaroo einstein hote.

its a fight club discussion so am backing off now.
Back to topic comrades :D:D:D
 
OP
A

adi007

Youngling
a_k_s_h_a_y said:
yeah that's what i meant
a program can be written in many ways !!
he wants us to think exactly as he does !
no a_k_s_h_a_y my intension is not that..
i modified the rules because i later found that the puzzle would become too easy without them..

anantkhaitan said:
Perhaps he is making the rules after seeing my code :p
this is some what true :D:D
but let me say that my intension was not to make u program the way i programmed..
After seeing ur code i found out that the puzzle will be too easy to solve without some rules.So i had to modify the rules

anantkhaitan said:
@ adi
Listen brother i have just one thing to say "I GIVE UP".
don't give up anantkhaitan. the answer to this puzzle is way too easy..
easier than ur old program..

anantkhaitan said:
If we use something like while(!kbhit()) the loop keeps on iterating until you press a key i.e. ending up your program whenever you like,
i already told that tom should chase jerry for 2 lines...
so there is no necessity for kbhit()

The_Devil_Himself said:
who said placement depends upon marks?toppers sux and are good for nothing!The guy who got the highest placement in my university in 2005-2006 had 9 backs at the time of interviews!!
^^I agree with u ..
please start a new thread named 'does placement depends upon marks' in the fight club..
lets see there what others think...
 
Last edited:

Pathik

Google Bot
The_Devil_Himself said:
who said placement depends upon marks?toppers sux and are good for nothing!The guy who got the highest placement in my university in 2005-2006 had 9 backs at the time of interviews!!
+100
 

anuj919

Broken In
Hi Adi :eek: :eek:
I think this answer fulfills all your conditions.:p

Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
	int i,j=1;
	long k;
	char a[]="Tom# Jerry ";
	clrscr();
	while(j<=2)
	{
		for(i=0;i<=149;i++)
		{
			printf("%*s",i+strlen(a),a);
			for(k=0;k<9999999;k++);
			clrscr();
		}
		a[3]=' ';a[10]='#';
		for(i=149;i>=0;i--)
		{
			printf("%*s",i+strlen(a),a);
			for(k=0;k<9999999;k++);
			clrscr();
		}
		a[3]='#';a[10]=' ';
		j++;
	}
}

:D :D
 
OP
A

adi007

Youngling
^^yup u are right..
one point for anuj919 and one for anantkhaitan and a_k_s_h_a_y...

adi007 said:
Hi! I am Adithya U,17 year old Engineering Student(IT) from Hassan,Karnataka

*farm3.static.flickr.com/2052/2086499468_1f153310e7_o.gif​

Currently you are witnessing C puzzle 11






First,let me state the rules in this thread:
1.Please do not give suggestions or hints.Specify the modified program only.
2.Before posting the program make sure it's working in the way i want.


Here is the 11th C puzzle



write a c program which gives the output as below..

Code:
Enter a number
52
The reverse of 52 is 25
52 is not a prime number
Sum of digits=7

Code:
Enter a number
17
The reverse of 17 is 71
17 is a prime number
Sum of digits=8

If i didn't specify the rules then anyone can solve this :D:D
Rules
maximum of 2 header files
maximum 2 variables(including global and local variables)
Both the variables must be of same data type
no structures,pointers,user defined functions..

Note :Specify your modified program along with the answer

Awards gallary:
Total puzzles solved :10
anuj919 3
me (If no one gets the solution then points will be for me) 2
saurabh kakkar 2
fun2sh 2
eggman 1
nigthtcrawler 1
a_k_s_h_a_y 1
anantkhaitan 1

Leading:anuj919
11th puzzle added!!
Thread updated!!:D
 
Last edited:

anantkhaitan

Burning Bright
Check out :
Code:
#include<stdio.h>
int main()
        {
        int a,b;
        printf("Enter a Number\n");
        scanf("%d",&a);
        b=10*(a%10)+(a/10);
        printf("The reverse of %d is %d\n",a,b);
        for(b=2;b<=a;b++)
                if(a==b)
                {printf("%d is a prime number\n",a);break;}
                else if(a%b==0)
                {printf("%d is not a prime number\n",a);break;}
        printf("Sum of digits=%d\n",a/10+a%10);
        return 0;
        }
This time do not add rules after submitting
 
K

khattam_

Guest
Here's the solution which works for all integers:
Code:
#include<stdio.h>
#include<conio.h>

void main(void){
int n,i;
clrscr();
printf("Enter a number\n");
scanf("%d",&n);

printf("The reverse of %d is ",n);
i=n;
while(i>0){
printf("%d",i%10);
i/=10;
}

printf("\n%d is ",n);
for(i=2;i<n;i++)
if (n%2==0){ 
printf("not ");
break;
}
printf ("a prime number",n);

i=0;
while(n>0){
i+=n%10;
n/=10;
}

printf("\nSum of digits=%d",i);
getch();
}
 
Last edited by a moderator:
Status
Not open for further replies.
Top Bottom