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
use std::collections::HashMap; | |
fn call(number: &str) -> &str { | |
match number { | |
"798-1364" => "We're sorry, the call cannot be completed as dialed. | |
Please hang up and try again.", | |
"645-7689" => "Hello, this is Mr. Awesome's Pizza. My name is Fred. | |
What can I get for you today?", | |
_ => "Hi! Who is this again?" | |
} |
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
/* | |
* C program to input N numbers and store them in an array. | |
* Do a linear search for a given key and report success | |
* or failure. | |
*/ | |
#include <stdio.h> | |
void main() | |
{ | |
int array[10]; |
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
/* | |
* C program to Calculate the value of nCr | |
*/ | |
#include <stdio.h> | |
int fact(int z); | |
void main() | |
{ | |
int n, r, ncr; |
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
/* | |
* C Program to Collect Statistics of a Source File like Total Lines, | |
* Total no. of Blank Lines, Total no. of Lines ending with Semicolon | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
void main(int argc, char *argv[]) /* Command line Arguments */ | |
{ | |
int ncount = 0, ccount = 0, scount = 0, blank = 0; |
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
# Program make a simple calculator that can add, subtract, multiply and divide using functions | |
# define functions | |
def add(x, y): | |
"""This function adds two numbers""" | |
return x + y | |
def subtract(x, y): | |
"""This function subtracts two 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
# Solve the quadratic equation ax**2 + bx + c = 0 | |
# Coeffients a, b and c are provided by the user | |
# import complex math module | |
import cmath | |
a = float(input('Enter a: ')) | |
b = float(input('Enter b: ')) | |
c = float(input('Enter c: ')) |
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
# Python program to display calendar of given month of the year | |
# import module | |
import calendar | |
# ask of month and year | |
yy = int(input("Enter year: ")) | |
mm = int(input("Enter month: ")) | |
# display the calendar |
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
// open.rs | |
use std::error::Error; | |
use std::fs::File; | |
use std::io::prelude::*; | |
use std::path::Path; | |
fn main() { | |
// Create a path to the desired file | |
let path = Path::new("hello.txt"); | |
let display = path.display(); |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <ctype.h> | |
int main(){ | |
int year; | |
printf("Type a year (up to 4 digits) to determine if it's a leap year:"); | |
scanf("%d",&year); | |
getchar(); | |
if(((year<0)||(isalpha(year))||(year>9999))){ | |
printf("Invalid year. Try again.\n"); |
NewerOlder