| | |
help me
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Solved Threads: 0
I must to write i program in C which will carry into clause(sentence) from keyboard and count how much "," have how much spaces " " have and how much times occur the word "The" for every clause(sentence). And in the end program when you carry into clause(sentence) must print all inputs particular for every clause how and the same clauses also? I must use array.
EX:
the problem is, my and, is big
In this sentence you have 6 spaces 2 full stops and word "The" is occure 1
I write some code but is not full i need someone to help me to finish the code on this program
EX:
the problem is, my and, is big
In this sentence you have 6 spaces 2 full stops and word "The" is occure 1
I write some code but is not full i need someone to help me to finish the code on this program
c Syntax (Toggle Plain Text)
#include<stdio.h> #include<string.h> #define MAX 100 int main() { char sentence[100]; int spaces=0,full_stop=0; puts("Enter sentence"); gets(sentence); for(i=0;sentence[i]!='\0';i++) { if (sentence[i]==',') full_stop+=1; if (sentence[i]==' ') spaces+=1; } printf(" %d %d %d %d pati\n",full_stop,spaces); return 0; }
Last edited by Ancient Dragon; Dec 5th, 2007 at 9:40 pm. Reason: add code tags
Do the program one step at a time and soon you will have it done. Looks like you have the first two requirements written -- counting the commas and spaces. Next you will probably want to count the number of "the" words. After line 16 add another loop using strtok() to extract the words.
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.
>>strtok() I dont have learn about this funktion and i dont know how to use it
Did you think to search google for it? There are hundreds of example to follow, such as this one.
>>i realy dont have any idea ?
Get the above working first and worry about the rest after that. Do a little at a time and you will not get so overwhelmed.
Did you think to search google for it? There are hundreds of example to follow, such as this one.
>>i realy dont have any idea ?
Get the above working first and worry about the rest after that. Do a little at a time and you will not get so overwhelmed.
Last edited by Ancient Dragon; Dec 5th, 2007 at 11:24 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.
•
•
Join Date: Dec 2007
Posts: 3
Reputation:
Solved Threads: 0
Here I write some code for my task but it doesent work.
Please someone to chack my code and to correcte my code
Please someone to chack my code and to correcte my code
c Syntax (Toggle Plain Text)
#include <stdio.h> #include<string.h> int main() { char c[100][100],az='a'; int n=0,t=0,t1=-1,k1=0,k2=0; int i1[1000],u1=0; int zap[1000],pra_m[1000],sog[1000],the[1000]; printf("Enter how much sentence do you wont\n n="); scanf("%d",&n); printf("Enter the sentence who will be separate vith full stop.\n"); int i=0,ii=0,iii=0; for(k1=0;k1<1000;k1++) { i1[k1]=-1;ako[k1]=0;zap[k1]=0;pra_m[k1]=0;sog[k1]=0; } while((t!=n)&&(t1!=n)) { scanf("%c",&c[i][u1]); if(c[i][u1]=='\n') { t1++;u1++;i=0;iii=0; } i++;i1[u1]++; if(iii==0) i=0; iii++; if(ii==0) { u1=0; i=0; } } for(k1=0;k1<n;k1++) for(k2=0;k2<=i1[k1];k2++) { if(c[k2][k1]==',') { zap[k1]++; } if(c[k2][k1]==' ') { pra_m[k1]++; } if(c[k2][k1]=='t') if(c[k2][k1]=='h') if(c[k2][k1]=='e') the[k1]++; for(az='a';az<='z';az++) { if(c[k2][k1]==az) if(c[k2][k1]!='a'&&c[k2][k1]!='e'&&c[k2][k1]!='i'&&c[k2][k1]!='o'&&c[k2][k1]!='u') sog[k1]++; } } printf("\n\n"); for(k1=0;k1<n;k1++) { printf("zapirki-> %d\n",zap[k1]); printf("prazni mesta-> %d\n",pra_m[k1]); printf("The-> %d\n",the[k1]); printf("soglaski -> %d\n",sog[k1]); } return 0; }
Last edited by Narue; Dec 6th, 2007 at 4:54 pm. Reason: Added code tags
•
•
•
•
Here I write some code for my task but it doesent work.
Please someone to chack my code and to correcte my code
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
![]() |
Other Threads in the C Forum
- Previous Thread: array help
- Next Thread: comparing and doing something between two Linked List
Views: 834 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for C
#include * append array arrays bash binarysearch changingto char character cm command copyanyfile copypdffile createprocess() database directory drawing dynamic execv feet fgets file floatingpointvalidation fork framework function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes read recursion recv recvblocked reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi






