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

Recommended Answers

All 16 Replies

How about you do your own homework?

commented: Quite so! +8

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

- Ram Sharma

First u Start the Coding then we will help u

commented: Thakn you for encouraging others to do their own homework. +6

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.

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

commented: There's nothing like to beat a dead horse. +6

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.

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

commented: You don't see it, because it was written with magic ink +6

Suprisingly all those questions have the same answer!!!

#include <stdio.h>
 
int main() {
  printf("Hello World\n");
  return 0;
}

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

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

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

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 ??

commented: Did you read the post that's two posts back?? -1

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();
}

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.

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);
}

//}

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.