- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 34488 Articles for Programming
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
22K+ Views
Firstly, set the string −string str = "Website"; Console.WriteLine("String: "+str);Check for every character in the string and increment a variable that would count the number of occurrences of that character −for (int j = 0; j < str.Length; j++) { if (str[0] == str[j]) { cal++; } }ExampleYou can try to run the following code to count the occurrences of each character.Live Demousing System; public class Demo { public static void Main() { string str = "Website"; Console.WriteLine("String: "+str); while (str.Length > 0) { ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
420 Views
I have added the numbers using an array −int[] num = new int[] {1, 25, 1, 55, 1};Now loop through and find for 1, if 1 is there, 6 then increment the variable that counts the occurrence −foreach(int j in num) { if (j == 1) { cal++; } }ExampleThe following is the code to count the number of 1’s in the entered number.Live Demousing System; public class Demo { public static void Main() { int cal = 0; int[] num = new int[] {1, 25, 1, 55, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
582 Views
You need to check for both the vowels and consonants, but do not forget to check for both the uppercase as well lowercase.For counting vowels, check for “aeiou” characters separately i.e.if (myStr[i] == 'a' || myStr[i] == 'e' || myStr[i] == 'i' || myStr[i] == 'o' || myStr[i] == 'u' || myStr[i] == 'A' || myStr[i] == 'E' || myStr[i] == 'I' || myStr[i] == 'O' || myStr[i] == 'U') { vowel_count++; }For counting consonants, check for other characters in elseif condition −else if ((myStr[i] >= 'a' && myStr[i] = 'A' && myStr[i]
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
572 Views
Set the decimal number −int decVal = 40;Now take a variable and set the decVal in it. Find the remainder with 8 since octal has base-8 number system and evaluate it in a loop like the following code snippet.while (quot != 0) { octalVal[i++] = quot % 8; quot = quot / 8; }ExampleYou can try to run the following code to convert decimal to octal number.Live Demousing System; class Demo { public static void Main() { int decVal, quot, i = 1, j; int[] octalVal = new int[80]; ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
376 Views
Let us say the following is your string −String str = "Welcome to our website!";Create a char array of the string included above using the ToCharArray() method:char []ch = str.ToCharArray();To convert the first character to uppercase −if (ch[i] >= 'a' && ch[i] = 'a' && val[i] = 'A' && val[i]
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
2K+ Views
Firstly, set the Fahrenheit temperature −double fahrenheit = 97; Console.WriteLine("Fahrenheit: " + fahrenheit);Now convert it into Celsius −celsius = (fahrenheit - 32) * 5 / 9;ExampleYou can try to run the following code to convert Fahrenheit to Celsius.Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { double celsius; double fahrenheit = 97; Console.WriteLine("Fahrenheit: " + fahrenheit); celsius = (fahrenheit - 32) * 5 / 9; Console.WriteLine("Celsius: " + celsius); Console.ReadLine(); } } }OutputFahrenheit: 97 Celsius: 36.1111111111111
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
920 Views
Let’ s say you have set the decimal to be −decVal = 34; Console.WriteLine("Decimal: {0}", decVal);Use the ToString() method for the values you get as a binary number for the decimal value −while (decVal >= 1) { val = decVal / 2; a += (decVal % 2).ToString(); decVal = val; }Now set a new empty variable to display the binary number using a loop −string binValue = "";ExampleYou can try to run the following code to convert decimal to binary in C#.Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Firstly, declare the words from 0 to 9 −// words for every digits from 0 to 9 string[] digits_words = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };The following are the digits to be converted to words −// number to be converted into words val = 4677; Console.WriteLine("Number: " + val);Use the loop to check for every digit in the given number and convert into words −do { next = val % 10; a[num_digits] = next; num_digits++; val = val / 10; } while(val > 0);ExampleYou can try to ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
393 Views
Let’s say your string is −str = "AMIT";To convert the above uppercase string in lowercase, use the ToLower() method −Console.WriteLine("Converted to LowerCase : {0}", str.ToLower());ExampleThe following is the code in C# to convert character case.Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { string str; str = "AMIT"; Console.WriteLine("UpperCase : {0}", str); // convert to lowercase Console.WriteLine("Converted to LowerCase : {0}", str.ToLower()); Console.ReadLine(); } } }OutputUpperCase : AMIT Converted to LowerCase : amit
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
3K+ Views
Firstly, set the binary value −int num = 101;Now assign the binary to a new variable −binVal = num;Till the value is greater than 0, loop through the binary number and base value like this, while (num > 0) { rem = num % 10; decVal = decVal + rem * baseVal; num = num / 10; baseVal = baseVal * 2; }ExampleThe following is the code to convert binary to decimal.Live Demousing System; using System.Collections.Generic; using System.Text; namespace Demo { class MyApplication { static void Main(string[] args) { ... Read More