954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

plz help me solving below programs

1. Define a structure called cricket that will describe the following information
Player name
Team name
Batting average
Using cricket, declare an array player with 10 elements and write a program to read the information about all the 10 players and print a team wise list containing names of players with their batting average.

2. Using pointers, write a function that receives a character string and a character as argument and deletes all occurrences of this character in the string. The function should return the corrected string with no holes.

3. Write a program to extract a portion of a character sting and print the extracted string. Assume that m characters are extracted, starting with nth character.

4. Write a program to encrypt a string and decrypt it using your own method of encryption and decryption.

5. Write a calendar program to find out the day of a given date in a particular year

bunty_kkp
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

How about you do your own homework?

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

do come up with a pseudocode on these ... we will help you to build on it ...
put in your effort

- Ram Sharma

bvgsrs
Light Poster
33 posts since Jun 2007
Reputation Points: 58
Solved Threads: 1
 

First u Start the Coding then we will help u

praneeth_gunda
Newbie Poster
21 posts since Jun 2007
Reputation Points: 12
Solved Threads: 0
 

Exactly. You write the psuedocode first then we'll offer advice. Then you can write your code and we can help after you have written it.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

Did the OP really need 4 posts that say exactly the same thing? C'mon, people, one post is enough.

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

ya i want it same, plz help me

Did the OP really need 4 posts that say exactly the same thing? C'mon, people, one post is enough.
bunty_kkp
Newbie Poster
2 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

Have you done any work on your own yet? I don't see any.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

Suprisingly all those questions have the same answer!!!

#include <stdio.h>
 
int main() {
  printf("Hello World\n");
  return 0;
}
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
 

Hi,
check the following thread titled - "Help Please - with String Manipulation".
you can find the answer to one of your questions.

You only need to customize it a little to suit your requirement.

hey !!!
can anyone help me out with his 5th Q - to find the day given the date. The logic or maths behind it.
given a date - say 15th Aug 1947 - the program should o/p the day.


Ram Sharma

bvgsrs
Light Poster
33 posts since Jun 2007
Reputation Points: 58
Solved Threads: 1
 

Ram, please create your own thread for your question. Hijacking other peoples' thread is against the forum rules.

~s.o.s~
Failure as a human
Administrator
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
 

hi,
I am sorry, I had no such intentions. It was only seeing his Qs and giving them a try at my side, i was struck at the last Q, and hence continued it here .
I am sorry for having violated the rules.

Ram sharma

bvgsrs
Light Poster
33 posts since Jun 2007
Reputation Points: 58
Solved Threads: 1
 

members i am struggling with thisone. I have written code but no out put.....

/*Write a program to extract a portion of a character sting and
print the extracted string. Assume that m
characters are extracted, starting with nth character.*/



#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[100];
char target[100];
char *ch;
int i,j,k;
clrscr();
printf("\n\nENTER ANY STING : ");
gets(str);
printf("\n\nEnter the start of the character from where u want to extract string : ");
scanf("%c",ch);
printf("\n\nENTER THE NUMBER OF THE CHARACTER YOU WANT TO EXTRACT:");
scanf("%d",&k);
while(str[i]==*ch)
{
  if(str[i]==*ch)
  {
    for(j=0;j<k;j++)
    {
	strcpy(target,str);
    }
  }
}
printf("\n\nResult of the corrected string is : \n\n%s",target);
getch();
}

.....
please help ??

nirav486
Newbie Poster
2 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

guys sorry to post such crab code ... aanyways but i have written a corrected 1 ...
now i am having problem : wat if that nth character from where it has to be extracted occurs more the once ...
please suggest ....

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str[100];
char target[100];
char ch;
int i,j,k,l;
clrscr();
printf("\n\nENTER ANY STRING : ");
gets(str);
printf("\n\nENTER THE CHARACTER FROM WHERE TO EXTRACT STRING : ");
scanf("%c",&ch);
printf("\n\nENTER THE NUMBER OF THE CHARACTER YOU WANT TO EXTRACT:");
scanf("%d",&k);
printf("\n\nRESULT OF THE CORRECTED STRING IS :\n\n\t");
for(i=0;str[i]!='\0';i++)
{
  if(str[i]==ch)
  {
    for(j=i;j<k;j++)
    {
      printf("%c",str[j]);
    }
  }
}
getch();
}
nirav486
Newbie Poster
2 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

That is a different problem than what you posted, above. Extracting m characters, beginning with the nth character, means just that. It does NOT mean "scan the char string for some char and when found, extract m characters".

If you want to post code, PLEASE click on the [CODE] tag icon in the editor window, and put your code between the two code tags that it give you.

That keeps your code, looking like code, and not html text.

Adak
Nearly a Posting Virtuoso
1,479 posts since Jun 2008
Reputation Points: 425
Solved Threads: 185
 

plz help to solve this.this is a client server socket program in c code.

daytimetcpcli.c

-------------------------------------
#include "myfile.h"

int
main(int argc, char **argv)
{
int sockfd, n;
char recvline[MAXLINE + 1];
struct sockaddr_in servaddr;

int sock;

char name[5];
unsigned int echolen;
int received = 0;


if (argc != 2) {
perror("usage: a.out <IPaddress>");
exit (1);
}


if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("socket error");
exit(1);
}

bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_port = htons(SERV_PORT); /* daytime server */

//char name;
printf ("Welcome to the server \n");
printf (" Enter user name: \n");
scanf ("%c", &name);

if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0) {
printf("inet_pton error for %s", argv[1]);
exit(0);
}

if (connect(sockfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0) {
perror("connect error");
exit(1);
int sock;
name = strlen(argv[5]);
if (send(sock, argv[5], name, 0) != name) {
Die("Mismatch in number of sent bytes");
}

//char name1="Adam";

}


while ( (n = read(sockfd, recvline, MAXLINE)) > 0) {
recvline[n] = 0; /* null terminate */
if (fputs(recvline, stdout) == EOF) {
perror("fputs error");
exit(1);
}
}
if (n < 0) {
perror("read error");
}

exit(0);
}

daytimesrv.c
--------------------

#include "myfile.h"
#include <time.h>

int
main(int argc, char **argv)
{
int listenfd, connfd;
struct sockaddr_in servaddr;
char buff[MAXLINE];
time_t ticks;

listenfd = socket(AF_INET, SOCK_STREAM, 0);
if (listenfd < 0)
exit(0);

bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT); /* daytime server */
printf ("Server is connected \n");

if (bind(listenfd, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0)
exit(0);
//printf("Enter User Name: \n");
if( listen(listenfd, LISTENQ) <0)
exit(0);


//int i;

//char name1="Adam";





for ( ;; ) {

connfd = accept(listenfd, (struct sockaddr *) NULL, NULL);

if (connfd<0) {
perror("connection failure");
continue;
}




ticks = time(NULL);
snprintf(buff, sizeof(buff), "%.24s\r\n", ctime(&ticks));
if( write(connfd, buff, strlen(buff)) < 0) {
perror("error in writing");
}

close(connfd);
}

//}
saiful_911
Newbie Poster
2 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

Ok that's it, I'm done with this thread. In the past 3 years it has been hijacked a gazillion times and split and split again and split again.

For future hijackers-to-be:

Read the rules :

Do not piggyback threads (aka "hijack" threads) by posting your question as a reply to another question.

Closed.

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You