Answers for "print string c"

C
0

console readline c

Here, take input from the user. Since age is an integer, we typecasted it using Convert.ToInt32() Method. It reads the next line from the input stream. It blocks until Enter key is pressed. Hence it is commonly used to pause the console so that the user can check the output.

// C# program to illustrate 
// the use of Console.ReadLine() 
using System; 
using System.IO; 
  
class GFG { 
      
    // Main Method 
    public static void Main() 
    { 
        int age; 
        string name; 
  
        Console.WriteLine("Enter your name: "); 
          
        // using the method 
        // typecasting not needed  
        // as ReadLine returns string 
        name = Console.ReadLine(); 
          
        Console.WriteLine("Enter your age: "); 
          
        // Converted string to int 
        age = Convert.ToInt32(Console.ReadLine()); 
          
        if (age >= 18)  
        { 
            Console.WriteLine("Hello " + name + "!"
                        + " You can vote"); 
        } 
        else { 
            Console.WriteLine("Hello " + name + "!"
                + " Sorry you can't vote"); 
        } 
    }  
}
Posted by: Guest on April-04-2020
1

print in c

printf()
Posted by: Guest on March-27-2020
0

printing out 2 strings in c

// Use of Getstring 
#include<stdio.h>
int main(){
char name[100];
int age;
printf("Enter your name\n");
gets(name);
printf("your name is %s", name);
}
//In the terminal your name is (name input)
Posted by: Guest on February-03-2021

Code answers related to "C"

Browse Popular Code Answers by Language