472,789 Members | 856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,789 software developers and data experts.

Please help me>>>>

how to wirte C program to calculate and print the number of different symbols used in a given string. A blank space counts as one symbol.

Input: Any string. The length is limited to 60 characters. For example:

Enter a string: Mississipi

Test data:
#1. “Say good bye!”
#2. “The world is round”

Output: The number of different symbols. For example, the output for the string “Mississipi” is

Number of symbols for the string “Mississippi” is: 4
can you help me....
Oct 19 '08 #1
2 1095
Declare one array of charachters for storing unique symbols and called symbols[100], and declare one integer n for storing the number of symbols and set it intially to zero, and an integer called test to check if a symbol in the string is repeated, and ofcourse declare an array string[100] to store the string.
Now start with this for loop: for(int i=0 ; i<strlen(string) ; i++) so you can check every symbol in the string, then set the integer test to 0 inside this for loop, then also inside this for loop use another for loop which is: for(int j=0 ; j<n ; j++) to check if this symbol is repeated by using the array symbols[] where j is its index(symbols[j]), and if this symbol(which is string[i]) is found in the array symbols[] then set the integer test to 1 and break from the second loop, and if it is not found set it to 0. Now after the second for loop is finished(either way) check the integer test, if it is equal to 0 put this symbol(which is symbol[i]) in the the array symbols(i.e: write symbols[n] = string[i]) and then increment n( meaning n++ ). But if test is equal to 1 do nothing(meaning the charachter string[i] is present more than once in the string), and here the first for loop is repeated.
And now you have the number of symbols, which is n.
Oct 19 '08 #2
thanks very much..........................
Oct 20 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
by: Mike Hnatt | last post by:
I thought it would be something like an "eval" but it is not. I want to refer to an object called "myobject". I can normally do this: document.myobject.innerText= "43" But since I don't...
by: Andrzej Wegrzyn | last post by:
Hi, I had a portal that worked before, and over 5 months period JavaScript errors started to show up on all forms where I have datagrids. Using: IE 6.0, WIN XP, IIS 5.1, Framework 1.1 ...
by: mit | last post by:
Hello friends , Here i have problem. I want to make the online job web site .But i donts know much about asp.net .so if any body provide me suggestion to how to create online resume database...
by: Fazal | last post by:
Hi, I'am developing a project for training management in a company where the department trains the internal employees. I have been given the job to display the reports. Where I got stuck with...
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
by: aze | last post by:
Hi, I have a 2 c files (pdfp.c, PrinterUtils.c) and 1 .h file (PrinterUtils.h) and 1 .mak file (pdfp.mak). What I need to do is compile these files into a dll so I can use them in my asp.net...
by: blogger | last post by:
i try use this script but keep getting Char: 6 Error: Expected ';' What can i do? <SCRIPT type="text/javascript"> /*Script distributed by Hypergurl.com Visit ...
by: dragony2000 | last post by:
I want to solve these questions using C# , Please !!! ************************************************************* 1- The factorial method is used frequently in probability problems. The...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.