Skip to content

Instantly share code, notes, and snippets.

@LokeshKumarES
LokeshKumarES / L7Q6_Register_Storage_Class_Compilation_Time.c
Created November 5, 2020 13:46
Lets compare the compilation time for all the four storage classes of variable in c.
//Register Storage Class Variable
//Speed Test
#include<stdio.h>
#include<time.h>
int main()
{
register int i;
for(i=1;i<=100000000;i++);
@LokeshKumarES
LokeshKumarES / L7Q6_Automatic_Storage_Class_Compilation_Time.c
Created November 5, 2020 13:44
Lets compare the compilation time for all the four storage classes of variable in c.
//Automatic Storage Class Variable
//Speed Test
#include<stdio.h>
#include<time.h>
int main()
{
auto int i;
for(i=1;i<=100000000;i++);
@LokeshKumarES
LokeshKumarES / L7Q5_External_Storage_Class_Variables_Default_Initial_Value_Scope_Storage_Life.c
Created November 4, 2020 04:57
Write a C program to show the storage, default initial value, scope and life of a external storage class variable.
#include<stdio.h>
int i; //external storage class variable
void increment();
void decrement();
int main()
{
printf("\ni=%d\n",i);
increment();
increment();
decrement();
@LokeshKumarES
LokeshKumarES / L7Q4_Static_Storage_Class_Variables_Default_Initial_Value_Scope_Storage_Life.c
Last active November 4, 2020 05:00
Write a C program to show the storage, default initial value, scope and life of a static storage class variable.
#include<stdio.h>
void increment();
int main()
{
increment();
increment();
increment();
return 0;
}
@LokeshKumarES
LokeshKumarES / L7Q3_Register_Storage_Class_Variables_Default_Initial_Value_Scope_Storage_Life.c
Last active November 2, 2020 07:06
Write a C program to show the storage, default initial value, scope and life of register storage class variables.
#include<stdio.h>
int main()
{
register int i;
for(i=1;i<=10;i++)
printf("%d\n",i);
return 0;
}
@LokeshKumarES
LokeshKumarES / L7Q2_Automatic_Storage_Class_Variable_Memory_Initial_Value_Scope_Life.c
Created November 1, 2020 12:19
Write a C program to show the storage, default initial value, scope and life of automatic storage class variables.
#include<stdio.h>
int main()
{
auto int i, j;
auto int a=1;
//Print garbage value (or unpredictable value)
printf("%d %d\n", i,j);
@LokeshKumarES
LokeshKumarES / L7Q1_Date_Types_Ranges_Size_In_Bytes_And_Format_Specifier.c
Last active October 11, 2020 05:59
Write a program to show the data types, their ranges, sizes and format specifiers.
#include<stdio.h>
//for using bool DataType we used this header file
#include<stdbool.h>
int main()
{
//character
char c;
unsigned char d;
//integer
@LokeshKumarES
LokeshKumarES / L6Q17_Greatest_Common_Divisor.c
Created September 10, 2020 07:09
Write a function to compute the greatest common divisor given by Euclid's algorithm, exemplified for J=1980, K=1617 as follows: Thus, the greates common divisor is 33.
#include<stdio.h>
int gcd(int a, int b);
void main()
{
int a,b;
printf("Enter the value of a: ");
scanf("%d", &a);
printf("Enter the value of b: ");
@LokeshKumarES
LokeshKumarES / L6Q16_Area_And_Distance_Between_Point_Lies_Inside_triangle.c
Created September 8, 2020 07:30
Write a function to compute the distance between two points and use it to develop another function that will compute the area of the triangle whose vertices are A(x1, y1), B(x2, y2), and C(x3, y3). Use these functions to develop a function which returns a value 1 if the point (x, y) lines inside the triangle ABC, otherwise returns a value 0.
#include<stdio.h>
#include<math.h>
void res(float x1, float y1, float x2, float y2, float x3, float y3,
float x, float y, float *area, int *flag);
float distance(float x1, float y1, float x2, float y2);
float cal_area(float a, float b, float c);
int position(float area, float A, float B, float C);
void main()
{
@LokeshKumarES
LokeshKumarES / L6Q15_Area_Of_Triangle_Using_Function.c
Created September 7, 2020 05:42
If the lengths of the sides of a triangle are denoted by a, b, c, then area of triangle is given by area = √(S(S-a)(S-b)(S-c)) Where, S = (a+b+c)/2. Write a function to calculate the area of the triangle.
#include<stdio.h>
#include<math.h>
int area(int a, int b, int c);
void main()
{
int a, b, c;
printf("Enter a: ");
scanf("%d", &a);
printf("Enter b: ");