commit c3dbda79c42b4e629fe3f4bdfb65e7c492babc0c Author: psavarmattas Date: Sun Apr 25 15:28:50 2021 +0530 First Commit diff --git a/ArithmeticOperations.c b/ArithmeticOperations.c new file mode 100644 index 0000000..34ffc9b --- /dev/null +++ b/ArithmeticOperations.c @@ -0,0 +1,20 @@ +// WAP to perform arithmetic operations (addition, subtraction, multiplication, division, modulo). + +void main() { + int a,b; + int sum,sub,multiply, mod; + float div; + a=10; + b=20; + sum=a+b; + sub=a-b; + multiply=a*b; + div=(float)a/b; + mod=a%b; + printf("Value of a = %d & b = %d \n", a,b); + printf("Sum = %d\n", sum); + printf("Difference = %d\n", sub); + printf("Product = %d\n", multiply); + printf("Quotient = %f\n", div); + printf("Modulus = %d", mod); +} diff --git a/ArithmeticOperations.exe b/ArithmeticOperations.exe new file mode 100644 index 0000000..b897b24 Binary files /dev/null and b/ArithmeticOperations.exe differ diff --git a/BitwiseOperators.c b/BitwiseOperators.c new file mode 100644 index 0000000..765b4ce --- /dev/null +++ b/BitwiseOperators.c @@ -0,0 +1,12 @@ +// WAP to perform bitwise operators. + +void main() +{ + int a = 12, b = 25; + printf("Values of a = %d, b = %d \n", a, b); + printf("Output for AND = %d\n", a&b); + printf("Output for OR = %d\n", a|b); + printf("Output for XOR = %d\n", a^b); + printf("Output for left shift to 3 = %d\n",a<<3); + printf("Output for right shift to 2 = %d\n",a>>2); +} diff --git a/BitwiseOperators.exe b/BitwiseOperators.exe new file mode 100644 index 0000000..0bb56ad Binary files /dev/null and b/BitwiseOperators.exe differ diff --git a/DataTypeSize.c b/DataTypeSize.c new file mode 100644 index 0000000..04fd905 --- /dev/null +++ b/DataTypeSize.c @@ -0,0 +1,8 @@ +// WAP to check size of following data types: char,int,float, double. + +void main() { + printf("Size of char data type : %d\n",sizeof(char)); + printf("Size of int data type : %d\n",sizeof(int)); + printf("Size of float data type : %d\n",sizeof(float)); + printf("Size of double data type : %d\n",sizeof(double)); +} diff --git a/DataTypeSize.exe b/DataTypeSize.exe new file mode 100644 index 0000000..20330c2 Binary files /dev/null and b/DataTypeSize.exe differ diff --git a/HelloWorld.c b/HelloWorld.c new file mode 100644 index 0000000..9742106 --- /dev/null +++ b/HelloWorld.c @@ -0,0 +1,5 @@ +// WAP to print "Hello World!". + +void main() { + printf("Hello World! \n"); +} \ No newline at end of file diff --git a/HelloWorld.exe b/HelloWorld.exe new file mode 100644 index 0000000..b67a7ae Binary files /dev/null and b/HelloWorld.exe differ diff --git a/InputAndPrint.c b/InputAndPrint.c new file mode 100644 index 0000000..a9c5f74 --- /dev/null +++ b/InputAndPrint.c @@ -0,0 +1,8 @@ +// WAP to take input from the keyboard & print the same value on the output screen. + +void main() { + int a,b; + printf("Enter the values of a & b\n"); + scanf("%d\n%d",&a,&b); + printf("The value of a=%d \nThe value of b=%d",a,b); +} diff --git a/InputAndPrint.exe b/InputAndPrint.exe new file mode 100644 index 0000000..fe8e859 Binary files /dev/null and b/InputAndPrint.exe differ diff --git a/MaximumNo.c b/MaximumNo.c new file mode 100644 index 0000000..056fb47 --- /dev/null +++ b/MaximumNo.c @@ -0,0 +1,9 @@ +// WAP to find maximum number using conditional operator. + +void main() { + int a,b,max; + printf("Enter the two numbers\n"); + scanf("%d%d",&a,&b); + max=(a>b)?a:b; + printf("Maximum between %d and %d is %d",a,b,max); +} diff --git a/MaximumNo.exe b/MaximumNo.exe new file mode 100644 index 0000000..f245383 Binary files /dev/null and b/MaximumNo.exe differ diff --git a/MaximumNo3.c b/MaximumNo3.c new file mode 100644 index 0000000..e6cc3f8 --- /dev/null +++ b/MaximumNo3.c @@ -0,0 +1,9 @@ +// WAP to find maximum out of three number using conditional operator. + +void main() { + int a,b,c,max; + printf("Enter 3 numbers:\n"); + scanf("%d %d %d",&a,&b,&c); + max = a > b ? ( a > c ? a : c ) : ( b > c ? b : c); + printf("\nThe biggest number between %d, %d & %d is: %d",a,b,c,max); +} \ No newline at end of file diff --git a/MaximumNo3.exe b/MaximumNo3.exe new file mode 100644 index 0000000..aa7a0f9 Binary files /dev/null and b/MaximumNo3.exe differ diff --git a/Order Of Programs.md b/Order Of Programs.md new file mode 100644 index 0000000..f0dd57d --- /dev/null +++ b/Order Of Programs.md @@ -0,0 +1,12 @@ +| Serial No. | Program Name | Executable File | Description of the program | +|------------|------------|---------------|--------------------------| +|1 | HelloWorld.c | HelloWorld.exe | WAP to print "Hello World!" | +|2 | VariablesPrintOut.c | VariablesPrintOut.exe | WAP to print values of two different variables on the output screen | +|3 | InputAndPrint.c | InputAndPrint.exe | WAP to take input from the keyboard & print the same value on the output screen | +|4 | ArithmeticOperations.c | ArithmeticOperations.exe | WAP to perform arithmetic operations (addition, subtraction, multiplication, division, modulo) | +|5 | MaximumNo.c | MaximumNo.exe | WAP to find maximum number using conditional operator | +|6 | ShortHandArithmeticOperations.c | ShortHandArithmeticOperations.exe | WAP to perform arithmetic operations (addition, subtraction, multiplication, division) by using shorthand operators | +|7 | SolveExpressions.c | SolveExpressions.exe | WAP to solve following expressions. r1= (a++) + (a++) & r2= (--a) + (a--). +|8 | MaximumNo3.c | MaximumNo3.exe | WAP to find maximum out of three number using conditional operator | +|9 | DataTypeSize.c | DataTypeSize.exe | WAP to check size of following data types: char,int,float, double | +|10 | BitwiseOperators.c | BitwiseOperators.exe | WAP to perform bitwise operators | \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..cad7690 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# C Programs For Everybody To Try! + +_`Last Updated: April 25' 2021`_ + +## Introduction: + +Here are programs that every budding programmer who is learning to code in C should start with. +These programs are a compilation of many different types of programs and levels of programming you should try. +You can use the table in Order Of Programs file to find the order in which it is best to program in. + +## Pre-Requisites: + +1. A coding IDE or just use the CMD/Terminal on your Windows Pc/Mac respectively (I used VS Code for this). + +2. Check that C/C++ Extension is properly installed in your system/VS Code and the Path to C/C++ is integratively set in your system. + +3. Start by trying to create the program by yourself if you encounter any problems refer to the code in the program file, +if the problem still persist then create a issue or use Google/Stack Overlflow for help. + +4. Done! You have successfully created the program in C by your own. + +Note: All the exe files are provided to make sure the program code runs when I create them (Tested on Windows 10). \ No newline at end of file diff --git a/ShortHandArithmeticOperations.c b/ShortHandArithmeticOperations.c new file mode 100644 index 0000000..e0ba317 --- /dev/null +++ b/ShortHandArithmeticOperations.c @@ -0,0 +1,16 @@ +// WAP to perform arithmetic operations (addition, subtraction, multiplication, division) by using shorthand operators. + +void main() { + int a,b; + a=5; + b=5; + printf("The value of a=%d \nThe value of b=%d\n",a,b); + a+=b; + printf("The sum of a & b = %d\n",a); + a-=b; + printf("The difference of a & b = %d\n",a); + a*=b; + printf("The product of a & b = %d\n",a); + a/=b; + printf("The quotient of a & b = %d\n",a); +} diff --git a/ShortHandArithmeticOperations.exe b/ShortHandArithmeticOperations.exe new file mode 100644 index 0000000..188ecea Binary files /dev/null and b/ShortHandArithmeticOperations.exe differ diff --git a/SolveExpressions.c b/SolveExpressions.c new file mode 100644 index 0000000..a001919 --- /dev/null +++ b/SolveExpressions.c @@ -0,0 +1,9 @@ +// WAP to solve following expressions. r1= (a++) + (a++) & r2= (--a) + (a--). + +void main() { + int a=10,b; + b=(a++)+(a++); + printf("Solve r1=(a++)+(a++)\nThe answer is=%d",b); + b=(--a)+(a--); + printf("\nSolve r2=(--a)+(a--)\nThe answer is=%d",b); +} \ No newline at end of file diff --git a/SolveExpressions.exe b/SolveExpressions.exe new file mode 100644 index 0000000..316a248 Binary files /dev/null and b/SolveExpressions.exe differ diff --git a/VariablesPrintOut.c b/VariablesPrintOut.c new file mode 100644 index 0000000..f23205c --- /dev/null +++ b/VariablesPrintOut.c @@ -0,0 +1,8 @@ +// WAP to print values of two different variables on the output screen. + +void main() { + int a,b; + a=10; + b=12; + printf("The value of a=%d \nThe value of b=%d",a,b); +} diff --git a/VariablesPrintOut.exe b/VariablesPrintOut.exe new file mode 100644 index 0000000..791587c Binary files /dev/null and b/VariablesPrintOut.exe differ