![]() |
| | #1 |
| Registered User Join Date: Nov 2009
Posts: 6
| help in this code Code:
#include<stdio.h>
#include<conio.h>
#define N 50
void main()
{
char str[N+1]="aabccbbdds";
char ch;
int i=0;
int count[26]={0};
clrscr();
while((ch=str[i])!='\0')
{
count[ch-'a']++;
i++;
}
for(i=0;i<26;i++)
{
if(count[i])
{
printf("%c %d \n",i+'a',count[i]);
}
}
getch();
}
/* out put*/ a 2 b 3 c 2 d 2 s 1 /* but i want it should only give me repeating character and its frequency and in next line it should show me the those char which are non repeating one*/ can you help me plzzzzzz |
| nikki86 is offline | |
| | #2 |
| Registered User Join Date: Oct 2009 Location: While(1)
Posts: 316
| Did u run your code the output you want is coming from your code miss |
| RockyMarrone is offline | |
| | #3 |
| Registered User Join Date: Oct 2009 Location: While(1)
Posts: 316
| And one more thing please use int main instead of void main as in C and in C++ always return type of main is int because we have to tell the system the execution status of the program |
| RockyMarrone is offline | |
| | #4 |
| Registered User Join Date: Nov 2009
Posts: 6
| yes i did run the code.. and this was the output |
| nikki86 is offline | |
| | #5 |
| Registered User Join Date: Oct 2009 Location: While(1)
Posts: 316
| Hey i think i miss understood your question may this modified version of your code can help you out Code: #include<stdio.h>
#define N 50
void main()
{
char str[N+1]="aabccbbdds";
char ch;
int i=0;
int count[26]={0};
while((ch=str[i])!='\0')
{
count[ch-'a']++;
i++;
}
for(i=0;i<26;i++)
{
#if 0
if(count[i])
{
printf("%c %d \n",i+'a',count[i]);
}
#else
printf("%c %d \n",i+'a',count[i]);
#endif
}
}
|
| RockyMarrone is offline | |
| | #6 |
| Registered User Join Date: Nov 2009
Posts: 6
| not working properly please help need this not able to figure it out... thank you in advance what i want is if i enter a string BIOINFORMATICS the output should be:: non repeated characters are:: BNFRMATCS repeated charaters are:: I 3 O 2 Last edited by nikki86; 11-13-2009 at 06:17 AM. |
| nikki86 is offline | |
| | #7 |
| Registered User Join Date: Nov 2009
Posts: 6
| help urgent |
| nikki86 is offline | |
| | #8 |
| Registered User Join Date: Oct 2009 Location: While(1)
Posts: 316
| i think first of all you should create another thread for another question and please first try out yourself |
| RockyMarrone is offline | |
| | #9 | |
| Registered User Join Date: Nov 2009
Posts: 6
| Quote:
Code:
#include<stdio.h>
#define N 50
void main()
{
char str[N+1]="BIOINFORMATICS";
char ch;
int i=0;
int count[26]={0};
while((ch=str[i])!='\0')
{
count[ch-'a']++;
i++;
}
for(i=0;i<26;i++)
{
if(count[i])
{
printf("%c %d \n",i+'a',count[i]);
}
else
{
printf("%c %d \n",i+'a',count[i]);
{
}
}
No this was the same question for this code ..... I DONT WANT THE OUTPUT THIS CODE IS GIVING...... INSTEAD I WANT TO GET OUTPUT AS I HAVE GIVEN IN QUOTE | |
| nikki86 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extended ASCII Characters in an RTF Control | JustMax | C Programming | 18 | 04-03-2009 08:20 PM |
| Enforcing Machine Code Restrictions? | SMurf | Tech Board | 21 | 03-30-2009 07:34 AM |
| Obfuscated Code Contest | Stack Overflow | Contests Board | 51 | 01-21-2005 04:17 PM |
| Interface Question | smog890 | C Programming | 11 | 06-03-2002 05:06 PM |
| Who will map the scan code (inserted by VKD_Force_keys) to virtual key code? | Unregistered | Windows Programming | 0 | 02-21-2002 06:05 PM |