C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-10-2009, 06:05 AM   #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   Reply With Quote
Old 11-10-2009, 06:12 AM   #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   Reply With Quote
Old 11-10-2009, 06:18 AM   #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   Reply With Quote
Old 11-10-2009, 06:49 AM   #4
Registered User
 
Join Date: Nov 2009
Posts: 6
yes i did run the code.. and this was the output
nikki86 is offline   Reply With Quote
Old 11-10-2009, 06:52 AM   #5
Registered User
 
Join Date: Oct 2009
Location: While(1)
Posts: 316
Quote:
Originally Posted by nikki86 View Post
yes i did run the code.. and this was the output
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   Reply With Quote
Old 11-12-2009, 07:50 AM   #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   Reply With Quote
Old 11-13-2009, 06:18 AM   #7
Registered User
 
Join Date: Nov 2009
Posts: 6
help urgent

Quote:
Originally Posted by nikki86 View Post
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
need help with this type of output
nikki86 is offline   Reply With Quote
Old 11-13-2009, 06:47 AM   #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   Reply With Quote
Old 11-13-2009, 09:44 PM   #9
Registered User
 
Join Date: Nov 2009
Posts: 6
Quote:
Originally Posted by nikki86 View Post
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
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   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 03:48 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22