Skip to content

Commit fca2d61

Browse files
committed
Upload files
0 parents  commit fca2d61

19 files changed

+309
-0
lines changed

AdditionOfTwoArr.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int i, n;
6+
scanf("%d", &n);
7+
8+
double arr1[n], arr2[n], arr[n];
9+
printf("Enter 1st array:");
10+
for(i=0; i<n; i++){
11+
scanf("%lf", &arr1[i]);
12+
}
13+
printf("Enter 2nd array:");
14+
for(i=0; i<n; i++){
15+
scanf("%lf", &arr2[i]);
16+
}
17+
18+
for(i=0; i<n; i++){
19+
arr[i] =arr1[i]+arr2[i];
20+
}
21+
printf("Resultant array");
22+
for(i=0; i<n; i++){
23+
printf("%.2lf ", arr[i]);
24+
}
25+
return 0;
26+
}

area_perimeterOfCircle.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
#define PI 3.14
3+
int main()
4+
{
5+
double radius = 5;
6+
double area = PI * radius * radius;
7+
double perimeter = 2 * PI * radius;
8+
9+
printf("Radius = %.2lf \nArea = %.2lf \nPerimeter = %.2lf\n",radius, area, perimeter);
10+
11+
return 0;
12+
13+
}

area_perimeterOfCircleConst.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
const double PI = 3.14;
6+
double radius = 5;
7+
double area = PI * radius * radius;
8+
double perimeter = 2 * PI * radius;
9+
10+
printf("Area = %.2lf \nRadius = %.2lf \nPerimeter = %.2lf", area, radius, perimeter);
11+
12+
return 0;
13+
}

evaluate.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int d, e;
6+
int a = 10, b = 20, c = 30;
7+
e = ++a, ++b, ++c, a+5;
8+
d = (++a, ++b, ++c, a+5);
9+
printf("%d %d", d, e);
10+
return 0;
11+
}

fifteen.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
char c1 = 'a';
6+
printf("%d %d", sizeof(c1), sizeof('a'));
7+
return 0;
8+
}

fourteen.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int a=10, b;
6+
b = sizeof(++a);
7+
printf("%d %d", a, b);
8+
return 0;
9+
}

ipConversion.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
#define MAX 16
3+
int main()
4+
{
5+
char ip[MAX];
6+
scanf("%s", )
7+
}

maxMinInArray.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
double min, max;
6+
int i, n;
7+
8+
scanf("%d", &n);
9+
double arr[n];
10+
11+
for(i=0; i<n; i++){
12+
scanf("%lf", &arr[i]);
13+
}
14+
15+
min = arr[0];
16+
max = arr[0];
17+
18+
for(i=0; i<n; i++)
19+
{
20+
if(arr[i] < min)
21+
min = arr[i];
22+
else if(arr[i] > max)
23+
max = arr[i];
24+
}
25+
26+
printf("\nMin : %.2lf \nMax : %.2lf", min, max);
27+
return 0;
28+
}

maxMinWithConstants.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
#include <limits.h>
3+
4+
int main()
5+
{
6+
printf("Maximum Number of bits allowed in a byte %d\n",CHAR_BIT);
7+
8+
printf("Maximum Number of characters allowed %d\n", CHAR_MAX);
9+
printf("Maximum Number of integer values allowed %ld\n", INT_MAX);
10+
printf("Maximum Number of long integer values allowed %ld\n", LONG_MAX);
11+
printf("\n");
12+
printf("Minimum Number of characters allowed %ld\n", CHAR_MIN);
13+
printf("Minimum Number of integer values allowed%ld\n", INT_MIN);
14+
printf("Minimum Number of long integer values allowed %ld\n", LONG_MIN);
15+
16+
17+
return 0;
18+
}

