Skip to content

Commit b4b5564

Browse files
committed
This repository help us to mastering in C
0 parents  commit b4b5564

File tree

198 files changed

+2850
-0
lines changed

Some content is hidden

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

198 files changed

+2850
-0
lines changed

.vscode/launch.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "C/C++: gcc.exe build and debug active file",
5+
"type": "cppdbg",
6+
"request": "launch",
7+
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
8+
"args": [],
9+
"stopAtEntry": false,
10+
"cwd": "${fileDirname}",
11+
"environment": [],
12+
"externalConsole": false,
13+
"MIMode": "gdb",
14+
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
15+
"setupCommands": [
16+
{
17+
"description": "Enable pretty-printing for gdb",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
},
21+
{
22+
"description": "Set Disassembly Flavor to Intel",
23+
"text": "-gdb-set disassembly-flavor intel",
24+
"ignoreFailures": true
25+
}
26+
],
27+
"preLaunchTask": "C/C++: gcc.exe build active file"
28+
},
29+
{
30+
"name": "(gdb) Launch",
31+
"type": "cppdbg",
32+
"request": "launch",
33+
"program": "enter program name, for example ${workspaceFolder}/a.exe",
34+
"args": [],
35+
"stopAtEntry": false,
36+
"cwd": "${fileDirname}",
37+
"environment": [],
38+
"externalConsole": false,
39+
"MIMode": "gdb",
40+
"miDebuggerPath": "/path/to/gdb",
41+
"setupCommands": [
42+
{
43+
"description": "Enable pretty-printing for gdb",
44+
"text": "-enable-pretty-printing",
45+
"ignoreFailures": true
46+
},
47+
{
48+
"description": "Set Disassembly Flavor to Intel",
49+
"text": "-gdb-set disassembly-flavor intel",
50+
"ignoreFailures": true
51+
}
52+
]
53+
}
54+
],
55+
"version": "2.0.0"
56+
}

.vscode/tasks.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: gcc.exe build active file",
6+
"command": "C:\\MinGW\\bin\\gcc.exe",
7+
"args": [
8+
"-fdiagnostics-color=always",
9+
"-g",
10+
"${file}",
11+
"-o",
12+
"${fileDirname}\\${fileBasenameNoExtension}.exe"
13+
],
14+
"options": {
15+
"cwd": "${fileDirname}"
16+
},
17+
"problemMatcher": [
18+
"$gcc"
19+
],
20+
"group": "build",
21+
"detail": "Task generated by Debugger."
22+
}
23+
],
24+
"version": "2.0.0"
25+
}

01 .Basics codes/Sumbyrecuss.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<stdio.h>
2+
int sum(int n){
3+
if (n==0 || n==1) return 1;
4+
int reans=n+sum(n-1);
5+
return reans;
6+
7+
}
8+
int main(){
9+
int n;
10+
printf("entter the value of n:");
11+
scanf("%d",&n);
12+
int s= sum(n);
13+
printf("%d",s);
14+
15+
}

01 .Basics codes/Sumbyrecuss.exe

40.4 KB
Binary file not shown.

01 .Basics codes/add.c

40.4 KB
Binary file not shown.

01 .Basics codes/eg.exe

40.4 KB
Binary file not shown.

01 .Basics codes/even.exe

40.4 KB
Binary file not shown.

01 .Basics codes/first.c

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<stdio.h>
2+
int main(int argc, char const *argv[])
3+
{
4+
int a, b;
5+
printf("enter the first num");
6+
scanf("%d",&a);
7+
printf("enter the first num");
8+
scanf("%d",&b);
9+
int c=(a+b)/2;
10+
printf("%d",c);
11+
return 0;
12+
}
13+

01 .Basics codes/first.exe

40.4 KB
Binary file not shown.

01 .Basics codes/hello.c

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include<stdio.h>
2+
int main(){
3+
int arr[10];
4+
int size=0;
5+
int i;
6+
printf("Enter the size of array between 1 to 10: ");
7+
scanf("%d",&size);
8+
if(size < 1 || size > 10)
9+
{
10+
printf("Inavaild size");
11+
return 0;
12+
}
13+
printf("Enter the element in the array: ");
14+
for(i =0;i<size;i++)
15+
{
16+
scanf("%d",&arr[i]);
17+
}
18+
int choice,data;
19+
printf("Enter the choice 1 for insert at the begining and 2 for the insert at the end and 3 for specific position: ");
20+
scanf("%d",&choice);
21+
printf("Enter the data: ");
22+
scanf("%d",&data);
23+
if(choice == 1)
24+
{
25+
if(size==10)
26+
{
27+
printf("array is full, You can't insert any data ");
28+
return 0;
29+
}
30+
for(int i= size;i>0;i--)
31+
{
32+
arr[i]=arr[i-1];
33+
}
34+
arr[0] = data;
35+
size++;
36+
}
37+
else if(choice == 2)
38+
{
39+
if(size==10)
40+
{
41+
printf("array is full, You can't insert any data ");
42+
return 0;
43+
}
44+
arr[size]=data;
45+
size++;
46+
47+
}
48+
else if(choice == 3)
49+
{
50+
if(size==10)
51+
{
52+
printf("array is full, You can't insert any data ");
53+
return 0;
54+
}
55+
int location;
56+
printf("Enter the location where you want to insert: ");
57+
scanf("%d",&location);
58+
for(int i=size; i>location;i--){
59+
arr[i]=arr[i-1];
60+
}
61+
arr[location]=data;
62+
size++;
63+
}
64+
else{
65+
printf("Enter the valid choice 1,2,3....");
66+
}
67+
// updated array
68+
printf("Updated array: ");
69+
for(int i= 0; i<size; i++)
70+
{
71+
printf("\t %d",arr[i]);
72+
}
73+
return 0;
74+
}

