To display a line in C#, use the Console.WriteLine().Under that set a blank line −Console.WriteLine(" ");The following is the code that displays a blank line −Example Live Demousing System; namespace Program { public class Demo { public static void Main(String[] args) { Console.WriteLine(" "); Console.WriteLine("Displayed a blank line above!"); Console.ReadLine(); } } }OutputDisplayed a blank line above!
Binary triangle is formed with 0s and 1s. To create one, you need to work around a nestes for loop and display 0s and 1s till the row entered.for (int i = 1; i
To display a line, Console.Write() is used in C#.Console displays the result on the console. I have first set a string.string str = "Tom Hanks is an actor";Now displaying the above line.Console.WriteLine(str);The following is the complete code −Example Live Demousing System; namespace Program { public class Demo { public static void Main(String[] args) { string str = "Tom Hanks is an actor"; Console.WriteLine("Displaying a line below"); Console.WriteLine(str); Console.ReadLine(); } } }OutputDisplaying a line below Tom Hanks is an actor
Yes, to perform an immediate login you have to navigate to Installation directory and use the following start parameters −-h Host name-n Instance number-u User nameUser name with special characters should be enclosed in double quotations (“”).Windows OShdbstudio.exe -h hanademo -n 03 -u HANAADMINhdbstudio.exe -h hanademo -n 03 -u "&hanatest"Linux OShdbstudio -h hana -n 03 –u HANAADMINhdbstudio -h hana -n 03 -u "&hana"Mac OSopen -a /Applications/sap/hdbstudio.app --args -h hana -n 03 -u HANAADMINopen -a /Applications/sap/hdbstudio.app --args -h hana -n 03 -u "&hana"Once you run above from command line, this will open HANA Studio. If you are prompted to enter password ... Read More
With C#, you can easily display the following diamond shape.$ $$$ $$$$$ $$$$$$$ $$$$$$$$$ $$$$$$$ $$$$$ $$$ $To display a diamond shape, you need to focus on the following points −Number of rows Dollar sign to be displayed Empty spacesConsidering the above you can easily create the diamond shape as shown in the below code −Example Live Demousing System; namespace Program { public class Demo { public static void Main(String[] args) { int i, j, r, d, e; // rows = 5 r = 5; // display dollar sign d = 1; // empty space e = r - 1; for (i = 1; i < r * 2; i++) { // display empty space for (j = 1; j
To display multiple blank lines, we will take a while loop.Here, we are printing 10 blank lines using Console.WriteLine();while (a < 10) { Console.WriteLine(" "); a++; }The following is the complete code to display multiple blank lines −Exampleusing System; namespace Program { public class Demo { public static void Main(String[] args) { int a = 0; while (a < 10) { Console.WriteLine(" "); a++; } Console.WriteLine("Displayed 10 blank lines above!"); Console.ReadLine(); } } }
To get the maximum occurred character in a string, loop until the length of the given string and find the occurrence.With that, set a new array to calculate −for (int i = 0; i < s.Length; i++) a[s[i]]++; }The values we used above −String s = "livelife!"; int[] a = new int[maxCHARS];Now display the character and the occurrence −for (int i = 0; i < maxCHARS; i++) if (a[i] > 1) { Console.WriteLine("Character " + (char) i); Console.WriteLine("Occurrence = " + a[i] + " times"); }Let us see the complete code ... Read More
Use the Contains() method to check if a string contains a word or not.Set the string −string s = "Together we can do so much!";Now let’s say you need to find the word “much”if (s.Contains("much") == true) { Console.WriteLine("Word found!"); }Let us see the complete code −Example Live Demousing System; public class Demo { public static void Main() { string s = "Together we can do so much!"; if (s.Contains("much") == true) { Console.WriteLine("Word found!"); } else { Console.WriteLine("Word not found!"); } } }OutputWord found!
Use the Equals method to check if an item exists in a C# array.Set string and substring −string subStr = "pqrs"; string[] str = { "abcd", "ijkl", "pqrs", "wxyz" };Now check whether the substring is part of the string or not using the Equals method.if (item.Equals(subStr)) { Console.WriteLine("Item Found"); }Here is the complete code −Example Live Demousing System; namespace Program { public class Demo { public static void Main(String[] args) { string subStr = "pqrs"; string[] str = { "abcd", "ijkl", "pqrs", "wxyz" }; foreach(string item in str) { if (item.Equals(subStr)) { Console.WriteLine("Item Found"); } } } } }OutputItem Found
You can't read user input in an un-initialized pointer. Instead, have a variable of the struct data type and assign its address to pointer before accessing its inner elements by → operatorexample#include struct example{ char name[20]; }; main(){ struct example *ptr; struct example e; puts("enter name"); gets(e.name); ptr=&e; puts(ptr->name); }OutputTypical result of above codeenter name Disha You entered Disha
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP