├── Pointers ├── iAnalyse │ ├── 3.png │ ├── 2(a).png │ └── 2(b).png ├── iAssess │ ├── 2.c │ └── 1.c └── iDesign │ ├── BasicPractice │ ├── 2.c │ ├── 1.c │ ├── 3.c │ ├── 5.c │ └── 4.c │ └── DynamicMemoryAllocation │ ├── 5.c │ ├── 4.c │ ├── 3.c │ ├── 1.c │ ├── 2.c │ ├── 6.c │ └── 7.c ├── Functions ├── iAnalyse │ ├── 2.png │ ├── 4.png │ └── 5.png ├── iAssess │ └── 1.c └── iDesign │ ├── 1.c │ ├── 6.c │ ├── 5.c │ ├── 4.c │ ├── 7.c │ ├── 2.c │ ├── 8.c │ └── 3.c ├── Basics of C ├── iAnalyse │ ├── 1.png │ ├── 3.png │ └── 4.png ├── iDesign │ ├── 2.c │ ├── 5.c │ ├── 3.c │ ├── 1.c │ ├── 4.c │ └── 6.c └── iAssess │ └── 1.c ├── Arrays and Strings ├── iAnalyse │ ├── 4.png │ └── q2.PNG ├── iDesign │ ├── 1.c │ ├── 4.c │ ├── 5.c │ ├── 11.c │ ├── 3.c │ ├── 2.c │ ├── 9.c │ ├── 8.c │ ├── 6.c │ ├── 7.c │ ├── 12.c │ └── 10.c └── iAssess │ └── 1.c ├── Structures and Union ├── iAnalyse │ ├── 1 │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ └── .DS_Store │ ├── 4 │ │ ├── 1.png │ │ ├── 2.png │ │ └── .DS_Store │ └── 5 │ │ ├── 1.png │ │ ├── 2.png │ │ ├── 3.png │ │ ├── 4.png │ │ ├── 5.png │ │ └── .DS_Store ├── iDesign │ ├── 3.c │ ├── 2.c │ └── 1.c └── iAssess │ └── 1.c ├── Conditional statements and Loops ├── iAnalyse │ ├── 2.png │ ├── 3.png │ └── 4.png ├── iDesign │ ├── 1.c │ ├── 8.c │ ├── 7.c │ ├── 10.c │ ├── 5.c │ ├── 12.c │ ├── 9.c │ ├── 11.c │ ├── 2.c │ ├── 3.c │ ├── 4.c │ └── 6.c └── iAssess │ └── 1.c.c ├── README.md ├── FileHandling ├── iDesign │ ├── 1.c │ ├── 2.c │ └── 3.c ├── iAssess │ └── 1.c └── iExplore │ └── I explore files.txt ├── .gitignore └── LICENSE /Pointers/iAnalyse/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Pointers/iAnalyse/3.png -------------------------------------------------------------------------------- /Functions/iAnalyse/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Functions/iAnalyse/2.png -------------------------------------------------------------------------------- /Functions/iAnalyse/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Functions/iAnalyse/4.png -------------------------------------------------------------------------------- /Functions/iAnalyse/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Functions/iAnalyse/5.png -------------------------------------------------------------------------------- /Basics of C/iAnalyse/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Basics of C/iAnalyse/1.png -------------------------------------------------------------------------------- /Basics of C/iAnalyse/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Basics of C/iAnalyse/3.png -------------------------------------------------------------------------------- /Basics of C/iAnalyse/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Basics of C/iAnalyse/4.png -------------------------------------------------------------------------------- /Pointers/iAnalyse/2(a).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Pointers/iAnalyse/2(a).png -------------------------------------------------------------------------------- /Pointers/iAnalyse/2(b).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Pointers/iAnalyse/2(b).png -------------------------------------------------------------------------------- /Arrays and Strings/iAnalyse/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Arrays and Strings/iAnalyse/4.png -------------------------------------------------------------------------------- /Arrays and Strings/iAnalyse/q2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Arrays and Strings/iAnalyse/q2.PNG -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/1/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/1/1.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/1/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/1/2.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/1/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/1/3.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/1/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/1/4.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/4/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/4/1.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/4/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/4/2.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/1.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/2.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/3.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/4.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/5.png -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/1/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/1/.DS_Store -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/4/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/4/.DS_Store -------------------------------------------------------------------------------- /Structures and Union/iAnalyse/5/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Structures and Union/iAnalyse/5/.DS_Store -------------------------------------------------------------------------------- /Conditional statements and Loops/iAnalyse/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Conditional statements and Loops/iAnalyse/2.png -------------------------------------------------------------------------------- /Conditional statements and Loops/iAnalyse/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Conditional statements and Loops/iAnalyse/3.png -------------------------------------------------------------------------------- /Conditional statements and Loops/iAnalyse/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Servatom/e-box-UTA003/HEAD/Conditional statements and Loops/iAnalyse/4.png -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/1.c: -------------------------------------------------------------------------------- 1 | /* ODD OR EVEN */ 2 | 3 | #include 4 | int main(){ 5 | int n; 6 | scanf("%d", &n); 7 | printf((n%2==0?"%d is an even number":"%d is an odd number"),n); 8 | } -------------------------------------------------------------------------------- /Basics of C/iDesign/2.c: -------------------------------------------------------------------------------- 1 | /* Odd or Even using Bitwise and Operator */ 2 | 3 | #include 4 | int main(){ 5 | int n; 6 | printf("Enter the number :\n"); 7 | scanf("%d", &n); 8 | printf((n&1)?"Odd":"Even"); 9 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # e-box-UTA003 2 | Stuck on Ebox? 3 | We have Ebox coding questions for UTA003 course. 4 | Made by a bunch of students from CSE 20-24 batch. 5 | 6 | Contributions to this repo are welcome! 7 | 8 | ![Visitor Count](https://profile-counter.glitch.me/{Concept-Team}/count.svg) 9 | -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/8.c: -------------------------------------------------------------------------------- 1 | /* Sum of first 'n' numbers */ 2 | 3 | #include 4 | int main(){ 5 | int n, sum = 0; 6 | scanf("%d", &n); 7 | for (int i =1; i <= n;i++){ 8 | sum = sum + i;} 9 | printf("%d", sum); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /Pointers/iAssess/2.c: -------------------------------------------------------------------------------- 1 | #include 2 | void update(int *a,int *b) 3 | { 4 | *a=*a+*b; 5 | *b=*a-*b*2; 6 | if(*b<0) 7 | *b=-*b; 8 | } 9 | int main() 10 | { 11 | int a,b; 12 | scanf("%d %d",&a,&b); 13 | update(&a,&b); 14 | printf("%d %d",a,b); 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Basics of C/iDesign/5.c: -------------------------------------------------------------------------------- 1 | /* Celsius to Fahrenheit Converter */ 2 | 3 | #include 4 | int main(){ 5 | int c; 6 | float f; 7 | printf("Temparature in Celsius:\n"); 8 | scanf("%d",&c); 9 | f = (1.8 * c) + 32; 10 | printf("Temparature in Fahrenheit is %.1fF",f); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Functions/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int i=1 ; 4 | int findPos(int n) 5 | { 6 | if(n==1) 7 | return i ; 8 | i*=2 ; 9 | return findPos(n/2) ; 10 | } 11 | int main() 12 | { 13 | int n ; 14 | scanf("%d",&n) ; 15 | printf("%d",findPos(n)) ; 16 | return 0 ; 17 | } 18 | -------------------------------------------------------------------------------- /Basics of C/iDesign/3.c: -------------------------------------------------------------------------------- 1 | /* Largest of three numbers using Ternary Operator */ 2 | 3 | #include 4 | int main(){ 5 | int a, b, c, max; 6 | printf("Enter the numbers :\n"); 7 | scanf("%d\n%d\n%d",&a,&b,&c); 8 | max = (a>b)?((a>c)?a:c):((b>c)?b:c); 9 | printf("%d is the greatest number",max); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/1.c: -------------------------------------------------------------------------------- 1 | /* Sum of array elements */ 2 | 3 | #include 4 | int main(){ 5 | int n, a[15], i, sum = 0; 6 | scanf("%d", &n); 7 | for(i = 0; i < n; i++) 8 | { 9 | scanf("%d", &a[i]); 10 | sum = sum + a[i]; 11 | } 12 | printf("The sum of the elements in the array is %d", sum); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Functions/iDesign/1.c: -------------------------------------------------------------------------------- 1 | //Area of a Circle 2 | 3 | #include 4 | float calcarea(float x); 5 | int main(){ 6 | float radius, area; 7 | scanf("%f",&radius); 8 | area=calcarea(radius); 9 | printf("The area of the circle is %.2f ",area); 10 | return 0; 11 | } 12 | float calcarea(float x){ 13 | float area=3.14*x*x; 14 | return area; 15 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/7.c: -------------------------------------------------------------------------------- 1 | /* Sum of Digits */ 2 | 3 | #include 4 | int main(){ 5 | int n, n1, sum = 0; 6 | printf("Enter the value :\n"); 7 | scanf("%d", &n); 8 | n1 = n; 9 | while(n>0){ 10 | sum = sum +(n%10); 11 | n = n/10; 12 | } 13 | printf("Sum of digits in %d is %d", n1, sum); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/10.c: -------------------------------------------------------------------------------- 1 | //Prime 2 | 3 | #include 4 | int main(){ 5 | int n, c=0; 6 | scanf("%d", &n); 7 | for(int i = 2; i< n/2 +1; i++){ 8 | if(n%i == 0){ 9 | c++; 10 | break; 11 | } 12 | } 13 | if(c==0) 14 | printf("Prime"); 15 | else 16 | printf("Not prime"); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/4.c: -------------------------------------------------------------------------------- 1 | /* Sum of even numbers */ 2 | 3 | #include 4 | int main(){ 5 | int n, a[15], i, sum = 0; 6 | scanf("%d", &n); 7 | for(i = 0; i < n; i++) 8 | { 9 | scanf("%d", &a[i]); 10 | if(a[i] % 2 == 0) 11 | sum = sum + a[i]; 12 | } 13 | printf("The sum of the even numbers in the array is %d", sum); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/5.c: -------------------------------------------------------------------------------- 1 | /* find the maximum element in an array */ 2 | 3 | #include 4 | int main(){ 5 | int n, a[15], i, max = 0; 6 | scanf("%d", &n); 7 | for(i = 0; i < n; i++) 8 | { 9 | scanf("%d", &a[i]); 10 | if(a[i] > max) 11 | max = a[i]; 12 | } 13 | printf("%d is the maximum element in the array", max); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Basics of C/iDesign/1.c: -------------------------------------------------------------------------------- 1 | /* Splitting into teams */ 2 | 3 | #include 4 | int main(){ 5 | int ss, team, left; 6 | printf("Number of students:\n"); 7 | scanf("%d", &ss); 8 | printf("Number of teams:\n"); 9 | scanf("%d", &team); 10 | left = ss % team; 11 | printf("The number of students in each team is %d and left out is %d", (ss/team),left); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/5.c: -------------------------------------------------------------------------------- 1 | /* Write a program to check whether a given year is a leap year or not */ 2 | 3 | #include 4 | int main(){ 5 | int year; 6 | scanf("%d", &year); 7 | if((year%4 == 0 && year%100 != 0) || (year%400 == 0)) 8 | printf("%d is a leap year", year); 9 | else 10 | printf("%d is not a leap year", year); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Functions/iDesign/6.c: -------------------------------------------------------------------------------- 1 | /* Recursion 4 : Sum of digits */ 2 | 3 | #include 4 | int computeSum(int n); 5 | int main(){ 6 | int n; 7 | printf("Enter the value of n\n"); 8 | scanf("%d",&n); 9 | printf("The sum of digits in %d is %d",n,computeSum(n)); 10 | return 0; 11 | } 12 | int computeSum(int n){ 13 | if(n==0) 14 | return 0; 15 | else return (n%10)+computeSum(n/10); 16 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/12.c: -------------------------------------------------------------------------------- 1 | /* P3 - Pascal's Triangle */ 2 | 3 | #include 4 | int main(){ 5 | int n; 6 | scanf("%d", &n); 7 | for(int i=1; i<=n;i++){ 8 | for(int j=n; j>i; j--){ 9 | printf(" "); 10 | } 11 | for(int k=1; k<=i; k++){ 12 | printf("* "); 13 | } 14 | printf("\n"); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/9.c: -------------------------------------------------------------------------------- 1 | /* Multiplication Table */ 2 | 3 | #include 4 | int main(){ 5 | int n, m, i=1; 6 | printf("Enter n\n"); 7 | scanf("%d", &n); 8 | printf("Enter m\n"); 9 | scanf("%d", &m); 10 | printf("The multiplication table of %d is\n",n); 11 | while(i<=m){ 12 | printf("%d*%d=%d\n", i, n, (i*n)); 13 | i++; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /FileHandling/iDesign/1.c: -------------------------------------------------------------------------------- 1 | /* 2 | File Copy 3 | */ 4 | 5 | #include 6 | 7 | int main(){ 8 | FILE *file_input = fopen("input.txt", "r"); 9 | FILE *file_output = fopen("output.txt", "w"); 10 | 11 | char character; 12 | 13 | while((character = fgetc(file_input)) != EOF){ 14 | fputc(character, file_output); 15 | } 16 | fclose(file_input); 17 | fclose(file_output); 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Functions/iDesign/5.c: -------------------------------------------------------------------------------- 1 | /* Recursion 2 : Fibonacci Series */ 2 | 3 | #include 4 | int fibo(int n); 5 | int main(){ 6 | int n; 7 | printf("Enter the value of n\n"); 8 | scanf("%d",&n); 9 | printf("The term %d in the fibonacci series is %d",n,fibo(n)); 10 | return 0; 11 | } 12 | int fibo(int n){ 13 | if (n==1) 14 | return 0; 15 | else if(n==2) 16 | return 1; 17 | else return fibo(n-1)+fibo(n-2); 18 | } -------------------------------------------------------------------------------- /Functions/iDesign/4.c: -------------------------------------------------------------------------------- 1 | /* Recursion 1 : Factorial */ 2 | 3 | #include 4 | int computeFactorial(int); 5 | int main(){ 6 | int n,fact; 7 | printf("Enter the value of n\n"); 8 | scanf("%d",&n); 9 | fact=computeFactorial(n); 10 | printf("The factorial of %d is %d",n,fact); 11 | return 0; 12 | } 13 | int computeFactorial(int n){ 14 | if(n==0) 15 | return 1; 16 | else 17 | return n*computeFactorial(n-1); 18 | } -------------------------------------------------------------------------------- /Functions/iDesign/7.c: -------------------------------------------------------------------------------- 1 | /* Recursion 6 : GCD of 2 Numbers */ 2 | 3 | #include 4 | int gcd(int n1, int n2); 5 | int main(){ 6 | int n1,n2; 7 | printf("Enter n1\n"); 8 | scanf("%d",&n1); 9 | printf("Enter n2\n"); 10 | scanf("%d",&n2); 11 | printf("GCD of %d and %d = %d",n1,n2,gcd(n1,n2)); 12 | return 0; 13 | } 14 | int gcd(int n1,int n2){ 15 | if(n2==0) 16 | return n1; 17 | else return gcd(n2,n1%n2); 18 | } -------------------------------------------------------------------------------- /Functions/iDesign/2.c: -------------------------------------------------------------------------------- 1 | /* Maximum of 3 Numbers */ 2 | 3 | #include 4 | int findmaximum(int,int,int); 5 | int main(){ 6 | int a,b,c; 7 | scanf("%d\n%d\n%d", &a,&b,&c); 8 | int max= findmaximum(a,b,c); 9 | printf("%d is the maximum number",max); 10 | return 0; 11 | } 12 | int findmaximum(int a, int b, int c){ 13 | if(a>b && a>c) 14 | return a; 15 | else if(b>a && b>c) 16 | return b; 17 | else 18 | return c; 19 | } -------------------------------------------------------------------------------- /Basics of C/iDesign/4.c: -------------------------------------------------------------------------------- 1 | /* Three idiots */ 2 | 3 | #include 4 | int main(){ 5 | int x1,x2,y1,y2; 6 | float x,y; 7 | printf("X1\n"); 8 | scanf("%d",&x1); 9 | printf("Y1\n"); 10 | scanf("%d",&y1); 11 | printf("X2\n"); 12 | scanf("%d",&x2); 13 | printf("Y2\n"); 14 | scanf("%d",&y2); 15 | x = (x1+x2)/2.0; 16 | y = (y1+y2)/2.0; 17 | printf("Binoy's house is located at (%.1f,%.1f)",x,y); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /FileHandling/iDesign/2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Count the number of characters in the file 3 | */ 4 | 5 | #include 6 | 7 | int main(){ 8 | FILE *file_input = fopen("sample.txt", "r"); 9 | 10 | char c; 11 | 12 | int count = 0; 13 | while((c = fgetc(file_input)) != EOF){ 14 | count = count + 1; 15 | } 16 | 17 | printf("The number of characters present in the file is %d\n", count-1); 18 | fclose(file_input); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /FileHandling/iDesign/3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Number of line in the file 3 | */ 4 | 5 | #include 6 | 7 | int main(){ 8 | FILE *input = fopen("input.txt", "r"); 9 | 10 | char c; 11 | int count = 0; 12 | while((c = fgetc(input)) != EOF){ 13 | if(c == '\n'){ 14 | count++; 15 | } 16 | else{ 17 | continue; 18 | } 19 | } 20 | 21 | printf("The file has %d lines\n", count); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/11.c: -------------------------------------------------------------------------------- 1 | /* Decimal to Binary Conversion */ 2 | 3 | #include 4 | #include 5 | int main(){ 6 | int n, bin=0, dec, i=0; 7 | printf("Enter the decimal number\n"); 8 | scanf("%d", &n); 9 | dec = n; 10 | while(n>0){ 11 | bin = bin + ((n%2) * pow(10,i)); 12 | i++; 13 | n=n/2; 14 | } 15 | printf("The binary equivalent of decimal number %d is %d", dec,bin); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Pointers/iDesign/BasicPractice/2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Odd or Even 3 | */ 4 | 5 | #include 6 | 7 | void oddoreven(int *a); 8 | 9 | int main(){ 10 | int a; 11 | printf("Enter the number\n"); 12 | scanf("%d", &a); 13 | 14 | oddoreven(&a); 15 | return 0; 16 | } 17 | 18 | void oddoreven(int *a){ 19 | if(*a%2 == 0){ 20 | printf("%d is an even number\n", *a); 21 | } 22 | else{ 23 | printf("%d is an odd number\n", *a); 24 | } 25 | } -------------------------------------------------------------------------------- /Basics of C/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int x,y,l; 4 | char s='('; 5 | char ss=')'; 6 | 7 | printf("Enter the x-coordinate of the left bottom vertex\n"); 8 | scanf("%d",&x); 9 | printf("Enter the y-coordinate of the left bottom vertex\n"); 10 | scanf("%d",&y); 11 | printf("Enter the length of a side\n"); 12 | scanf("%d",&l); 13 | x=x+(l/2); 14 | y=y+(l/2); 15 | printf("The centre of the room is at %c%d,%d%c",s,x,y,ss); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Functions/iDesign/8.c: -------------------------------------------------------------------------------- 1 | /* Recursion 3 : Compute a^n */ 2 | 3 | #include 4 | int computePower(int a, int n); 5 | int main(){ 6 | int a,n; 7 | printf("Enter the value of a\n"); 8 | scanf("%d",&a); 9 | printf("Enter the value of n\n"); 10 | scanf("%d",&n); 11 | printf("The value of %d power %d is %d",a,n,computePower(a,n)); 12 | return 0; 13 | } 14 | int computePower(int a, int n){ 15 | if(n==0) 16 | return 1; 17 | else 18 | return a*computePower(a,n-1); 19 | } -------------------------------------------------------------------------------- /Basics of C/iDesign/6.c: -------------------------------------------------------------------------------- 1 | 2 | /* Quadratic Equation Roots */ 3 | #include 4 | #include 5 | int main(){ 6 | int a, b,c; 7 | double discriminant, root1,root2; 8 | printf("Enter the values of a,b,c :\n"); 9 | scanf("%d\n%d\n%d",&a,&b,&c); 10 | discriminant = b * b - 4 * a * c; 11 | root1 = (-b + sqrt(discriminant)) / (2 * a); 12 | root2 = (-b - sqrt(discriminant)) / (2 * a); 13 | printf("The roots are:\nroot1 = %.1lf\nroot2 = %.1lf",root1,root2); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/11.c: -------------------------------------------------------------------------------- 1 | /* Letter Frequency */ 2 | 3 | #include 4 | int main() 5 | { 6 | int a[26]={ 0 }; 7 | char str[200]; 8 | printf("Enter the input string\n"); 9 | scanf("%s",str); 10 | for(int i=0;str[i]!='\0';i++) 11 | { 12 | if(str[i]>='a' && str[i]<='z') 13 | a[str[i]-97]++; 14 | } 15 | printf("The letter frequency is\n"); 16 | for(int i=0;i<26;i++) 17 | { 18 | if(a[i]!=0) 19 | printf("%c %d\n",i+97,a[i]); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Pointers/iDesign/BasicPractice/1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Addition of two numbers 3 | */ 4 | 5 | #include 6 | 7 | void addition(int *a, int *b); 8 | 9 | int main(){ 10 | int a, b; 11 | int *a_p = &a; 12 | int *b_p = &b; 13 | printf("Enter the value of a\n"); 14 | scanf("%d", a_p); 15 | 16 | printf("Enter the value of b\n"); 17 | scanf("%d", b_p); 18 | 19 | addition(a_p, b_p); 20 | return 0; 21 | } 22 | 23 | void addition(int *a, int *b){ 24 | printf("Sum of two elements = %d", *a + *b); 25 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/3.c: -------------------------------------------------------------------------------- 1 | /* search for an element ‘a’ in the array */ 2 | 3 | #include 4 | int main() 5 | { 6 | int n, arr[15], a; 7 | scanf("%d", &n); 8 | for(int i = 0; i < n; i++) 9 | { 10 | scanf("%d", &arr[i]); 11 | } 12 | scanf("%d", &a); 13 | for(int i = 0; i < n; i++) 14 | { 15 | if (arr[i] == a) 16 | { 17 | printf("%d is present in the array", a); 18 | return 0; 19 | } 20 | } 21 | printf("%d is not present in the array", a); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /FileHandling/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | FILE *f1,*f2; 6 | f1=fopen("input.txt","r"); 7 | f2=fopen("output.txt","w"); 8 | char c; 9 | c=fgetc(f1); 10 | while(c!=EOF) 11 | { 12 | if(c!=' ') 13 | fputc(c,f2); 14 | else 15 | { 16 | fputc(c,f2); 17 | c=fgetc(f1); 18 | fputc(toupper(c),f2); 19 | } 20 | c=fgetc(f1); 21 | 22 | } 23 | fclose(f1); 24 | fclose(f2); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/2.c: -------------------------------------------------------------------------------- 1 | /* Ascending Order */ 2 | 3 | #include 4 | int main(){ 5 | int n, a[15], temp; 6 | scanf("%d", &n); 7 | for(int i = 0; i < n; i++){ 8 | scanf("%d", &a[i]); 9 | } 10 | for(int i = 0; i < n; i++) 11 | { 12 | for(int j = i + 1; j < n; j++) 13 | if(a[j] < a[i]) 14 | { 15 | temp = a[j]; 16 | a[j] = a[i]; 17 | a[i] = temp; 18 | } 19 | } 20 | for(int i = 0; i < n; i++) 21 | { 22 | printf("%d ", a[i]); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Pointers/iDesign/BasicPractice/3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Swapping 2 numbers 3 | */ 4 | 5 | #include 6 | 7 | void swap(int *a, int *b); 8 | 9 | int main(){ 10 | int a, b; 11 | 12 | printf("Enter the value of a\n"); 13 | scanf("%d", &a); 14 | 15 | printf("Enter the value of b\n"); 16 | scanf("%d", &b); 17 | 18 | swap(&a, &b); 19 | return 0; 20 | } 21 | 22 | void swap(int *a, int *b){ 23 | printf("Before swapping\na = %d b = %d\n", *a, *b); 24 | int temp; 25 | temp = *a; 26 | *a = *b; 27 | *b = temp; 28 | printf("After swapping\na = %d b = %d", *a, *b); 29 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/9.c: -------------------------------------------------------------------------------- 1 | /* String Sorting */ 2 | 3 | #include 4 | #include 5 | int main(){ 6 | char str[20], temp; 7 | printf("Enter the input string\n"); 8 | scanf("%s", str); 9 | int len = strlen(str); 10 | for(int i = 0; i < len; i++) 11 | { 12 | for(int j = i+1; j < len; j++) 13 | { 14 | if(str[j] < str[i]) 15 | { 16 | temp = str[j]; 17 | str[j] = str[i]; 18 | str[i] = temp; 19 | } 20 | } 21 | } 22 | printf("The output string is %s", str); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/8.c: -------------------------------------------------------------------------------- 1 | /* Palindrome */ 2 | 3 | #include 4 | int main(){ 5 | char str[50]; int len = 0; 6 | printf("Enter a string\n"); 7 | scanf("%s", str); 8 | while(str[len] != '\0') 9 | { 10 | len++; 11 | } 12 | int begin = 0, middle = len/2, end = len - 1; 13 | for( ; begin < middle; begin++) 14 | { 15 | if(str[begin]!=str[end]) 16 | { 17 | printf("%s is not a palindrome", str); 18 | return 0; 19 | } 20 | end--; 21 | } 22 | if(begin == middle) 23 | printf("%s is a palindrome", str); 24 | return 0; 25 | } -------------------------------------------------------------------------------- /Pointers/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void manipulate(char *a) 4 | { 5 | int i,len; 6 | 7 | for(i=0;*(a+i)!='\0';i++); 8 | len=i; 9 | for(i=0;i 4 | int main(){ 5 | int m, A[10][10], B[10][10], C[10][10]; 6 | scanf("%d", &m); 7 | for(int i = 0; i < m; i++) 8 | for(int j = 0; j < m; j++) 9 | scanf("%d", &A[i][j]); 10 | for(int i = 0; i < m; i++) 11 | for(int j = 0; j < m; j++) 12 | scanf("%d", &B[i][j]); 13 | for(int i = 0; i < m; i++) 14 | for(int j = 0; j < m; j++) 15 | C[i][j] = A[i][j] + B[i][j]; 16 | for(int i = 0; i < m; i++){ 17 | for(int j = 0; j < m; j++) 18 | printf("%d ", C[i][j]); 19 | printf("\n"); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/2.c: -------------------------------------------------------------------------------- 1 | /* TRIANGLE TYPE */ 2 | 3 | #include 4 | int main(){ 5 | int a,b,c; 6 | scanf("%d %d %d", &a, &b, &c); 7 | if(a+b+c == 180){ 8 | if(a==b && b==c) 9 | printf("Triangle is equilateral"); 10 | else if(a==b||b==c||a==c){ 11 | if(a==90 || b==90 || c==90) 12 | printf("Triangle is right isosceles"); 13 | else 14 | printf("Triangle is isosceles"); 15 | } 16 | else if(a==90||b==90||c==90) 17 | printf("Triangle is right"); 18 | else 19 | printf("Triangle is not special"); 20 | } 21 | else 22 | printf("Not a Triangle"); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/3.c: -------------------------------------------------------------------------------- 1 | /* Electricity Bill */ 2 | 3 | #include 4 | int main(){ 5 | int user_id, units ; char name[50]; float amt; 6 | printf("Enter the user id of user\n"); 7 | scanf("%d", &user_id); 8 | printf("Enter the name of user\n"); 9 | scanf("%s", name); 10 | printf("Enter the number of units consumed by user\n"); 11 | scanf("%d", &units); 12 | 13 | if(units <= 100) 14 | amt = units*1.00; 15 | else if(units>100 && units<=300) 16 | amt = units * 2.00; 17 | else 18 | amt = units * 3.00; 19 | 20 | if(amt > 1000) 21 | amt = amt + (0.15*amt); 22 | 23 | if(amt<50) 24 | amt = 50; 25 | 26 | printf("Charge details\n%d %s %.2f",user_id, name, amt); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/7.c: -------------------------------------------------------------------------------- 1 | /* Matrix Multiplication */ 2 | 3 | #include 4 | int main(){ 5 | int m, A[10][10], B[10][10], C[10][10]; 6 | scanf("%d", &m); 7 | for(int i = 0; i < m; i++) 8 | for(int j = 0; j < m; j++) 9 | scanf("%d", &A[i][j]); 10 | 11 | for(int i = 0; i < m; i++) 12 | for(int j = 0; j < m; j++) 13 | scanf("%d", &B[i][j]); 14 | 15 | for (int i = 0; i < m; ++i) { 16 | for (int j = 0; j < m; ++j) { 17 | C[i][j] = 0; 18 | for (int k = 0; k < m; k++) { 19 | C[i][j] += A[i][k] * B[k][j]; 20 | } 21 | } 22 | } 23 | 24 | for(int i = 0; i < m; i++){ 25 | for(int j = 0; j < m; j++) 26 | printf("%d ", C[i][j]); 27 | printf("\n"); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Pointers/iDesign/BasicPractice/5.c: -------------------------------------------------------------------------------- 1 | /* 2 | Maximum of 3 numbers 3 | */ 4 | 5 | #include 6 | 7 | int maximum(int *a, int *b, int *c); 8 | 9 | int main(){ 10 | int a, b, c; 11 | 12 | printf("Enter the value of a\n"); 13 | scanf("%d", &a); 14 | 15 | printf("Enter the value of b\n"); 16 | scanf("%d", &b); 17 | 18 | printf("Enter the value of c\n"); 19 | scanf("%d", &c); 20 | 21 | int max = maximum(&a, &b, &c); 22 | printf("Maximum element is %d", max); 23 | return 0; 24 | } 25 | int maximum(int *a, int *b, int *c){ 26 | if(*a > *b){ 27 | if(*a > *c){ 28 | return *a; 29 | } 30 | else{ 31 | return *c; 32 | } 33 | } 34 | else if(*b > *c){ 35 | return *b; 36 | } 37 | else{ 38 | return *c; 39 | } 40 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | # OS generated files # 55 | ###################### 56 | .DS_Store 57 | .DS_Store? 58 | ._* 59 | .Spotlight-V100 60 | .Trashes 61 | ehthumbs.db 62 | Thumbs.db 63 | -------------------------------------------------------------------------------- /Pointers/iDesign/BasicPractice/4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Distance between 2 points 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | float distance(int *x1, int *y1, int *x2, int *y2); 9 | 10 | int main(){ 11 | int x1, y1; 12 | int x2, y2; 13 | 14 | printf("Enter x1\n"); 15 | scanf("%d", &x1); 16 | 17 | printf("Enter y1\n"); 18 | scanf("%d", &y1); 19 | 20 | printf("Enter x2\n"); 21 | scanf("%d", &x2); 22 | 23 | printf("Enter y2\n"); 24 | scanf("%d", &y2); 25 | 26 | float dist = distance(&x1,&y1, &x2, &y2); 27 | printf("Distance between 2 points is %.2f", dist); 28 | return 0; 29 | } 30 | 31 | float distance(int *x1, int *y1, int *x2, int *y2){ 32 | float dist_sqr = ((*x1 - *x2)*(*x1 - *x2)) + ((*y1 - *y2)*(*y1 - *y2)); 33 | float dist = sqrt(dist_sqr); 34 | return dist; 35 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/4.c: -------------------------------------------------------------------------------- 1 | /* Display Grade */ 2 | 3 | #include 4 | int main(){ 5 | int roll_no, mark; 6 | char name[50],grade; 7 | printf("Enter the roll number of student\n"); 8 | scanf("%d", &roll_no); 9 | printf("Enter the name of student\n"); 10 | scanf("%s", name); 11 | printf("Enter the total mark of student\n"); 12 | scanf("%d", &mark); 13 | if(mark >= 50){ 14 | if(mark >= 90) 15 | grade = 'A'; 16 | else if(mark >= 80) 17 | grade = 'B'; 18 | else if(mark >= 70) 19 | grade = 'C'; 20 | else if(mark >= 60) 21 | grade = 'D'; 22 | else if(mark >= 50) 23 | grade = 'E'; 24 | printf("Grade details\n%d %s %d %c", roll_no, name, mark, grade); 25 | } 26 | else 27 | printf("Grade details\n%d %s %d Fail", roll_no, name, mark); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /Arrays and Strings/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main(){ 4 | int i, j, a, n,*number; 5 | printf("Enter the number of elements in an array \n"); 6 | scanf("%d", &n); 7 | number=(int*)malloc(n*sizeof(int)) ; 8 | printf("Enter the array elements \n"); 9 | for (i = 0; i < n; ++i) 10 | scanf("%d", (number+i)); 11 | 12 | for (i = 0; i < n; ++i) 13 | { 14 | for (j = i + 1; j < n; ++j) 15 | { 16 | if (*(number+i) > *(number+j)) 17 | { 18 | a = *(number+i); 19 | *(number+i) = *(number+j) ; 20 | *(number+j) = a; 21 | } 22 | } 23 | } 24 | 25 | printf("Sorted array\n"); 26 | for (i = 0; i < n; ++i) 27 | printf("%d\n", *(number+i)); 28 | return 0 ; 29 | } 30 | -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/12.c: -------------------------------------------------------------------------------- 1 | /* String reverse without special characters */ 2 | 3 | #include 4 | #include 5 | int main() 6 | { 7 | char arr[100]; 8 | scanf("%s",arr); 9 | int d=strlen(arr); 10 | int i=0,j=d-1,temp=0; 11 | while(i=97 && arr[i]<=122) || (arr[i]>=65 && arr[i]<=90)) 14 | flag=1; 15 | if((arr[j]>=97 && arr[j]<=122) || (arr[j]>=65 && arr[j]<=90)) 16 | count=1; 17 | if(flag==0){ 18 | i++;continue; 19 | } 20 | if(count==0){ 21 | j--; 22 | continue; 23 | } 24 | if(flag==1 && count==1){ 25 | temp=arr[i]; 26 | arr[i]=arr[j]; 27 | arr[j]=temp; 28 | i++; 29 | j--; 30 | } 31 | } 32 | printf("%s",arr); 33 | return 0; 34 | 35 | 36 | 37 | } -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/5.c: -------------------------------------------------------------------------------- 1 | /* 2 | Functions- Lucky String 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | int checkLucky(char * a); 10 | 11 | int main(){ 12 | char *string = (char*)malloc(100*sizeof(char)); 13 | 14 | printf("Enter the input string\n"); 15 | scanf("%s", &(*string)); 16 | int isLucky = checkLucky(string); //0 false 1 true 17 | if(isLucky){ 18 | printf("%s is lucky\n", string); 19 | } 20 | else{ 21 | printf("%s is not lucky\n", string); 22 | } 23 | 24 | return 0; 25 | } 26 | 27 | int checkLucky(char *a){ 28 | int size = strlen(a); 29 | int ascii_sum = 0; 30 | for(int i = 0; i < size; i++){ 31 | ascii_sum = ascii_sum + (int)(*(a++)); 32 | } 33 | 34 | if(ascii_sum%2 == 0){ 35 | //Its lucky 36 | return 1; 37 | } 38 | else{ 39 | return 0; 40 | } 41 | 42 | return -1; 43 | } -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/4.c: -------------------------------------------------------------------------------- 1 | /* 2 | Teaching sum of elements 3 | */ 4 | #include 5 | #include 6 | 7 | int wrongsetsum(int n, int *a); 8 | int correctsetsum(int n, int *a); 9 | 10 | int main(){ 11 | int size; 12 | scanf("%d", &size); 13 | int *number_array = (int*)malloc(size*sizeof(int)); //Array 14 | int *input_array = number_array; 15 | 16 | for(int i = 0; i < size; i++){ 17 | scanf("%d", &(*(input_array++))); 18 | } 19 | 20 | printf("%d\n%d\n", wrongsetsum(size, number_array), correctsetsum(size, number_array)); 21 | 22 | return 0; 23 | } 24 | 25 | int wrongsetsum(int n, int *a){ 26 | int sum = 0; 27 | for(int i = 0; i < n; i++){ 28 | int temp_n = *(a++); 29 | if(temp_n < 0){ 30 | sum = sum + ((-1)*temp_n); 31 | } 32 | else{ 33 | sum = sum + temp_n; 34 | } 35 | } 36 | 37 | return sum; 38 | } 39 | 40 | int correctsetsum(int n, int *a){ 41 | int sum = 0; 42 | for(int i = 0; i < n; i++){ 43 | sum = sum + *(a++); 44 | } 45 | 46 | return sum; 47 | } -------------------------------------------------------------------------------- /Conditional statements and Loops/iDesign/6.c: -------------------------------------------------------------------------------- 1 | /* Switch operations */ 2 | 3 | #include 4 | int main(){ 5 | int a, b, choice, result; 6 | printf("Enter the first value :\n"); 7 | scanf("%d", &a); 8 | printf("Enter the second value :\n"); 9 | scanf("%d", &b); 10 | printf("Enter the choice from the menu\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n"); 11 | scanf("%d",&choice); 12 | 13 | switch(choice){ 14 | case 1: 15 | result = a+b; 16 | printf("The value after Addition is %d.",result); 17 | break; 18 | case 2: 19 | result = a-b; 20 | printf("The value after Subtraction is %d.",result); 21 | break; 22 | case 3: 23 | result = a*b; 24 | printf("The value after Multiplication is %d.",result); 25 | break; 26 | case 4: 27 | result = a/b; 28 | printf("The value after Division is %d.",result); 29 | break; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Functions- Array Type 3 | */ 4 | #include 5 | #include 6 | int findType(int n, int *a) 7 | { 8 | int count=0 ; 9 | 10 | for(int i=0 ; i 6 | 7 | int findMax(int n, int *a); 8 | 9 | int main(){ 10 | int n; 11 | int array[20]; 12 | 13 | printf("Enter the number of elements in the array\n"); 14 | scanf("%d", &n); 15 | if(n > 20){ 16 | printf("Max storage is for 20 elements!\n"); 17 | return 1; 18 | } 19 | 20 | printf("Enter the elements in the array\n"); 21 | for(int i = 0; i < n; i++){ 22 | scanf("%d", &array[i]); 23 | } 24 | 25 | printf("The maximum element in the array is %d", findMax(n, array)); 26 | 27 | return 0; 28 | } 29 | 30 | int findMax(int n, int *a){ 31 | int array_temp[n]; 32 | for(int i = 0; i < n; i++){ 33 | array_temp[i] = *a++; 34 | } 35 | 36 | for(int i = 0; i < n; i++){ 37 | if(array_temp[0] < array_temp[i]){ 38 | int temp = array_temp[i]; 39 | array_temp[i] = array_temp[0]; 40 | array_temp[0] = temp; 41 | } 42 | } 43 | 44 | return array_temp[0]; 45 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Servatom 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Structures and Union/iDesign/3.c: -------------------------------------------------------------------------------- 1 | /* 2 | Student Marks 3 | */ 4 | 5 | #include 6 | 7 | struct Student{ 8 | int rollno; 9 | char name[20]; 10 | int marks[5]; 11 | int total; 12 | float average; 13 | }; 14 | 15 | int main(){ 16 | struct Student a[3]; 17 | int i, j, max = 0 , index = 0; 18 | 19 | for(i = 0; i < 3; i++){ 20 | printf("Enter the student %d rollno:\n", i+1); 21 | scanf("%d", &a[i].rollno); 22 | 23 | printf("Enter the student %d name:\n", i+1); 24 | scanf("%s", a[i].name); 25 | a[i].total=0; 26 | 27 | for(j = 0; j < 5; j++){ 28 | printf("Enter the student %d marks%d:\n", i+1, j+1); 29 | scanf("%d", &a[i].marks[j]); 30 | a[i].total += a[i].marks[j]; 31 | } 32 | 33 | a[i].average = (float)a[i].total/5; 34 | if(a[i].average > max){ 35 | max = a[i].average; 36 | index = i; 37 | } 38 | } 39 | printf("Student Details:\n"); 40 | printf("Name:%s\n", a[index].name); 41 | printf("RollNo:%d\n",a[index].rollno); 42 | printf("Total:%d\n", a[index].total); 43 | printf("Average:%.2f\n", a[index].average); 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/2.c: -------------------------------------------------------------------------------- 1 | /* 2 | Functions- Standard Deviation 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | float findMean(int n, int *a); 9 | float standardDeviation(int n, int *a); 10 | 11 | int main(){ 12 | int size; 13 | printf("Enter the number of elements in the array\n"); 14 | scanf("%d", &size); 15 | 16 | if(size < 0){ 17 | return 1; 18 | } 19 | 20 | printf("Enter the elements in the array\n"); 21 | int number_array[size]; 22 | 23 | for(int i = 0; i < size; i++){ 24 | scanf("%d", &number_array[i]); 25 | } 26 | float standard_deviation = standardDeviation(size, number_array); 27 | printf("The standard deviation is %.2f\n", standard_deviation); 28 | return 0; 29 | } 30 | 31 | float findMean(int n, int *a){ 32 | float mean = 0; 33 | float sum = 0; 34 | for(int i = 0; i < n; i++){ 35 | sum = sum + (float)(*(a++)); 36 | } 37 | mean = (float)(sum/n); 38 | return mean; 39 | } 40 | 41 | float standardDeviation(int n, int *a){ 42 | float sd = 0; 43 | int *array = a; 44 | float mean = findMean(n, array); 45 | for(int i = 0; i < n; i++){ 46 | sd = sd + pow((*(a++) - mean), 2); 47 | } 48 | 49 | sd = sqrt(sd/n); 50 | return sd; 51 | } -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/6.c: -------------------------------------------------------------------------------- 1 | /* 2 | Functions-Matrix Maximum 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int findMax(int **a, int m, int n){ 9 | int i, j, max = 0; 10 | for(i = 0; i <= m-1; i++){ 11 | for(j = 0; j <= n-1; j++){ 12 | if(max 6 | 7 | int main(){ 8 | struct employee{ 9 | char name[50]; 10 | int employeeid; 11 | int age; 12 | char designation[50]; 13 | float salary; 14 | }; 15 | int number_employees = 5; 16 | struct employee employees[number_employees]; 17 | 18 | for(int i = 0; i < number_employees; i++){ 19 | printf("Enter details for employee %d\n", i+1); 20 | 21 | printf("Enter employee name\n"); 22 | scanf("%s", employees[i].name); 23 | 24 | printf("Enter employee id\n"); 25 | scanf("%d", &employees[i].employeeid); 26 | 27 | printf("Enter employee age\n"); 28 | scanf("%d", &employees[i].age); 29 | 30 | printf("Enter employee designation\n"); 31 | scanf("%s", employees[i].designation); 32 | 33 | printf("Enter employee salary\n"); 34 | scanf("%f", &employees[i].salary); 35 | } 36 | 37 | for(int i = 0; i < number_employees; i++){ 38 | printf("Details of employee %d\n", i+1); 39 | printf("Employee name:%s\n", employees[i].name); 40 | printf("Employee id:%d\n", employees[i].employeeid); 41 | printf("Employee age:%d\n", employees[i].age); 42 | printf("Employee designation:%s\n", employees[i].designation); 43 | printf("Employee salary:%.2f\n", employees[i].salary); 44 | } 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Structures and Union/iDesign/1.c: -------------------------------------------------------------------------------- 1 | /* 2 | Structures: Student 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int main(){ 9 | struct Student{ 10 | char name[30]; 11 | char department[20]; 12 | int yearOfStudy; 13 | float cgpa; 14 | }; 15 | 16 | int number_of_students; 17 | printf("Enter the number of students\n"); 18 | scanf("%d", &number_of_students); 19 | 20 | struct Student students[number_of_students]; 21 | 22 | for(int i = 0; i < number_of_students; i++){ 23 | printf("Enter the details of student %d\n", i+1); 24 | printf("Enter name\n"); 25 | scanf("%s", students[i].name); 26 | 27 | printf("Enter department\n"); 28 | scanf("%s", students[i].department); 29 | 30 | printf("Enter year of study\n"); 31 | scanf("%d", &students[i].yearOfStudy); 32 | 33 | printf("Enter cgpa\n"); 34 | scanf("%f", &students[i].cgpa); 35 | } 36 | 37 | for(int i = 0; i < number_of_students; i++){ 38 | for(int j = i + 1; j < number_of_students; j++){ 39 | if((strcmp(students[i].name,students[j].name)) > 0){ 40 | struct Student temp = students[i]; 41 | students[i] = students[j]; 42 | students[j] = temp; 43 | } 44 | } 45 | } 46 | 47 | printf("Details of students\n"); 48 | for(int i = 0; i < number_of_students; i++){ 49 | printf("Student %d\n", i+1); 50 | printf("Name: %s\n", students[i].name); 51 | printf("Department: %s\n", students[i].department); 52 | printf("Year of study: %d\n", students[i].yearOfStudy); 53 | printf("CGPA: %.2f\n", students[i].cgpa); 54 | 55 | } 56 | return 0; 57 | } -------------------------------------------------------------------------------- /Functions/iDesign/3.c: -------------------------------------------------------------------------------- 1 | //CALCULATOR 2 | 3 | #include 4 | #include 5 | int addition(int a, int b); 6 | int subtraction(int a, int b); 7 | int multiplication(int a, int b); 8 | float division(int a, int b); 9 | int modulo(int a, int b); 10 | float average(int a, int b); 11 | int power(int a, int b); 12 | int main(){ 13 | int a,b,choice; 14 | float result; 15 | scanf("%d\n%d\n%d",&a,&b,&choice); 16 | switch(choice){ 17 | case 1: 18 | //int result; 19 | result = addition(a,b); 20 | printf("%.0f",result); 21 | break; 22 | case 2: 23 | //int result; 24 | result = subtraction(a,b); 25 | printf("%.0f",result); 26 | break; 27 | case 3: 28 | //int result; 29 | result = multiplication(a,b); 30 | printf("%.0f",result); 31 | break; 32 | case 4: 33 | //float result; 34 | result = division(a,b); 35 | printf("%.2f",result); 36 | break; 37 | case 5: 38 | //int result; 39 | result = modulo(a,b); 40 | printf("%.0f",result); 41 | break; 42 | case 6: 43 | //float result; 44 | result = average(a,b); 45 | printf("%.2f",result); 46 | break; 47 | case 7: 48 | //int result; 49 | result = power(a,b); 50 | printf("%.0f",result); 51 | break; 52 | } 53 | return 0; 54 | } 55 | int addition(int a, int b){ 56 | return (a+b); 57 | } 58 | int subtraction(int a, int b){ 59 | return (a-b); 60 | } 61 | int multiplication(int a, int b){ 62 | return (a*b); 63 | } 64 | float division(int a, int b){ 65 | return ((float)a/b); 66 | } 67 | int modulo(int a, int b){ 68 | return (a%b); 69 | } 70 | float average(int a, int b){ 71 | return ((a+b)/2.0); 72 | } 73 | int power(int a, int b){ 74 | return (int)pow(a,b); 75 | } -------------------------------------------------------------------------------- /FileHandling/iExplore/I explore files.txt: -------------------------------------------------------------------------------- 1 | 1. When fopen() is not able to open a file, it returns 2 | Ans: NULL 3 | 4 | 2. getc() returns EOF when 5 | A) End of files is reached 6 | B) When getc() fails to read a character 7 | Ans: Both A and B 8 | 9 | 3. The text file "Sample.txt" consists of the following text: 10 | True peace is not merely the absence of tension. 11 | 12 | Determine the output when the following is executed: 13 | #include 14 | #include 15 | int main() 16 | { 17 | FILE *fptr; 18 | char filename[100], c; 19 | fptr = fopen("Sample.txt", "r"); 20 | if (fptr == NULL) 21 | { 22 | printf("Cannot open file \n"); 23 | exit(0); 24 | } 25 | c = fgetc(fptr); 26 | while (c != EOF) 27 | { 28 | printf ("%c", c); 29 | c = fgetc(fptr); 30 | } 31 | fclose(fptr); 32 | return 0; 33 | } 34 | Ans: True peace is not merely the absence of tension. 35 | 36 | 4. The code below read from your keyboard input until an ENTER is pressed, convert any lower case letter to upper case, and then write it to a file: 37 | 38 | L1: ch=getchar(); 39 | L2: while (ch!='\n') { 40 | L3: if (ch>='a' and ch<='z') 41 | L4: ch=ch-'A'+'a'; 42 | L5: fputc(ch,fp); 43 | L6: ch=getchar(); 44 | L7: } 45 | L8: fclose(fp); 46 | 47 | Which line(s) is/are incorrect ? 48 | Ans: L3 L4 49 | 50 | 5. What is the meant by ‘a’ in the following operation? 51 | fp = fopen(“Random.txt”, “a”); 52 | Ans: Append 53 | 54 | 6. Which of the following fopen statements are illegal? 55 | Ans: None of the mentioned 56 | 57 | 7. Which of the following true about FILE *fp ? 58 | Ans: FILE is a structure and fp is a pointer to the structure of FILE type 59 | 60 | 8. FILE is of type ______ ? 61 | Ans: struct type 62 | 63 | 9. The text file "Sample.txt" consists of the following text: 64 | True peace is not merely the absence of tension. 65 | 66 | Determine the output when the following is executed: 67 | #include 68 | int main() 69 | { 70 | int i; 71 | char c; 72 | FILE *fptr; 73 | fptr=fopen("Sample.txt","r"); 74 | for(i=0; i<14; i++) { 75 | c=fgetc(fptr); 76 | if (i>7) 77 | putchar(c); 78 | } 79 | fclose(fptr); 80 | } 81 | Ans: ce is 82 | 83 | 10. For binary files, a ___ must be appended to the mode string. 84 | Ans: "b" 85 | 86 | 87 | -------------------------------------------------------------------------------- /Arrays and Strings/iDesign/10.c: -------------------------------------------------------------------------------- 1 | /* OPERATIONS ON STRINGS */ 2 | 3 | #include 4 | #define SIZE 20 5 | 6 | int stringLength(char string[], int size); 7 | void revString(char string[], char rev_word[], int size); 8 | void concString(char s1[], char s2[], char result[], int size); 9 | int compareString(char s1[], char s2[]); 10 | 11 | int main(){ 12 | char word1[SIZE]; 13 | char word2[SIZE]; 14 | scanf("%s", word1); 15 | scanf("%s", word2); 16 | 17 | //Length of string 18 | printf("Length of the first string is %d\n", stringLength(word1, SIZE)); 19 | printf("Length of the second string is %d\n", stringLength(word2, SIZE)); 20 | 21 | //Rev string 22 | char rev_word[SIZE]; 23 | revString(word1, rev_word, SIZE); 24 | printf("The reverse of the first string is %s\n", rev_word); 25 | 26 | revString(word2, rev_word, SIZE); 27 | printf("The reverse of the second string is %s\n", rev_word); 28 | 29 | //Conc string 30 | char cat_string[SIZE*2]; 31 | concString(word1, word2, cat_string, SIZE); 32 | printf("The concatenated string is %s\n", cat_string); 33 | 34 | //Compare string 35 | int diff = compareString(word1, word2); 36 | if(diff > 0){ 37 | printf("%s appears before %s\n", word2, word1); 38 | } 39 | else if (diff < 0){ 40 | printf("%s appears before %s\n", word1, word2); 41 | } 42 | else{ 43 | printf("Both the input strings are same\n"); 44 | } 45 | } 46 | int stringLength(char string[], int size){ 47 | int count = 0; 48 | for(int i = 0; i < size; i++){ 49 | if(string[i] != '\0'){ 50 | count++; 51 | } 52 | else{ 53 | break; 54 | } 55 | } 56 | return count; 57 | } 58 | 59 | void revString(char string[], char rev_word[], int size){ 60 | int temp_size = stringLength(string, size); 61 | int rev = 0; 62 | 63 | for(int i = temp_size - 1; i >= 0 && rev < temp_size; i--, rev++){ 64 | rev_word[rev] = string[i]; 65 | } 66 | rev_word[rev] = '\0'; 67 | } 68 | 69 | void concString(char s1[], char s2[], char result[], int size){ 70 | int oneLength = stringLength(s1, size); 71 | int twoLength = stringLength(s2, size); 72 | int j = 0; 73 | 74 | for(int i = 0; i < oneLength; i++, j++){ 75 | result[j] = s1[i]; 76 | } 77 | for(int i = 0; i < twoLength; i++, j++){ 78 | result[j] = s2[i]; 79 | } 80 | result[j] = '\0'; 81 | } 82 | 83 | int compareString(char s1[], char s2[]){ 84 | int i; 85 | 86 | for(i = 0; s1[i] == s2[i]; i++){ 87 | if(s1[i] == '\0'){ 88 | return 0; 89 | } 90 | } 91 | return s1[i] - s2[i]; 92 | } -------------------------------------------------------------------------------- /Structures and Union/iAssess/1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | struct Date 5 | { 6 | int day; 7 | char month[10]; 8 | int year; 9 | }; 10 | 11 | struct Event 12 | { 13 | char name[30]; 14 | char type[30]; 15 | int duration; 16 | float expenses; 17 | struct Date scheduledDate; 18 | }; 19 | int monthcalc(char *s) 20 | { 21 | if(strcmp(s,"January")==0) 22 | return 1; 23 | else if(strcmp(s,"February")==0) 24 | return 2; 25 | else if(strcmp(s,"March")==0) 26 | return 3; 27 | else if(strcmp(s,"April")==0) 28 | return 4; 29 | else if(strcmp(s,"May")==0) 30 | return 5; 31 | else if(strcmp(s,"June")==0) 32 | return 6; 33 | else if(strcmp(s,"July")==0) 34 | return 7; 35 | else if(strcmp(s,"August")==0) 36 | return 8; 37 | else if(strcmp(s,"September")==0) 38 | return 9; 39 | else if(strcmp(s,"October")==0) 40 | return 10; 41 | else if(strcmp(s,"November")==0) 42 | return 11; 43 | else 44 | return 12; 45 | } 46 | 47 | int main() 48 | { 49 | int i,j,n; 50 | printf("Enter the number of events\n"); 51 | scanf("%d",&n); 52 | struct Event e[n]; 53 | struct Event temp; 54 | for(i=0;ie[j+1].scheduledDate.year) 76 | { 77 | temp=e[j]; 78 | e[j]=e[j+1]; 79 | e[j+1]=temp; 80 | } 81 | else if((e[j].scheduledDate.year==e[j+1].scheduledDate.year)&&(monthcalc(e[j].scheduledDate.month)>monthcalc(e[j+1].scheduledDate.month))) 82 | { 83 | temp=e[j]; 84 | e[j]=e[j+1]; 85 | e[j+1]=temp; 86 | } 87 | else if((e[j].scheduledDate.year==e[j+1].scheduledDate.year)&&(monthcalc(e[j].scheduledDate.month)==monthcalc(e[j+1].scheduledDate.month))&&(e[j].scheduledDate.day>e[j+1].scheduledDate.day)) 88 | { 89 | temp=e[j]; 90 | e[j]=e[j+1]; 91 | e[j+1]=temp; 92 | } 93 | } 94 | } 95 | printf("Event details sorted by scheduled date\n"); 96 | for(i=0;i 2 | int main() 3 | { 4 | int N,ptsA=0,ptsB=0,i,j,flag=0; 5 | scanf("%d",&N); 6 | int ar[N]; 7 | for(i=0;i=4) 16 | { 17 | for(j=1;j<=4;j++) 18 | if(ar[i+j]>10||ar[i+j]==1) 19 | flag=1; 20 | 21 | if(flag==0) 22 | { 23 | printf("Player A scores 4 point(s)\n"); 24 | ptsA+=4; 25 | } 26 | } 27 | else if(ar[i]==13&&(N-i-1)>=3) 28 | { 29 | for(j=1;j<=3;j++) 30 | if(ar[i+j]>10||ar[i+j]==1) 31 | flag=1; 32 | 33 | if(flag==0) 34 | { 35 | printf("Player A scores 3 point(s)\n"); 36 | ptsA+=3; 37 | } 38 | } 39 | else if(ar[i]==12&&(N-i-1)>=2) 40 | { 41 | for(j=1;j<=2;j++) 42 | if(ar[i+j]>10||ar[i+j]==1) 43 | flag=1; 44 | 45 | if(flag==0) 46 | { 47 | printf("Player A scores 2 point(s)\n"); 48 | ptsA+=2; 49 | } 50 | } 51 | else if(ar[i]==11&&(N-i-1)>=1) 52 | { 53 | 54 | if(ar[i+1]>10||ar[i+1]==1) 55 | flag=1; 56 | 57 | if(flag==0) 58 | { 59 | printf("Player A scores 1 point(s)\n"); 60 | ptsA+=1; 61 | } 62 | } 63 | } 64 | else 65 | { 66 | if(ar[i]==1&&(N-i-1)>=4) 67 | { 68 | for(j=1;j<=4;j++) 69 | if(ar[i+j]>10||ar[i+j]==1) 70 | flag=1; 71 | 72 | if(flag==0) 73 | { 74 | printf("Player B scores 4 point(s)\n"); 75 | ptsB+=4; 76 | } 77 | } 78 | else if(ar[i]==13&&(N-i-1)>=3) 79 | { 80 | for(j=1;j<=3;j++) 81 | if(ar[i+j]>10||ar[i+j]==1) 82 | flag=1; 83 | 84 | if(flag==0) 85 | { 86 | printf("Player B scores 3 point(s)\n"); 87 | ptsB+=3; 88 | } 89 | } 90 | else if(ar[i]==12&&(N-i-1)>=2) 91 | { 92 | for(j=1;j<=2;j++) 93 | if(ar[i+j]>10||ar[i+j]==1) 94 | flag=1; 95 | 96 | if(flag==0) 97 | { 98 | printf("Player B scores 2 point(s)\n"); 99 | ptsB+=2; 100 | } 101 | } 102 | else if(ar[i]==11&&(N-i-1)>=1) 103 | { 104 | 105 | if(ar[i+1]>10||ar[i+1]==1) 106 | flag=1; 107 | 108 | if(flag==0) 109 | { 110 | printf("Player B scores 1 point(s)\n"); 111 | ptsB+=1; 112 | } 113 | } 114 | } 115 | } 116 | 117 | printf("Player A: %d point(s)\n",ptsA); 118 | printf("Player B: %d point(s)",ptsB); 119 | return 0; 120 | } 121 | -------------------------------------------------------------------------------- /Pointers/iDesign/DynamicMemoryAllocation/7.c: -------------------------------------------------------------------------------- 1 | /* 2 | Matrix Types 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int findSymmetric(int **a,int n) 9 | { 10 | int count=0 ; 11 | for(int i=0 ; i