This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
/* global variable declaration */ | |
int g; | |
int main() { | |
/* local variable declaration */ | |
int a,b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
/* function declaration */ | |
int max(int num1, int num2); | |
int main() { | |
/* local vaariable definiton */ | |
int a = 100; | |
int b = 200; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
words = ['cat', 'dog', 'people'] | |
for w in words: | |
if len(w) > 6: | |
words.insert(0, w) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Measure some strings: | |
movie = ['boogeyman', 'johnwick', 'best'] | |
for m in movie: | |
print(m, len(m)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Filename: success_test.sh | |
CMD="command" #Substitute with command for which you need to test the exit status | |
$CMD | |
if [ $? -eq 0 ]; | |
then | |
echo "$CMD executed successfully" | |
else | |
echo "$CMD terminated unsuccessfully" | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Filename:sleep.sh | |
echo -n Count: | |
tput sc #Store the cursor position. | |
count=0; | |
while true; | |
do | |
if [ $count -lt 40 ] ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#num_sort.plx | |
use warnings; | |
use strict; | |
my @unsorted = (1, 2, 11, 24, 3, 36, 40, 4); | |
my @string = sort { $a cmp $b } @unsorted; #with cmp, we compare $a and $b variables. | |
print "String sort: @string\n"; | |
my @number = sort { $a <=> $b } @unsorted; # <=> helps us to sorting numbers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
#sort_names.plx | |
use warnings; | |
use strict; | |
my @unsorted = qw(Onur Aylin Ayvaz Ferrin); | |
print "Unsorted: @unsorted\n"; | |
my @sorted = sort @unsorted; #sort function puts the words in an alphabetical order. | |
print "Sorted: @sorted\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
float sales; | |
float salary; | |
while(sales != -1) { | |
printf("Enter sales in dollars (-1 to end): "); | |
scanf("%f",&sales); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
int n; | |
int fact = 1; | |
printf("Enter an integer that you want to take the factorial of: "); | |
scanf("%d",&n); | |
NewerOlder