Skip to content

Commit b3d319b

Browse files
committed
Examples with credit
1 parent f6724aa commit b3d319b

File tree

280 files changed

+8124
-2545
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+8124
-2545
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ android {
114114

115115
dependencies {
116116
testImplementation 'junit:junit:4.12'
117+
// https://mvnrepository.com/artifact/org.jsoup/jsoup
118+
testImplementation group: 'org.jsoup', name: 'jsoup', version: '1.7.2'
117119
androidTestImplementation 'com.android.support.test:runner:1.0.1'
118120
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
119121

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// C Program to Find ASCII Value of a Character
2+
3+
// This page contains source code to display ASCII value of a character enter by user...
4+
5+
#include <stdio.h>
6+
int main()
7+
{
8+
char c;
9+
printf("Enter a character: ");
10+
11+
// Reads character input from the user
12+
scanf("%c", &c);
13+
14+
// %d displays the integer value of a character
15+
// %c displays the actual character
16+
printf("ASCII value of %c = %d", c, c);
17+
return 0;
18+
}
19+
20+
// https://www.programiz.com/c-programming/examples/ASCII-value-character
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// C Program to Access Elements of an Array Using Pointer
2+
3+
// This program declares the array of five element and the elements of that array are accessed using pointer.
4+
5+
#include <stdio.h>
6+
7+
int main()
8+
{
9+
int data[5], i;
10+
printf("Enter elements: ");
11+
12+
for(i = 0; i < 5; ++i)
13+
scanf("%d", data + i);
14+
15+
printf("You entered: \n");
16+
for(i = 0; i < 5; ++i)
17+
printf("%d\n", *(data + i));
18+
19+
return 0;
20+
}
21+
22+
// https://www.programiz.com/c-programming/examples/access-array-pointer

app/examples/c/add-matrix.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// C Program to Add Two Matrix Using Multi-dimensional Arrays
2+
3+
// C program to add two matrix entered by user with source code and output....
4+
5+
#include <stdio.h>
6+
int main(){
7+
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
8+
9+
printf("Enter number of rows (between 1 and 100): ");
10+
scanf("%d", &r);
11+
printf("Enter number of columns (between 1 and 100): ");
12+
scanf("%d", &c);
13+
14+
printf("\nEnter elements of 1st matrix:\n");
15+
16+
for(i=0; i<r; ++i)
17+
for(j=0; j<c; ++j)
18+
{
19+
printf("Enter element a%d%d: ",i+1,j+1);
20+
scanf("%d",&a[i][j]);
21+
}
22+
23+
printf("Enter elements of 2nd matrix:\n");
24+
for(i=0; i<r; ++i)
25+
for(j=0; j<c; ++j)
26+
{
27+
printf("Enter element a%d%d: ",i+1, j+1);
28+
scanf("%d", &b[i][j]);
29+
}
30+
31+
// Adding Two matrices
32+
33+
for(i=0;i<r;++i)
34+
for(j=0;j<c;++j)
35+
{
36+
sum[i][j]=a[i][j]+b[i][j];
37+
}
38+
39+
// Displaying the result
40+
printf("\nSum of two matrix is: \n\n");
41+
42+
for(i=0;i<r;++i)
43+
for(j=0;j<c;++j)
44+
{
45+
46+
printf("%d ",sum[i][j]);
47+
48+
if(j==c-1)
49+
{
50+
printf("\n\n");
51+
}
52+
}
53+
54+
return 0;
55+
}
56+
57+
// https://www.programiz.com/c-programming/examples/add-matrix

app/examples/c/add-numbers.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// C Program to Add Two Integers
2+
3+
// This page contains example to add two integers in C programming language with output and explanation...
4+
5+
#include <stdio.h>
6+
int main()
7+
{
8+
int firstNumber, secondNumber, sumOfTwoNumbers;
9+
10+
printf("Enter two integers: ");
11+
12+
// Two integers entered by user is stored using scanf() function
13+
scanf("%d %d", &firstNumber, &secondNumber);
14+
15+
// sum of two numbers in stored in variable sumOfTwoNumbers
16+
sumOfTwoNumbers = firstNumber + secondNumber;
17+
18+
// Displays sum
19+
printf("%d + %d = %d", firstNumber, secondNumber, sumOfTwoNumbers);
20+
21+
return 0;
22+
}
23+
24+
// https://www.programiz.com/c-programming/examples/add-numbers

app/examples/c/alphabet.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// C Program to Check Whether a Character is an Alphabet or not
2+
3+
// In this example, you will learn to check whether a character entered by the user is an alphabet or not.
4+
5+
#include <stdio.h>
6+
int main()
7+
{
8+
char c;
9+
printf("Enter a character: ");
10+
scanf("%c",&c);
11+
12+
if( (c>='a' && c<='z') || (c>='A' && c<='Z'))
13+
printf("%c is an alphabet.",c);
14+
else
15+
printf("%c is not an alphabet.",c);
16+
17+
return 0;
18+
}
19+
20+
// https://www.programiz.com/c-programming/examples/alphabet
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// C Program to Display Armstrong Number Between Two Intervals
2+
3+
// Example to find all Armstrong numbers between two integers (entered by the user) using loops and if...else statement.
4+
5+
#include <stdio.h>
6+
#include <math.h>
7+
8+
int main()
9+
{
10+
int low, high, i, temp1, temp2, remainder, n = 0, result = 0;
11+
12+
printf("Enter two numbers(intervals): ");
13+
scanf("%d %d", &low, &high);
14+
printf("Armstrong numbers between %d an %d are: ", low, high);
15+
16+
for(i = low + 1; i < high; ++i)
17+
{
18+
temp2 = i;
19+
temp1 = i;
20+
21+
// number of digits calculation
22+
while (temp1 != 0)
23+
{
24+
temp1 /= 10;
25+
++n;
26+
}
27+
28+
// result contains sum of nth power of its digits
29+
while (temp2 != 0)
30+
{
31+
remainder = temp2 % 10;
32+
result += pow(remainder, n);
33+
temp2 /= 10;
34+
}
35+
36+
// checks if number i is equal to the sum of nth power of its digits
37+
if (result == i) {
38+
printf("%d ", i);
39+
}
40+
41+
// resetting the values to check Armstrong number for next iteration
42+
n = 0;
43+
result = 0;
44+
45+
}
46+
return 0;
47+
}
48+
49+
// https://www.programiz.com/c-programming/examples/armstrong-number-interval
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// C Program to Find Largest Element of an Array
2+
3+
// C program to find the largest element of an array with source code, output and explanation....
4+
5+
#include <stdio.h>
6+
7+
int main()
8+
{
9+
int i, n;
10+
float arr[100];
11+
12+
printf("Enter total number of elements(1 to 100): ");
13+
scanf("%d", &n);
14+
printf("\n");
15+
16+
// Stores number entered by the user
17+
for(i = 0; i < n; ++i)
18+
{
19+
printf("Enter Number %d: ", i+1);
20+
scanf("%f", &arr[i]);
21+
}
22+
23+
// Loop to store largest number to arr[0]
24+
for(i = 1; i < n; ++i)
25+
{
26+
// Change < to > if you want to find the smallest element
27+
if(arr[0] < arr[i])
28+
arr[0] = arr[i];
29+
}
30+
printf("Largest element = %.2f", arr[0]);
31+
32+
return 0;
33+
}
34+
35+
// https://www.programiz.com/c-programming/examples/array-largest-element

app/examples/c/average-arrays.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// C Program to Calculate Average Using Arrays
2+
3+
// C programming source code to calculate average using arrays....
4+
5+
#include <stdio.h>
6+
7+
int main()
8+
{
9+
int n, i;
10+
float num[100], sum = 0.0, average;
11+
12+
printf("Enter the numbers of elements: ");
13+
scanf("%d", &n);
14+
15+
while (n > 100 || n <= 0)
16+
{
17+
printf("Error! number should in range of (1 to 100).\n");
18+
printf("Enter the number again: ");
19+
scanf("%d", &n);
20+
}
21+
22+
for(i = 0; i < n; ++i)
23+
{
24+
printf("%d. Enter number: ", i+1);
25+
scanf("%f", &num[i]);
26+
sum += num[i];
27+
}
28+
29+
average = sum / n;
30+
printf("Average = %.2f", average);
31+
32+
return 0;
33+
}
34+
35+
// https://www.programiz.com/c-programming/examples/average-arrays
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// C Program to Convert Binary Number to Decimal and vice-versa
2+
3+
// In this example, you will learn to convert binary number to decimal and decimal number to binary manually by creating a user-defined function
4+
5+
#include <stdio.h>
6+
#include <math.h>
7+
int convertBinaryToDecimal(long long n);
8+
9+
int main()
10+
{
11+
long long n;
12+
printf("Enter a binary number: ");
13+
scanf("%lld", &n);
14+
printf("%lld in binary = %d in decimal", n, convertBinaryToDecimal(n));
15+
return 0;
16+
}
17+
18+
int convertBinaryToDecimal(long long n)
19+
{
20+
int decimalNumber = 0, i = 0, remainder;
21+
while (n!=0)
22+
{
23+
remainder = n%10;
24+
n /= 10;
25+
decimalNumber += remainder*pow(2,i);
26+
++i;
27+
}
28+
return decimalNumber;
29+
}
30+
31+
// https://www.programiz.com/c-programming/examples/binary-decimal-convert

0 commit comments

Comments
 (0)