Skip to content

Instantly share code, notes, and snippets.

View sutirthaC97's full-sized avatar
😇
Hi, there!

Sutirtha Chakraborty sutirthaC97

😇
Hi, there!
View GitHub Profile
@sutirthaC97
sutirthaC97 / function-pointer-example.c
Created April 10, 2017 02:46
Function pointer example in C.
#include <stdio.h>
void say(char* s){
printf("%s",s);
}
int main()
{
void (*say_ptr)(char* s) = &say;
say("\nHello!");
@sutirthaC97
sutirthaC97 / enum-example.c
Created April 9, 2017 16:37
Enum example in C program.
#include <stdio.h>
int main()
{
enum weekdays{sun, mon, tue, wed, thu=121, fri, sat};
enum weekdays sunday = sun;
enum weekdays friday = fri;
printf("sunday has the value: %d and friday: %d", sunday, friday);//Here friday has the value 122 because the previous const thu has the value of 121 whilst wed has the value of 3 because sun is initialized to zero.
@sutirthaC97
sutirthaC97 / typedef-example.c
Created April 9, 2017 16:22
Usage of typedef.
#include <stdio.h>
typedef double dbl; //Now dbl can be used anywhere in the program we need to write double.
int main()
{
dbl a = 21.3987;
printf("The value of a is : %lf ", a);
@sutirthaC97
sutirthaC97 / datatypes-example.c
Last active April 9, 2017 16:13 — forked from anonymous/datatypes-example.c
An example C program demonstrating different data types, their variables and their naming conventions.
/*An example C program to demonstrate different data types.*/
#include <stdio.h>
int main()
{
int meaningOfLife = 42;
float a_random_float = 56.9;
double pi = 3.141;
char c = 'c';
@sutirthaC97
sutirthaC97 / preprocessor-example.c
Created April 9, 2017 15:16
An example of a C program where preprocessor directive #define and the mathematical function pow are employed.
/*C program to print area of a circle whose radius is given as input*/
#include <stdio.h>
#include <math.h>//for the function -> pow()
#define pi 3.141
int main(){
double radius, area;
printf("\nEnter the value of the radius: ");
scanf("%lf",&radius);
@sutirthaC97
sutirthaC97 / HelloWorld.c
Created April 9, 2017 14:25
Hello World program
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}