Skip to content

Instantly share code, notes, and snippets.

View ThePratikSah's full-sized avatar
🏠
Working from home

Pratik Sah ThePratikSah

🏠
Working from home
View GitHub Profile
Datatypes | Range | Bytes | Format
signed char | -128 to +127 | 1 | %c
unsigned char | 0to 255 | 1 | %c
short signed int | -32768 to +32767 | 2 | %d
short unsigned int | 0 to 65535 | 2 | %u
signed int | -32768 to +32767 | 2 | %d
unsigned int | 0 to 65535 | 2 | %u
long signed int | -2147483648 to +2147483647 | 4 | %ld
long unsigned int | 0 to 4294967295 | 4 | %lu
float | -3.4eˆ38 to +3.4eˆ38 | 4 | %f
/*
Author: Pratik Sah
Topic: Using If statement
*/
main(){
if (condition) { //'{ }' for multiple statements
statement 1;
statement 2;
}
}
/*
A simple program to find a negative number
Author: Pratik Sah
*/
main(){
int n;
printf("Enter any number: ");
scanf("%d", &n);
/*
Author: Pratik Sah
Date: 30-03-17
*/
main(){
int n;
printf("Enter any number:");
scanf("%d",&n);
/*
Author: Pratik Sah
Date: 01-04-17
*/
main(){
int n;
printf("Enter any number:");
scanf("%d", &n);
if (n%2==0)
/*
Author: Pratik Sah
Topic: Syntax of nested if else statement
*/
main(){
if (condition) {
statement 1;
statement 2;
}
else
/*
Author: Pratik Sah
Date: 01-04-17
*/
main(){
int n;
printf("Enter any number:");
scanf("%d", &n);
if (n<0)
printf("-ve number.");
/*
Author: Pratik Sah
Date: 01-04-17
*/
main(){
int a,b,c;
printf("Enter any three numbers:\n");
scanf("%d%d%d", &a,&b,&c);
if (a>b && a>c)
printf("%d is greatest.", a);
/*
Author: Pratik Sah
Topic: Syntax of if else statement
*/
main(){
if (condition) {
statement 1;
statement 2;
}
else {
switch (expression) {
case 1: //block 1 statement;
break;
case 2: //block 2 statement;
break;
....
....
default: //default statement;
}