01 .Basics codes/hello.exe

40.9 KB
Binary file not shown.

01 .Basics codes/lp.c

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include<stdio.h>
2+
main(){
3+
int a;
4+
printf("enter the year");
5+
scanf("%d",&a);
6+
if(a%4==0){
7+
printf("it is leap year");
8+
9+
}else{
10+
printf("it is not leap year");
11+
}
12+
return 0;
13+
}

01 .Basics codes/lp.exe

39.9 KB
Binary file not shown.

01 .Basics codes/ncr.c

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
int main()
3+
{
4+
int num, r;
5+
printf("Enter n number :");
6+
scanf("%d", &num);
7+
printf("Enter r number :");
8+
scanf("%d", &r);
9+
int nfact = 1; // n!
10+
int rfact = 1; // r!
11+
int nrfact = 1; // n-r!
12+
for (int i = 1; i <= num; i++)
13+
{
14+
nfact = nfact * i;
15+
}
16+
for (int i = 1; i <= r; i++)
17+
{
18+
rfact = rfact * i;
19+
}
20+
for (int i = 1; i <= (num - r); i++)
21+
{
22+
nrfact = nrfact * i;
23+
}
24+
int ncr = nfact / (rfact * nrfact);
25+
printf("%d", ncr);
26+
return 0;
27+
}

01 .Basics codes/ncr.exe

40.4 KB
Binary file not shown.

01 .Basics codes/operation.c

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include<stdio.h>
2+
int main(int argc, char const *argv[])
3+
{int num1 , num2;
4+
printf("enter num1: ");
5+
scanf("%d",&num1);
6+
printf("enter num2: ");
7+
scanf("%d",&num2);
8+
int choice;
9+
printf("choose the num for addtion=1 for multiply =2 for dividion=3 for subtration=4");
10+
scanf("%d",&choice);
11+
if (choice==1){
12+
int c=num1+num2;
13+
printf("%d",c);
14+
15+
}
16+
else if (choice==2)
17+
{
18+
int c=num1*num2;
19+
printf("%d",c);
20+
21+
}
22+
else if (choice==3){
23+
int c=num1/num2;
24+
printf("%d",c);
25+
26+
}
27+
else if (choice==4){
28+
int c=num1-num2;
29+
printf("%d",c);
30+
31+
}if(choice==0){
32+
printf("invalid choice");
33+
}
34+
return 0;
35+
}

01 .Basics codes/operation.exe

40.4 KB
Binary file not shown.

01 .Basics codes/p111.c

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include<stdio.h>
2+
int main()
3+
{
4+
printf("\n *");
5+
printf("\n * *");
6+
printf("\n * * *");
7+
printf("\n * * * *");
8+
printf("\n * * * * *");
9+
return 0;
10+
11+
}

01 .Basics codes/p111.exe

39.8 KB
Binary file not shown.

01 .Basics codes/p3.c

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<stdio.h>
2+
int main(){
3+
int row,i,j;
4+
printf("enter the numbefr of rows:");
5+
scanf("%d",&row);
6+
for(i=1; i<=row; i++){
7+
for(j=1; j<i; j++){
8+
printf("*");
9+
}
10+
prinf("\n");
11+
}
12+
return 0;
13+
14+
}

01 .Basics codes/p4.c

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include<stdio.h>
2+
int main(){
3+
int row,i,j;
4+
printf("enter the numbefr of rows:");
5+
scanf("%d",&row);
6+
for(i=1; i<=row; i++){
7+
for(j=i; j<row; j++){
8+
printf("");
9+
}
10+
for (j = 1; j<=i; j++)
11+
{
12+
printf("*");
13+
}
14+
15+
printf("\n");
16+
}
17+
return 0;
18+
19+
}

01 .Basics codes/p5.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<stdio.h>
2+
int main(){
3+
int row,i,j;
4+
printf("enter the number of rows :");
5+
scanf("%d",&row);
6+
for (i = 1; i <=row; i++)
7+
{
8+
for ( j = 1; j<=row+1-i; j++)
9+
{
10+
printf("*");
11+
}
12+
printf("\n");
13+
}
14+
15+
}

01 .Basics codes/p5.exe

40.5 KB
Binary file not shown.

01 .Basics codes/p6.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#include<stdio.h>
2+
int main(){
3+
int row , i,j;
4+
printf("enter the no of rows:");
5+
scanf("%d",&row);
6+
for (i = 1; i <=row; i++)
7+
{
8+
for ( j = 1; j<=row+1-i; j++)
9+
{
10+
printf("%d",j);
11+
}printf("\n");
12+
13+
}
14+
15+
}

01 .Basics codes/p6.exe

40.5 KB
Binary file not shown.

01 .Basics codes/p7.c

Whitespace-only changes.

01 .Basics codes/palindrome.c

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include<stdio.h>
2+
int main(){
3+
int num;
4+
5+
6+
printf("Enter the number : ");
7+
scanf("%d",&num);
8+
int temp=num;
9+
if(num<0){
10+
return 0;
11+
}
12+
int res=0;
13+
14+
for(int i=1; num>0; i++){
15+
res=res*10;
16+
res=res+(num%10);
17+
18+
num=num/10;
19+
}
20+
printf("%d\n",res);
21+
if(temp==res){
22+
printf("The number is palindrome");
23+
}
24+
else{
25+
printf("The number is not palindrome");
26+
}
27+
return 0;
28+
}

01 .Basics codes/palindrome.exe

40.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)