| | |
A program to print out a word that appears the most number of times
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 24
Reputation:
Solved Threads: 0
Write a program to find the number of times that a given word(i.e. a short string) occurs in the sentence(i.e. in a sentence!).
Read data from the standard input. the first line is a single word, which is followed by general text on the second line. read both up to a newline character, and insert a terminating null before processing.
Typical output should be:
The word is "the".
The sentence is "the cat sat on the mat".
The word occurs 2 times.
Read data from the standard input. the first line is a single word, which is followed by general text on the second line. read both up to a newline character, and insert a terminating null before processing.
Typical output should be:
The word is "the".
The sentence is "the cat sat on the mat".
The word occurs 2 times.
Atleast show your code (efforts) & specify where you are stuck up. You are expecting that someone will write the entire code for you. You've not even specified what your specific problem is about.
•
•
•
•
Write a program to find the number of times that a given word(i.e. a short string) occurs in the sentence(i.e. in a sentence!).
Read data from the standard input. the first line is a single word, which is followed by general text on the second line. read both up to a newline character, and insert a terminating null before processing.
Typical output should be:
The word is "the".
The sentence is "the cat sat on the mat".
The word occurs 2 times.
•
•
Join Date: Nov 2007
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
Atleast show your code (efforts) & specify where you are stuck up. You are expecting that someone will write the entire code for you. You've not even specified what your specific problem is about.
Help me on how to print the names , average mark and comment in descending order.
******************************************************
*******************************************************
c Syntax (Toggle Plain Text)
#include <stdio.h> int N; float array[3]; //declaration of structure struct marks{ char first_name[20]; char second_name[20]; float CSC_2100; float CSC_2101; float CSC_2102; float CSC_2103; float CSC_2104; }; struct marks student[5]; // code to compute average float find_average( float a, float b,float c,float d,float e){ float average = ((a+b+c+d+e)/5); return average; } // to sort the average marks in descending order void bubblesort(float a[], int N) { int i, swapped = 1; while(swapped) for (swapped = 0, i = 1; i<N; i++) if (a[i] > a[i-1]) { int t = a[i-1]; a[i-1]=a[i]; a[i]=t; } } int i; main() { printf("Enter marks for five students:\n\n"); printf("Enter your marks as floats:"); for (i = 0;i < 3; i++){ printf("\n\n"); printf("Enter your First name:"); scanf("%s",&student[i].first_name); printf("Enter your Second Name:"); scanf("%s",&student[i].second_name); printf("Enter marks for CSC 2100:"); scanf("%f",&student[i].CSC_2100); printf("Enter marks for CSC 2101:"); scanf("%f",&student[i].CSC_2101); printf("Enter marks for CSC 2102:"); scanf("%f",&student[i].CSC_2102); printf("Enter marks for CSC 2103:"); scanf("%f",&student[i].CSC_2103); printf("Enter marks for CSC 2104:"); scanf("%f",&student[i].CSC_2104); } for (i =0; i<3; i++){ printf("\n\n"); printf("Name :\t%s %s",student[i].second_name,student[i].first_name); printf("\nAverage: %.2f\t",find_average(student[i].CSC_2100,student[i].CSC_2101,student[i].CSC_2102,student[i].CSC_2103,student[i].CSC_2104)); printf("\nRemark:\t"); } for (i = 0; i<3;i++) array[i]= find_average(student[i].CSC_2100,student[i].CSC_2101,student[i].CSC_2102,student[i].CSC_2103,student[i].CSC_2104); for (i = 0; i<3;i++) bubblesort(array, N); printf("\n"); for (i =0; i < 3; i++){ printf("%.2f\t",array[i]); if (array[i]<50) printf("Sorry try next year"); else printf("congratulations, you passed!"); printf("\n"); } return 0; }
Last edited by Ancient Dragon; Nov 18th, 2007 at 12:25 pm. Reason: add code tags
I suppose you think we are that stupid? That isn't your program because it does not do anything that is required in your assignment that you originally posted. We aren't as dumb as you might think we are.
Trash that entire program and begin a new one. This time we want to see YOUR work, not someone elses.
Trash that entire program and begin a new one. This time we want to see YOUR work, not someone elses.
Last edited by Ancient Dragon; Nov 18th, 2007 at 12:29 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Here you go
You might also try the post titled Read Me: Read This Before Posting as well as this announcement
You might also try the post titled Read Me: Read This Before Posting as well as this announcement
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
![]() |
Similar Threads
- number of times each number in array occurs? (C)
- Print Max Prime Number??? (C++)
- Solution for Ex.4-5 in Acc.C++? (C++)
- Number of times a number appears in an array (C++)
- How can we print an MS Word document from Java (Java)
- List <char *> Problem (C)
- How to code a program that can play sound (C++)
Other Threads in the C Forum
- Previous Thread: functions in c
- Next Thread: help with function in C
| Thread Tools | Search this Thread |
* ansi api array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches initialization intmain() iso km license linked linkedlist linux linuxsegmentationfault list logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string suggestions test unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi






