├── 1 ├── 2 digit number or not ├── README.md ├── array find the maximum number in an array ├── avrage of numbers in an array ├── biggest of 2 number ├── even number or odd number ├── find positive or negative ├── find the where the seet is ├── get the input from the user and print it ├── maximum and minimum number in an array ├── print number grater than 25 in an array ├── print number of odd , even numbers in the array ├── print the month as the input is given in munbers ├── sum of even and odd index numbers in an array ├── sum of even index numbers in an array ├── sum of numbers in an array ├── sum of numbers in the array ├── the number is divisible by 5or 7 or by both ├── to find larger number in an array ├── to find maximum of 4 numbers ├── to find the factors ├── to find the given is a digit or not ├── to find the input is a alphabet or not ├── to find the input is a special character or not ├── to find the number of days in a month ├── to find the person is eligible to vote or not └── to find the year is leep year or not /1: -------------------------------------------------------------------------------- 1 | To find the number is positive or negative and also conver the negative number to positive 2 | #include 3 | int main() { 4 | int a,num; 5 | scanf ("%d",&a); 6 | if(a<0) 7 | {num=-1*a; 8 | printf("the number is negative , the positive number is :%d",num);} 9 | else 10 | {printf("the number is positive %d",a); 11 | return 0;} 12 | } 13 | -------------------------------------------------------------------------------- /2 digit number or not: -------------------------------------------------------------------------------- 1 | to find the given number is a 2 digit number or not 2 | #include 3 | int main(){ 4 | int a; 5 | scanf("%d",&a); 6 | if (9100) 7 | {printf("the give number is two digit number %d ",a); 8 | } 9 | else 10 | {printf("it is not a double digit number %d",a);} 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # c-programming 2 | sharing my programs 3 | -------------------------------------------------------------------------------- /array find the maximum number in an array: -------------------------------------------------------------------------------- 1 | //maximum number in an array 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int max=0; 9 | for (int i=0;imax){ 12 | max=a[i]; 13 | } 14 | }printf("max num :%d",max);} 15 | -------------------------------------------------------------------------------- /avrage of numbers in an array: -------------------------------------------------------------------------------- 1 | //avrage of numbers in an array 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int sum=0; 9 | for(int i=0;i 4 | int main(){ 5 | int a,b; 6 | scanf("%d %d",&a,&b); 7 | if (a>b) 8 | { 9 | printf("a is bigger number %d",a); 10 | } 11 | else 12 | { 13 | printf("b is bigger number %d ",b); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /even number or odd number: -------------------------------------------------------------------------------- 1 | the givren number is even or odd 2 | #include 3 | int main(){ 4 | int a; 5 | scanf("%d",&a); 6 | if (a%2==0) 7 | { 8 | printf("the number is even %d",a); 9 | } 10 | else 11 | {printf("the number is odd %d",a);} 12 | } 13 | -------------------------------------------------------------------------------- /find positive or negative: -------------------------------------------------------------------------------- 1 | to find the number is positive or negative 2 | 3 | #include 4 | int main (){ 5 | int a; 6 | scanf("%d",&a); 7 | if (a>0) 8 | {printf("the number is positive %d",a); 9 | } 10 | else {printf("the number is negative %d",a); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /find the where the seet is: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int a,n; 4 | printf("enter the number 1-72 :"); 5 | scanf("%d",&a); 6 | if(n>=1&&n<=72){ 7 | n=a%8; 8 | switch(n){ 9 | case 1: 10 | case 4: 11 | printf("lower"); 12 | break; 13 | case 2: 14 | case 5: 15 | printf("middle"); 16 | break; 17 | case 3: 18 | case 6: 19 | printf("upper"); 20 | break; 21 | 22 | case 7: 23 | printf("side lower"); 24 | break; 25 | case 0: 26 | printf("side upper"); 27 | break; 28 | } 29 | 30 | } 31 | else 32 | printf("invalid enter num within 1-72"); 33 | } 34 | -------------------------------------------------------------------------------- /get the input from the user and print it: -------------------------------------------------------------------------------- 1 | //to get the input from the user and print it 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size:); 6 | scanf("%d",&n); 7 | int a[n]; 8 | for(int i=0;i 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int max=0; 9 | for (int i=0;imax){ 12 | max=a[i]; 13 | } }printf("max num :%d\n",max); 14 | for (int i=0;i 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | for (int i=0;i25){ 11 | printf("%d",a[i]);} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /print number of odd , even numbers in the array: -------------------------------------------------------------------------------- 1 | //print the number of odd and even numbers in the array 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int even =0; 9 | int odd =0; 10 | for (int i=0;i 2 | int main(){ 3 | int n; 4 | printf("enter the value of month in numbers n :"); 5 | scanf("%d",&n); 6 | switch(n) 7 | { 8 | case 1: 9 | printf("january "); 10 | break; 11 | 12 | case 2: 13 | printf("feburary "); 14 | break; 15 | 16 | case 3: 17 | printf("march "); 18 | break; 19 | 20 | case 4: 21 | printf("april "); 22 | break; 23 | 24 | case 5: 25 | printf("may "); 26 | break; 27 | 28 | case 6: 29 | printf("june "); 30 | break; 31 | 32 | case 7: 33 | printf("july "); 34 | break; 35 | 36 | case 8: 37 | printf("august "); 38 | break; 39 | 40 | case 9: 41 | printf("september "); 42 | break; 43 | 44 | case 10: 45 | printf("october"); 46 | break; 47 | 48 | case 11: 49 | printf("november"); 50 | break; 51 | 52 | case 12: 53 | printf("december"); 54 | break; 55 | 56 | default: 57 | printf("invalied"); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sum of even and odd index numbers in an array: -------------------------------------------------------------------------------- 1 | //sum of even and odd index numbers 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size :"); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int sum=0; 9 | int sum1=0; 10 | for(int i=0;i<5;i++){ 11 | scanf("%d",&a[i]); 12 | if(i%2==0){ 13 | sum=sum+a[i];} 14 | else if (i%2!=0){ 15 | sum1=sum1+a[i]; 16 | } 17 | } 18 | printf("sum : %d\n",sum); 19 | printf("odd: %d",sum1); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /sum of even index numbers in an array: -------------------------------------------------------------------------------- 1 | //sum of even index numbers 2 | #include 3 | int main() { 4 | int n; 5 | printf("enter the size "); 6 | scanf("%d",&n); 7 | int a[n]; 8 | int sum=0; 9 | for(int i=0;i<5;i++){ 10 | scanf("%d",&a[i]); 11 | if(i%2==0){ 12 | sum=sum+a[i];}} 13 | printf("sum : %d",sum); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sum of numbers in an array: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[5]; 5 | int b=0; 6 | for(int i=0;i<5;i++){ 7 | scanf("%d",&a[i]); 8 | b=b+a[i]; 9 | } printf("%d\n",b); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /sum of numbers in the array: -------------------------------------------------------------------------------- 1 | //find the sum of numbers in the array 2 | 3 | #include 4 | int main() { 5 | 6 | int a[5]={1,2,3,4,5}; 7 | int sum=0; 8 | for(int i=0;i<5;i++){ 9 | sum=sum+a[i];} 10 | printf("sum : %d",sum); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /the number is divisible by 5or 7 or by both: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int a; 4 | printf("enter an number :"); 5 | scanf("%d",&a); 6 | if (a%5==0 && a%7==0){ 7 | printf("the number is divisible by both 5 and 7:%d",a);} 8 | else if (a%5==0) 9 | {printf("the number is divisible by 5 :%d",a);} 10 | else if (a%7==0) 11 | { 12 | printf("the number is divisable by 7 :%d",a);} 13 | else 14 | {printf ("the number is not divisible by 5 and 7 :%d",a);} 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /to find larger number in an array: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[5]; 5 | int large=0; 6 | for(int i=0;i<5;i++){ 7 | scanf("%d",&a[i]); 8 | if(a[i]>large){ 9 | large=a[i]; 10 | }} 11 | printf("the large number is:%d\n",large); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /to find maximum of 4 numbers: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int a, b, c, d; 4 | int max; 5 | scanf("%d %d %d %d", &a, &b, &c, &d); 6 | max = a; 7 | if (b > a) { 8 | max = b; 9 | } 10 | if (c > max) { 11 | max = c; 12 | } 13 | if (d > max) { 14 | max = d; 15 | } 16 | printf("%d", max); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /to find the factors: -------------------------------------------------------------------------------- 1 | //find factors for the given number 2 | 3 | #include 4 | int main(){ 5 | int n=1; 6 | int a; 7 | int c=0; 8 | scanf("%d",&a); 9 | while(n>=0){ 10 | if(a%n==0){ 11 | c++; 12 | printf("the factors are :%d\n",n); 13 | } 14 | n++; 15 | } printf("%d",c++); 16 | } 17 | -------------------------------------------------------------------------------- /to find the given is a digit or not: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int a; 4 | char b; 5 | scanf("%d%c",&a,&b); 6 | if (a==b) 7 | {printf("not digit");} 8 | else 9 | {printf(" digit");} 10 | } 11 | -------------------------------------------------------------------------------- /to find the input is a alphabet or not: -------------------------------------------------------------------------------- 1 | include 2 | int main(){ 3 | char c; 4 | scanf("%c",&c); 5 | if (c>='a' && c<='z') 6 | {printf("alphabet %c",c);} 7 | else if (c>='A' && c<='Z') 8 | {printf("alphabet %c",c);} 9 | else 10 | {printf("not alphaber %c",c);} 11 | } 12 | -------------------------------------------------------------------------------- /to find the input is a special character or not: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | char a; 4 | scanf("%c",&a); 5 | if(a>='A' && a<='Z') 6 | {printf("not a special character %c",a);} 7 | else if(a>='a' && a<='z') 8 | {printf("not a special character %c",a);} 9 | else if (a>='0' && a<='9') 10 | {printf("not a special character %c",a);} 11 | else 12 | {printf("it is a special character %c",a);} 13 | } 14 | -------------------------------------------------------------------------------- /to find the number of days in a month: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { int n; 4 | printf("enitr the month 1-12 :"); 5 | scanf("%d",&n); 6 | if(n==1 || n==3 || n==5 ||n==7 || n==8 || n==10 ||n==12) 7 | {printf("31 days ,month %d",n);} 8 | else if (n==4||n==6||n==9||n==11) 9 | {printf("30 days ,month %d",n);} 10 | else if (n==2) 11 | {printf("28 or 29 days,month %d",n); 12 | } 13 | else 14 | {printf("invalied input %d",n);} 15 | } 16 | -------------------------------------------------------------------------------- /to find the person is eligible to vote or not: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | char name[100]; 4 | int age ; 5 | printf("enter the name :"); 6 | scanf("%s",&name); 7 | printf("enter the age:"); 8 | scanf("%d",&age); 9 | if (age>=18){ printf(" eligible to vote");} 10 | else {printf(" not eligible to vote ");} 11 | -------------------------------------------------------------------------------- /to find the year is leep year or not: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a; 5 | printf("enter the year:"); 6 | scanf("%d",&a); 7 | if((a%4==0&&a%100!=0)||(a%400==0)) 8 | {printf("leep year");} 9 | else 10 | {printf("not a leep year");} 11 | } 12 | --------------------------------------------------------------------------------