Programming Basic

Programming basic
1. Declare variable , Get input and print output in console.

[C Programming]

char s[]; char c; int i; float f;

printf("Enter your website name: ");
scanf("%s", str);
printf("Entered Website:%s", str);

scanf("%d", i);    // integer along with +, - int
scanf("%c", c );   //char single char // char* is string
scanf("%f", f);    //float   others :  e,E,f,g,G
scanf("%lf", f);   //double
scanf("%.2lf", f);   //double 2 decimal digit

scanf("%s", str);                      // string with out space
scanf("%[^\n]", input_string);  // read full line and save to variable

[Javascript]


var a; // It is any data type

console.log("hello");
 process.stdout.write("Hello, World.");


[PHP]

$_fp = fopen("php://stdin", "r");   //open
$inputString = fgets($_fp);  // get a line of input from stdin and save it to our variable
print("Hello, World.\n");    // output
fclose($_fp); //close

[JAVA]

Scanner scan = new Scanner(System.in); //create scanner object to read from stdin
String strinput         = scan.nextLine();       // read full line and save to string variable
double numdouble = scan.nextDouble();
int  numint = scan.nextInt();
scan.close();                                              //close scanner object
System.out.println("Hello, World.");       // display output with stdout

Share this

Related Posts

Previous
Next Post »