Solve the given C Puzzle

Status
Not open for further replies.

Faun

Wahahaha~!
Staff member
adi007 said:
smiley is just the way to indicate the end....
It's just like normal char...

how do u enter smiley after string in cmd prompt ?

Hitting CTRL+B gives ^B
 

Faun

Wahahaha~!
Staff member
adi007 said:
example program here
*www.thinkdigit.com/forum/showpost.php?p=654017&postcount=21
yeah seen that.

During runtime also you have to press CTRL B to enter smiley

CTRL B gives ^B not a smiley in dos prompt
 
OP
A

adi007

Youngling
fun2sh said:
wat if the smiley appears in th mid like this


do u expect output like
noooo....
As soon as the smiley encounters the program should end by displaying
Code:
Have a nice day
and the main thing is
There is no separate output and input.The program is dynamic

T159 said:
yeah seen that.

During runtime also you have to press CTRL B to enter smiley

CTRL B gives ^B not a smiley in dos prompt
I am planning to upload the runtime vedio of the program on monday or tuesday...
 
Last edited:

Faun

Wahahaha~!
Staff member
adi007 said:
There is no separate output and input.The program is dynamic


I am planning to upload the runtime vedio of the program on monday or tuesday...

that means that the input and output will be on same line

It would be nice if u can provide screenshot
 
OP
A

adi007

Youngling
i will post the gif file or link to runtime vedio on Tuseday(@offtopic :I am going to release my software presenmaker(beta) on that day.:D:D:D...)
Date for the puzzle 8 has been extended till next Thursday...
 

anuj919

Broken In
Hey I am also a student in 1st year in Gujarat & new in this puzzle

I have done puzzle 8

Here is the Solution...



#include<stdio.h>
#include<conio.h>

//Function to return the reverse the string given as argument

char *str_rev(char str[100])
{
char rev[100];
int i,j;
for(i=0;str!='\0';i++);
i--;
for(j=0;i>=0;i--)
{
rev[j++]=str;
}
rev[j]='\0';
return rev;
}


void main()
{
char a[100][100],c; // a is two dimentional array to store diffrent strings
// c is temp variable

int i=0,j=0,k=0; // i is for i th string entered
// j is for j th letter of i th string

clrscr();
printf("Enter String \n");
while((c=getche())!=':)')
//:)=Ctrl+B
{
if(c!=' ')
{
a[j++]=c;
//If space is not entered put char at the end of i th word (i.e,a)
}
else
{
a[j]='\0';
//If space is entered put null character at the end of i th word
i++;j=0;k=0;
// increment no of words & make j=0 for next use

//Now first clear the screen & start printing all the strings reversed

clrscr();
printf("Enter String \n");
while(k<i)
{
printf("%s ",str_rev(a[k]));
k++;
}
}
}

//After smily print string in new line

printf("\nHave a Nice Day");
getch();
}


:D:D:D
 
Last edited:
OP
A

adi007

Youngling
i think the answer given by anuj919 is wrong....
Not yet compiled and checked ...
But i think what the program is doing is accept the string and then clear the screen and then print the reverse of the string.This is wrong because I said the program is dynamic.....
Anyways ,I have prepared the animated gif run time output,will post it tommorow......
 
Last edited:

Faun

Wahahaha~!
Staff member
adi007 said:
i think the answer given by anuj919 is wrong....
Not yet compiled and checked ...
But i think what the program is doing is accept the string and then clear the screen and then print the reverse of the string.This is wrong because I said the program is dynamic.....
Anyways ,I have prepared the animated gif run time output,will post it tommorow......

no its reversing the word as soon as u press space, its dynamic.

I dunno wat else can be dynamic other than that ?
 

fun2sh

Pawned!... Beyond GODLIKE
yeah its dynamic..me to checked it n its reverses the strin as soon as u press a space bar
 
OP
A

adi007

Youngling
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 9






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 9th C puzzle



this is the same 8th puzzle but there are somes rules..
Write a c program which gives accepts words and at the end of a word,it will replace the word by it's reverse.This is done until a smiley is encountered.At the end it will print "Have a nice day".That is if i entered i luv c and i think it's rocks :) will give the output as..



to be more explainable

Code:
Enter the string
i luv_
as soon i press space,it will become

Code:
Enter the string
i vul _

Rules
1.No user defined functions..
2.No usage of clrscr()
3.No header file other than stdio.h should be used.
4.No * symbol in the whole program

Note :Specify your modified program along with the answer

Awards gallary:
Puzzles solved :8
me (If no one gets the solution then points will be for me) 2
saurabh kakkar 2
fun2sh 2
eggman 1
nigthtcrawler 1
anuj919 1
Leading:saurabh kakkar,fun2sh and myself
puzzle 9 added thread updated!!
 

fun2sh

Pawned!... Beyond GODLIKE
are bhai why u givin same program now!!!!

waise now one question can we use strtok() function n gotoxy() function???
 

anuj919

Broken In
I think it is next to impossible to solve the puzzle 9 without using getch/getche (Which r in "conio.h ") because without it one can't read sentence 'word by word'

So please can we use getch/getche?
 
Status
Not open for further replies.
Top Bottom