Skip to content

Instantly share code, notes, and snippets.

@LokieVikky
Created February 15, 2023 13:03
Show Gist options
  • Save LokieVikky/198c8c6ca1d80c311ee768774df6189e to your computer and use it in GitHub Desktop.
Save LokieVikky/198c8c6ca1d80c311ee768774df6189e to your computer and use it in GitHub Desktop.
// void main() {
// printName();
// functionWithArgs("SomeName");
// int result = functionWithReturnType();
// print(result);
// functionWithArgs2('SomeName', 1);
// functionWithOptionalParameter(age: 1,name:'Naveen');
// }
// // void - returns nothing
// // function defenition
// // returnType functionName(...args...){}
// void printName() {
// print('SomeName');
// }
// void functionWithArgs(String name) {
// print(name);
// }
// void functionWithArgs2(String name, int age) {
// print(name);
// print(age);
// }
// int functionWithReturnType() {
// return 5;
// }
// void functionWithOptionalParameter({required String name, int age = 0}) {
// print(name);
// print(age);
// // if (name != null) {
// // }
// // if (age != null) {
// // }
// }
// void main() {
// String name = 'Naveen,Parthiban,Lokesh,Lingesh';
// List<String> names = name.split(',');
// int index = 0;
// while (index < names.length) {
// print(names[index]);
// index++;
// }
// int i = 1;
// while (i < 200) {
// bool result = isPrimeNumber(i);
// if (result == true) {
// print(i);
// }
// i++;
// }
// }
// bool isPrimeNumber(int number) {
// int a = number;
// int b = 1;
// List<int> factors = [];
// while (a >= b) {
// if ((a % b) == 0) {
// factors.add(b);
// }
// b++;
// }
// if (factors.length == 2) {
// return true;
// }
// return false;
// }
// void main() {
// String name = 'Naveen';
// String reversed = '';
// int i = name.length;
// while (i > 0) {
// reversed = reversed + name[i - 1];
// i--;
// }
// print(reversed);
// }
// void main() {
// String name = 'Naveen';
// List<String> reversed = [];
// int i = name.length;
// while (i > 0) {
// print(name[i-1]);
// reversed.add(name[i-1]);
// i--;
// }
// print(reversed.join());
// }
// for(initialaztion;condition;increment/decrement){}
// void main() {
// for (int i = 0; i <= 10; i++) {
// print(i);
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment