First Commit
This commit is contained in:
20
ArithmeticOperations.c
Normal file
20
ArithmeticOperations.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
ArithmeticOperations.exe
Normal file
BIN
ArithmeticOperations.exe
Normal file
Binary file not shown.
12
BitwiseOperators.c
Normal file
12
BitwiseOperators.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
BitwiseOperators.exe
Normal file
BIN
BitwiseOperators.exe
Normal file
Binary file not shown.
8
DataTypeSize.c
Normal file
8
DataTypeSize.c
Normal file
@@ -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));
|
||||
}
|
||||
BIN
DataTypeSize.exe
Normal file
BIN
DataTypeSize.exe
Normal file
Binary file not shown.
5
HelloWorld.c
Normal file
5
HelloWorld.c
Normal file
@@ -0,0 +1,5 @@
|
||||
// WAP to print "Hello World!".
|
||||
|
||||
void main() {
|
||||
printf("Hello World! \n");
|
||||
}
|
||||
BIN
HelloWorld.exe
Normal file
BIN
HelloWorld.exe
Normal file
Binary file not shown.
8
InputAndPrint.c
Normal file
8
InputAndPrint.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
InputAndPrint.exe
Normal file
BIN
InputAndPrint.exe
Normal file
Binary file not shown.
9
MaximumNo.c
Normal file
9
MaximumNo.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
MaximumNo.exe
Normal file
BIN
MaximumNo.exe
Normal file
Binary file not shown.
9
MaximumNo3.c
Normal file
9
MaximumNo3.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
MaximumNo3.exe
Normal file
BIN
MaximumNo3.exe
Normal file
Binary file not shown.
12
Order Of Programs.md
Normal file
12
Order Of Programs.md
Normal file
@@ -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 |
|
||||
22
README.md
Normal file
22
README.md
Normal file
@@ -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).
|
||||
16
ShortHandArithmeticOperations.c
Normal file
16
ShortHandArithmeticOperations.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
ShortHandArithmeticOperations.exe
Normal file
BIN
ShortHandArithmeticOperations.exe
Normal file
Binary file not shown.
9
SolveExpressions.c
Normal file
9
SolveExpressions.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
SolveExpressions.exe
Normal file
BIN
SolveExpressions.exe
Normal file
Binary file not shown.
8
VariablesPrintOut.c
Normal file
8
VariablesPrintOut.c
Normal file
@@ -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);
|
||||
}
|
||||
BIN
VariablesPrintOut.exe
Normal file
BIN
VariablesPrintOut.exe
Normal file
Binary file not shown.
Reference in New Issue
Block a user