maxOfThreeNums.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
5+
{
6+
int num1, num2, num3;
7+
8+
scanf("%d %d %d", &num1, &num2, &num3);
9+
10+
printf("Maximum of three numbers : %d ", (((num1 > num2)&& (num1 > num3))? num1 :(num2 > num3)? num2 : num3));
11+
12+
return 0;
13+
}

patterns/pattern1.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
cin >> n;
9+
for(int i=0; i<n; i++){
10+
for(int j=0; j<=i; j++){
11+
cout << "*";
12+
}
13+
cout << endl;
14+
}
15+
// cout<<"Hello World";
16+
17+
return 0;
18+
}

patterns/pattern2.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
cin >> n;
9+
for(int i=1; i<=n; i++){
10+
for(int j=1; j<=n; j++){
11+
if(i+j >=n+1)
12+
cout << "*";
13+
else
14+
cout << " ";
15+
}
16+
cout << endl;
17+
}
18+
// cout<<"Hello World";
19+
20+
return 0;
21+
}

patterns/pattern3.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
cin >> n;
9+
for(int i=1; i<=n; i++){
10+
for(int j=n; j>=i; j--){
11+
cout << "*";
12+
}
13+
cout << endl;
14+
}
15+
// cout<<"Hello World";
16+
17+
return 0;
18+
}

patterns/pattern4.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
cin >> n;
9+
for(int i=1; i<=n; i++){
10+
for(int j=n; j>=i; j--){
11+
cout << "*";
12+
}
13+
cout << endl;
14+
}
15+
// cout<<"Hello World";
16+
17+
return 0;
18+
}

postfixAndPrefix.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
postfix operator:
2+
3+
A postfix operator is a unary operator which works only on single operand to increment or decrement value of an operand.
4+
5+
It does the operation only when the statement gets terminated.
6+
7+
For example,
8+
k = i++ // Directly assigns i value to k and after assignment i is incremented.
9+
y = x++ * 10 // the current value of x is multiplied with 10 and after assignment x is incremented.
10+
q = p-- / 3 // the current value of p is divided by 3 and after assignment p is decremented.
11+
12+
13+
14+
15+
Prefix operator:
16+
17+
A prefix operator is a unary operator which is similar to postfix in use but it does the increment/decrement operation first.
18+
19+
It does the operation before the value of operand is used in an expression.
20+
21+
For example,
22+
k = ++i; // i is incremented and assigned
23+
y = ++x * 10 // x is incremented and that value is multiplied with 10 and assigned
24+
q = --p / 3 // p is decremented and that value is divided by 3 and assigned.
25+

reversingNum.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
5+
{
6+
int num, rem, revDigits = 0;
7+
scanf("%d", &num);
8+
9+
while(num > 0)
10+
{
11+
rem = num % 10;
12+
revDigits = revDigits*10 + rem;
13+
num = num /10;
14+
}
15+
16+
printf("%d", revDigits);
17+
return 0;
18+
}

sizeofOperator.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
5+
{
6+
printf("Int : %lu \nLong : %lu \nFloat : %lu \nChar : %lu \nDouble : %lu\n", sizeof(int), sizeof(long), sizeof(float), sizeof(char), sizeof(double));
7+
return 0;
8+
}
9+

sumAndAvgInArr.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int n, i;
6+
double avg, sum=0;
7+
8+
scanf("%d", &n);
9+
10+
double arr[n];
11+
for(i =0; i<n; i++){
12+
scanf("%lf", &arr[i]);
13+
}
14+
15+
for(i=0; i<n; i++){
16+
sum = sum + arr[i];
17+
}
18+
avg = (double)sum /n;
19+
20+
printf("Sum: %.2lf \nAverage: %.2lf", sum, avg);
21+
return 0;
22+
}

swapOfTwoNum.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int a = 4;
6+
int b = 1;
7+
8+
a = a ^ b;
9+
b = a ^ b;
10+
a = a ^ b;
11+
printf("\n%d \t %d", a, b);
12+
13+
return 0;
14+
}

0 commit comments

Comments
 (0)