Last active
December 5, 2024 15:30
-
-
Save djoudi/bac93ca577e76d97511c5361ea6f2aff to your computer and use it in GitHub Desktop.
c lang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main() | |
| { | |
| // int x ; | |
| // char c = 'a'; | |
| // float t = 25.12; | |
| // | |
| //printf("this is val x %d",x); | |
| // printf(" please enter val X"); | |
| // scanf("%d",&x); | |
| //dlkfjdslkfjflk | |
| /*dsfmlskdmfd | |
| sdlfksjdflkdsjf | |
| sdfkj | |
| */ | |
| // printf("Val X = %d ",x); | |
| //int a ,b ; | |
| //printf("please enter a b"); | |
| //scanf("%d %d ",&a,&b); | |
| //printf("The result of a + b = %d",a+b); | |
| //int c = 25; | |
| //if(c>0){ | |
| // printf("Positive é"); | |
| //}else{ | |
| // printf("Negative") ; | |
| //} | |
| // return 0; | |
| //} | |
| //float a,b,c; | |
| //printf("please enter A\n"); | |
| //scanf("%f",&a); | |
| //printf("please enter B\n"); | |
| //scanf("%f",&b); | |
| //if(b!=0){ | |
| // c = a/b; | |
| // printf("The Result of a/b = %f",c); | |
| //}else { | |
| // printf("Error Div By Zero"); | |
| //} | |
| //printf("%d",15<25 AND 10!=10); | |
| // 1 AND 0 ===> 0 | |
| // 0 And 1 ===> 0 | |
| // 1 AND 1 ===> 1 | |
| // 0 AND 0 ===> 0 | |
| // | |
| // ================== | |
| // | |
| // 1 OR 0 ===> 1 | |
| // 0 OR 1 ===> 1 | |
| // 1 OR 1 ===> 1 | |
| // 0 OR 0 ===> 0 | |
| //int x = 12; | |
| //int y ; | |
| //x = x + 3; // x+=3 | |
| //x =x -2 ; // x-=2 | |
| //x= x * 2; //x*=2 | |
| //x = x / 2; // x/=2 | |
| //x = x % 2 ; // x%=2 | |
| //printf("%d",x++); | |
| //printf("%d",++x); | |
| //y = x++; | |
| //printf("x= %d y = %d",x,y); | |
| //char c ; | |
| //printf("please enter you Char \n"); | |
| //scanf("%c",&c); | |
| //if(c=='A' || c=='a'){ | |
| // printf("True"); | |
| //}else{ | |
| // printf("False"); | |
| //} | |
| //float a,b; | |
| //char c; | |
| //printf("Enter A \n"); | |
| //scanf("%f",&a); | |
| //printf("Enter B \n"); | |
| //scanf("%f",&b); | |
| //printf("Enter Op \n"); | |
| //scanf("\n%c",&c); | |
| //if(c=='+') printf("%f",a+b); | |
| //if(c=='-') printf("%f",a-b); | |
| //if(c=='*') printf("%f",a*b); | |
| //if(c=='/'){ | |
| // if(b!=0) printf("%f",a/b); | |
| // else printf("Div By Zero"); | |
| //} | |
| //else printf("No Operator"); | |
| //float a,b; | |
| //char c; | |
| //printf("Enter A \n"); | |
| //scanf("%f",&a); | |
| //printf("Enter B \n"); | |
| //scanf("%f",&b); | |
| //printf("Enter Op \n"); | |
| //scanf("\n%c",&c); | |
| //if(c=='+') printf("%f",a+b); | |
| //else if(c=='-') printf("%f",a-b); | |
| //else if(c=='*') printf("%f",a*b); | |
| //else if(c=='/'){ | |
| // if(b!=0) printf("%f",a/b); | |
| // else printf("Div By Zero"); | |
| //} | |
| //else printf("No Operator"); | |
| //float a,b; | |
| //char c; | |
| //printf("Enter A \n"); | |
| //scanf("%f",&a); | |
| //printf("Enter B \n"); | |
| //scanf("%f",&b); | |
| //printf("Enter Op \n"); | |
| //scanf("\n%c",&c); | |
| //switch(c){ | |
| // case '+': | |
| // printf("%f",a+b); | |
| // break; | |
| // case '-': | |
| // printf("%f",a-b); | |
| // break; | |
| // case '*': | |
| // printf("%f",a*b); | |
| // break; | |
| // case '/': | |
| // if(b!=0) printf("%f",a/b); | |
| // else printf("Div By Zero"); | |
| // break; | |
| // default: | |
| // printf("No Operator"); | |
| // | |
| //} | |
| int a,b,c; | |
| printf("Enter A \n"); | |
| scanf("%d",&a); | |
| printf("Enter B \n"); | |
| scanf("%d",&b); | |
| printf("A = %d and B = %d \n",a,b); | |
| c = a; | |
| a = b ; | |
| b = c; | |
| printf("\n==============================\n"); | |
| printf("A = %d and B = %d",a,b); | |
| return 0; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main() | |
| { | |
| // int a,b; | |
| // printf("enter a value"); | |
| // scanf("%d",&a); | |
| // if(a>5) b = 100; | |
| // else b = 60; | |
| // b = (a>5)?100:60; | |
| // printf("B laue is %d",b); | |
| // 0 1 2 3 4 5 6 | |
| //While | |
| //Do.. while | |
| //For | |
| //int i = 10; | |
| //while(i<=6) | |
| //{ | |
| // printf("%d\t",i); | |
| // i++; | |
| //} | |
| //int j=0; | |
| //do{ | |
| // printf("%d\t",j); | |
| // j++; | |
| //}while(j<=6); | |
| // 2 4 6 8 10 12 14 16 | |
| //int c = 2; | |
| //while(c<=16) | |
| //{ | |
| // if(c%2==0) | |
| // printf("%d \t",c); | |
| // c++ ; | |
| //} | |
| // | |
| //int c = 2; | |
| //while(c<=16) | |
| //{ | |
| // printf("%d \t",c); | |
| // c=c+2 ; | |
| //} | |
| // | |
| //int c = 1; | |
| //while(c<=8) | |
| //{ | |
| // printf("%d \t",c*2); | |
| // c++ ; | |
| //} | |
| // a b c | |
| //10 25 36 | |
| // | |
| // int a,b,c,max; | |
| // printf("enter a ,b,c"); | |
| // scanf("%d%d%d",&a,&b,&c); | |
| // // max = a; | |
| // if(a>b && a >c) printf(" A %d is Max",a); | |
| // else if(b>a && b>c)printf(" B %d is Max",b); | |
| // else if(c>a && c>b)printf(" C %d is Max",c); | |
| // else printf(" message ..."); | |
| // int n , i,p; | |
| // p = 1; | |
| // printf("enter N"); | |
| // scanf("%d",&n); | |
| // i = 2; | |
| // while(i<=n/2){ | |
| // if(n%i==0){ | |
| // p = 0; | |
| // break; | |
| // } | |
| // i++; | |
| // } | |
| // if(p ==0) printf("Not Prime"); | |
| // else printf("Is Prime"); | |
| //for(int i = 1; i<=6 ; i++){ | |
| // printf("%d\t",i); | |
| //} | |
| // 1 1 1 | |
| // 1 1 1 | |
| // 1 1 1 | |
| // for(int i = 0;i<3; i++){ | |
| // for(int j = 0;j<3; j++){ | |
| // printf("A \t"); | |
| // } | |
| // printf("\n"); | |
| // } | |
| printf("\n----------------------\n"); | |
| // for(int i = 2;i>=0; i--){ | |
| // for(int j = 0;j<3; j++){ | |
| // printf("B \t"); | |
| // } | |
| // printf("\n"); | |
| // } | |
| //int t[6]; | |
| // | |
| //for(int i=0;i<6;i++) | |
| //{ | |
| // printf("please enter Number \n %d",i+1); | |
| // scanf("%d",&t[i]); | |
| //} | |
| // | |
| //for(int i=0;i<6;i++) | |
| //{ | |
| // printf(" %d\t",t[i]); | |
| //} | |
| int T2[5]; | |
| for(int i=0;i<5;i++) | |
| { | |
| printf("please enter Number \n %d",i+1); | |
| scanf("%d",&T2[i]); | |
| } | |
| for(int i = 0;i<5;i++){ | |
| if(T2[i]%2==0) printf("T2===%d",T2[i]); | |
| } | |
| //printf("%d\n",t[5]); | |
| // | |
| //int t2[] = {10,15,13,20,30,18}; | |
| //printf("%d\n",t[5]); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define SIZE 100 | |
| int main() | |
| { | |
| // int T2[5]; | |
| // for(int i=0;i<5;i++) | |
| // { | |
| // printf("please enter Number \n %d",i+1); | |
| // scanf("%d",&T2[i]); | |
| // } | |
| // | |
| // int max = T2[0]; | |
| // for(int j= 1;j<5;j++){ | |
| // if(max<T2[j]){ | |
| // max = T2[j]; | |
| // } | |
| // } | |
| // | |
| //printf("The Max is %d",max); | |
| // 15 48 200 9 69 ==> 9 15 48 69 200 | |
| // int T2[SIZE]; | |
| // for(int i=0;i<SIZE;i++) | |
| // { | |
| // printf("please enter Number \n %d",i+1); | |
| // scanf("%d",&T2[i]); | |
| // } | |
| // int temp; | |
| // //Bubble Sort | |
| // for(int i = 0;i<SIZE;i++){ | |
| // for(int j = 0;j<SIZE-1;j++){ | |
| // if(T2[j]>T2[j+1]){ | |
| // temp = T2[j]; | |
| // T2[j] = T2[j+1]; | |
| // T2[j+1] = temp; | |
| // } | |
| // } | |
| // } | |
| // | |
| // for(int i=0;i<SIZE;i++) | |
| // { | |
| // printf("please enter Number \t %d",T2[i]); | |
| // | |
| // } | |
| //sort | |
| // a c t e p m O | |
| // | |
| // char T2[SIZE]; | |
| // printf("please enter Word "); | |
| // gets(T2); | |
| // | |
| // for(int i = 0 ;i<strlen(T2); i++){ | |
| // if(T2[i]=='a' || T2[i]=='A' || T2[i]=='i'|| T2[i]=='I' ){ | |
| // printf("Chart %c \n",T2[i]); | |
| // } | |
| // | |
| // } | |
| char T2[SIZE]; | |
| printf("please enter text "); | |
| gets(T2); | |
| int cpt = 0; | |
| for(int i = 0;i <strlen(T2); i++){ | |
| if( T2[i]!=' ' && T2[i]!='\n'){ | |
| cpt++; | |
| } | |
| } | |
| printf("Num de chart is %d\t%d ",cpt,strlen(T2)); | |
| return 0; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #define S 100 | |
| int main() | |
| { | |
| // Palindrome | |
| // MISSIM | |
| //ECOCE | |
| char w[S]; | |
| printf("please enter your word "); | |
| gets(w); | |
| int isPalindrome = 1; | |
| for(int i =0; i<strlen(w)/2;i++){ | |
| if(w[i]!=w[strlen(w)-i-1]){ | |
| isPalindrome = 0; | |
| break; | |
| } | |
| } | |
| if(isPalindrome) printf("the word is Palindrome"); | |
| else printf("the word is Not Palindrome"); | |
| // for(int i = strlen(w)-1;i>=0; i--){ | |
| // printf("%c",w[i]); | |
| // } | |
| return 0; | |
| // Ecoin MIM | |
| // i S | |
| // EcoSn | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| void add(float a, float b){ | |
| printf("%d",a+b); | |
| } | |
| void sub(float a, float b){ | |
| printf("%d",a-b); | |
| } | |
| void mul(float a, float b){ | |
| printf("%d",a*b); | |
| } | |
| void dive(float a, float b){ | |
| if(b==0) printf("Div By Zero"); | |
| else printf("%f",a/b); | |
| } | |
| int main() | |
| { | |
| float x, y; | |
| char op; | |
| printf("please enter Value X,Y,OP"); | |
| scanf("%f %f %c",&x,&y,&op); | |
| switch(op){ | |
| case '+': | |
| add(x,y); | |
| break; | |
| case '-': | |
| sub(x,y); | |
| break; | |
| case '*': | |
| mul(x,y); | |
| break; | |
| case '/': | |
| dive(x,y); | |
| break; | |
| default: | |
| printf("No operation"); | |
| } | |
| return 0; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int add(int a,int b){ | |
| // printf(" \nFrom Fun Add %d",a+b); | |
| return a+b; | |
| } | |
| int main() | |
| { | |
| int c = add(45,2); | |
| printf(" \nFrom Main Fun %d",c); | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <conio.h> | |
| char check(int a){ | |
| char result; | |
| if(a%2==0) result = 'p'; | |
| else result ='i'; | |
| return result; | |
| } | |
| int main() | |
| { | |
| int x; | |
| char c; | |
| char choice; | |
| do{ | |
| printf("\n===================\n"); | |
| printf("Menu \n"); | |
| printf("1. Enter a number\n"); | |
| printf("q. Quite\n"); | |
| printf("\n===================\n"); | |
| printf("\nPlease select an option\n"); | |
| scanf("%c",&choice); | |
| if(choice=='1'){ | |
| printf("please enter your Number\t"); | |
| scanf("%d",&x); | |
| c = check(x); | |
| if(c=='p') printf("Paire\n"); | |
| else printf("Impair\n"); | |
| } | |
| else if(choice=='q'){ | |
| printf("\nExiting the program Googdby \n"); | |
| break; | |
| }else { | |
| printf("\nInvalid Error\n"); | |
| } | |
| //system('clear'); | |
| }while(choice !='q'); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment