├── README.md ├── Module 1-Fundamentals of C Programming ├── T02-Setting up environment │ └── Compilers and Interpreters.c.txt ├── T11-Repetitive Constructs in C │ ├── Loops - The for Loop.c.txt │ └── Loops - The while and do-while Loops.c.txt ├── T13- Repetitive Constructs in C-III │ └── Demonstartion of Number Techniques.c.txt ├── T06-Expressions │ └── Expressions.c.txt ├── T05-Operators-II │ └── Operators- Part-II.c.txt ├── T03-Fundamental Concepts in C │ ├── Variables.c.txt │ └── Type Conversion.c.txt ├── T09-Decision Making in C-If else statement │ ├── Solution to Exercise │ ├── Selection Statements- The Switch Statement.c.txt │ ├── Introduction.c.txt │ └── Selection Statements- The if-else-if-else Ladder and Nested if Statement.c.txt ├── T12- Repetitive Constructs in C-II │ ├── Demonstartion of Number Techniques.c.txt │ ├── Demonstration of Series Generation.c.txt │ └── Demonstration of Elementary Techniques.c.txt ├── T08- IO Functions │ └── IO_Functions.c.txt ├── T07-Math Functions │ └── Math Functions.c.txt ├── T04-Operators-I │ └── Operators.c.txt └── T10- Decision Making in C - Ternary Operators │ └── Selection Statements - Program Demonstrations.c.txt ├── Module 2-Advanced C Programming ├── T09-Strings │ └── Strings in C Programming.c.txt ├── T13-User defined data types-II │ └── Enumeration.c.txt ├── T03-Single Dimensional Arrays I │ └── One-Dimensional Arrays.c.txt ├── T11-Pointers II │ ├── Function Pointers.c.txt │ └── Dynamic Memory Allocation.c.txt ├── T10-Pointers I │ ├── Functions and Pointers.c.txt │ └── Pointers.c.txt ├── T15-Pre-compiler directives │ └── Preprocessor Directives - I.c.txt ├── T05-Single Dimensional Arrays III │ ├── Sorting Arrays.c.txt │ └── Concatenating and Merging One-Dimensional Arrays.c.txt ├── T02-User defined functions │ ├── Functions.c.txt │ └── Methods of Calling a Function.c.txt ├── T12-User defined data types-I │ ├── Structures.c.txt │ └── Unions.c.txt ├── T06-Multi-Dimensional Arrays I │ └── Two-Dimensional Arrays.c.txt ├── T08-Dealing with characters │ └── Dealing with Characters.c.txt └── T04-Single Dimensional Arrays II │ └── Searching in Arrays.c.txt ├── Module 4-Advanced C++ Programming ├── T06-Exception Handling │ ├── Exception Handling.cpp.txt │ └── Built-in and User-defined Exceptions.cpp.txt ├── T03-Input & Output in C++-I │ ├── Input Output in C++.cpp.txt │ └── The Header File - iomanip.cpp.txt ├── T04-TInput & Output in C++-II │ └── The Header File - fstream.cpp.txt ├── T02-Abstract Classes │ └── Abstract Classes.cpp.txt ├── T07-Namespace │ └── Namespace in C++.cpp.txt └── T01-Dealing with inheritance │ ├── Types of Inheritance.cpp.txt │ └── Inheritance.cpp.txt └── Module 3-Introduction To OOP and C++ ├── T06-Construtor and Function Overloading └── Constructor and Function Overloading.cpp.txt ├── T03-Classes and Objects ├── Classes and Objects.cpp.txt └── Member Functions in Classes.cpp.txt └── T04-Constructors & Destructors ├── Types of Constructors.cpp.txt └── Constructors and Destructors.cpp.txt /README.md: -------------------------------------------------------------------------------- 1 | # Programming-with-C-and-CPP -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T02-Setting up environment/Compilers and Interpreters.c.txt: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("Hello,World!"); 5 | return 0; 6 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T09-Strings/Strings in C Programming.c.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Internshala-Online-Trainings/Programming-with-C-and-CPP/HEAD/Module 2-Advanced C Programming/T09-Strings/Strings in C Programming.c.txt -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T13-User defined data types-II/Enumeration.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | 3 | #include 4 | 5 | enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun}; 6 | 7 | int main() 8 | { 9 | enum week day; 10 | day = Wed; 11 | printf("%d",day); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T11-Repetitive Constructs in C/Loops - The for Loop.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int a; 8 | for ( a = 1; a <= 10; a++ ) 9 | { 10 | printf( "%d\n", a ); 11 | } 12 | getchar(); 13 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T13- Repetitive Constructs in C-III/Demonstartion of Number Techniques.c.txt: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,j; 5 | for(i = 1; i <= 5; i++) // for number of rows 6 | { 7 | for(j = 1; j <= i; j++) // for columns 8 | { 9 | printf("%d", j); 10 | } 11 | printf("\n"); 12 | } 13 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T03-Single Dimensional Arrays I/One-Dimensional Arrays.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | 4 | #include 5 | void main() 6 | { 7 | int marks[5] = { 4,5,9,7,8}; 8 | int i; 9 | for(i=0;i<5;i++) 10 | { 11 | printf("Element stored at a[%d] = %d \n",i,marks[i]); 12 | } 13 | getch(); 14 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T11-Pointers II/Function Pointers.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | 3 | #include 4 | int sum (int num1, int num2) 5 | { 6 | return num1+num2; 7 | } 8 | int main() 9 | { 10 | //declaring a function pointer 11 | int (*fp) (int, int); 12 | fp = sum; 13 | //Calling function using function pointer 14 | int result = fp(10, 5); 15 | printf("result: Call using function pointer: %d",result); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T06-Expressions/Expressions.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int a = 9, b =12, c = 12, i; 8 | i = (a + b)/2 - 2*c; 9 | printf("%d\n", i); 10 | 11 | } 12 | 13 | 14 | Program 2 15 | #include 16 | int main() 17 | { 18 | int a = 9, b =12, c = 12, i; 19 | i = a + b/2 - 2*c; 20 | printf("%d\n", i); 21 | 22 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T10-Pointers I/Functions and Pointers.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | 3 | #include 4 | int *bigger(int *x, int *y) 5 | { 6 | if(*x > *y) 7 | { 8 | return(x); 9 | } 10 | else 11 | { 12 | return(y); 13 | } 14 | } 15 | int main() 16 | { 17 | int num1, num2, *c; 18 | printf("Enter two integers : \n"); 19 | scanf(" %d", &num1 ); 20 | scanf(" %d", &num2 ); 21 | c = (int *) bigger(&num1, &num2); 22 | printf("The bigger value = %d", *c); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T15-Pre-compiler directives/Preprocessor Directives - I.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | #include 3 | #define MESSAGE "Internshala's Android Training Program" 4 | int main() 5 | { 6 | printf("\nMESSAGE : %s",MESSAGE); 7 | return 0; 8 | } 9 | 10 | 11 | Program 2 12 | #include 13 | #define WRONG 0 14 | #define RIGHT 1 15 | int main() 16 | { 17 | printf("\nWRONG IS : %f",WRONG); 18 | printf("\nRIGHT IS : %d",RIGHT); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T06-Exception Handling/Exception Handling.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | using namespace std; 5 | 6 | double division(int a, int b) { 7 | if( b == 0 ) { 8 | throw "Division by zero exception!"; 9 | } 10 | return (a/b); 11 | } 12 | int main () { 13 | int x = 10; 14 | int y = 0; 15 | double z = 0; 16 | 17 | try { 18 | z = division(x, y); 19 | cout << z << endl; 20 | } catch (const char* msg) { 21 | cerr << msg << endl; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T05-Single Dimensional Arrays III/Sorting Arrays.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | 4 | //Bubble Sort// 5 | # include 6 | 7 | int main() 8 | { 9 | int i,temp, j; 10 | 11 | int a[] = {13, 24, 5, 19, 2, 17, 4}; 12 | /* This is the main logic of bubble sort algorithm */ 13 | for(i=5;i>=0;i--) 14 | { 15 | for(j=0;j<=i;j++) 16 | { 17 | if(a[j]>a[j+1]) 18 | { 19 | temp=a[j]; 20 | a[j]=a[j+1]; 21 | a[j+1]=temp; 22 | } 23 | } 24 | } 25 | 26 | printf("Sorted elements: "); 27 | for(i=0;i<7;i++) 28 | printf(" %d",a[i]); 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T05-Operators-II/Operators- Part-II.c.txt: -------------------------------------------------------------------------------- 1 | Below is the codes used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int a = 12,b =25,AND_opr,OR_opr,XOR_opr,NOT_opr ; 8 | AND_opr = (a&b); 9 | OR_opr = (a|b); 10 | NOT_opr = (~b); 11 | XOR_opr = (a^b); 12 | printf("AND_opr value = %d\n",AND_opr ); 13 | printf("OR_opr value = %d\n",OR_opr ); 14 | printf("NOT_opr value = %d\n",NOT_opr ); 15 | printf("XOR_opr value = %d\n",XOR_opr ); 16 | printf("left_shift value = %d\n", a << 1); 17 | printf("right_shift value = %d\n", a >> 1); 18 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T11-Pointers II/Dynamic Memory Allocation.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | int main() 8 | { 9 | char *name; 10 | /* memory is allocated dynamically */ 11 | name = calloc( 20, sizeof(char) ); 12 | if( name== NULL ) 13 | { 14 | printf("Couldn't able to allocate requested memory\n"); 15 | } 16 | else 17 | { 18 | strcpy( name,"internshala.com"); 19 | } 20 | printf("Dynamically allocated memory content : " \ 21 | "%s\n", name ); 22 | free(name); 23 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T03-Fundamental Concepts in C/Variables.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main( ) 6 | { 7 | auto int a = 1; 8 | { 9 | auto int a = 2; 10 | { 11 | auto int a = 3; 12 | printf ( "\n%d ", a); 13 | } 14 | printf ( "%d ", a); 15 | } 16 | printf( "%d\n", a); 17 | } 18 | 19 | 20 | Program 2 21 | #include 22 | int fun() 23 | { 24 | int count = 0; 25 | count++; 26 | return count; 27 | } 28 | 29 | int main() 30 | { 31 | printf("%d ", fun()); 32 | printf("%d ", fun()); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T10-Pointers I/Pointers.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | 5 | int main () { 6 | 7 | int i = 20; /* actual variable declaration */ 8 | int *iptr; /* pointer variable declaration */ 9 | iptr = &i; /* store address of i in pointer variable*/ 10 | int j = *iptr; /* store variable stored in location pointed by iptr* in j / 11 | 12 | /* address stored in pointer variable */ 13 | printf("Address stored in ip variable: %x\n", iptr ); 14 | 15 | /* access the value using the pointer */ 16 | printf("Value of *ip variable: %d\n", j ); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T02-User defined functions/Functions.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | // function prototype, also called function declaration 5 | float cube ( float x ); 6 | // main function, program starts from here 7 | int main( ) 8 | { 9 | float m, n ; 10 | printf ( "\nEnter some number for finding cube \n"); 11 | scanf ( "%f", &m ) ; 12 | // function call 13 | n = cube ( m ) ; 14 | printf ( "\ncube of the given number %f is %f",m,n ); 15 | } 16 | 17 | float cube ( float x ) // function definition 18 | { 19 | float p ; 20 | p = x * x * x ; 21 | return ( p ); 22 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T03-Fundamental Concepts in C/Type Conversion.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int num1 = 50, num2 = 3; 8 | float result; 9 | result = num1 / num2; 10 | printf("Result with type casting: %f", result); 11 | return 0; 12 | } 13 | 14 | 15 | Program 2 16 | #include 17 | int main() 18 | { 19 | float num1 = 1.7; 20 | int num2 = 9; 21 | float result = num1 * num2; 22 | printf("result = %f", result); 23 | return 0; 24 | } 25 | 26 | 27 | Program 3 28 | #include 29 | int main() 30 | { 31 | int num1 = 50, num2 = 3; 32 | float result; 33 | result = num1 / num2; 34 | printf("Result with type casting: %f", result); 35 | return 0; 36 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T09-Decision Making in C-If else statement/Solution to Exercise: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int x, y, ch; 5 | printf("Enter value for x : "); 6 | scanf(" %d", &x); 7 | printf("Enter value for y : "); 8 | scanf(" %d", &y); 9 | printf ("+++ Calculator +++ \n"); 10 | printf ("1) Add \n"); 11 | printf ("2) Subtract \n"); 12 | printf ("3) Multiply \n"); 13 | printf ("4) Divide \n" ); 14 | printf ("Enter your choice 1-4 : "); 15 | scanf(" %d", &ch); 16 | switch(ch) 17 | { 18 | case 1: 19 | printf("\nResult is : %d \n", x + y); 20 | break; 21 | case 2: 22 | printf("\nResult is : %d \n", x - y ); 23 | break; 24 | case 3: 25 | printf("\nResult is : %d \n", x * y ); 26 | break; 27 | case 4: 28 | printf("\nResult is : %d \n", x / y ); 29 | break; 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T12- Repetitive Constructs in C-II/Demonstartion of Number Techniques.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | Program 1 4 | #include 5 | #include 6 | 7 | int main() 8 | { 9 | // Declare variables 10 | int d, r=0, n, t; 11 | 12 | // Accept a number 13 | printf("Enter a number : "); 14 | scanf ("%d", &n); 15 | 16 | t = n; 17 | 18 | // Calculate the reverse 19 | while (n > 0) 20 | { 21 | d = n % 10; // Split the last digit 22 | r = r*10+d; // add d into r * 10 - r is storing the reverse 23 | n = n / 10; // remove the last digit from the number 24 | } 25 | // Print the reverse 26 | printf("Reverse : %d", r); 27 | if (t == r) 28 | printf("The number is palindrome\n"); 29 | else 30 | printf("The number is not palindrome\n"); 31 | return 0; 32 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T12- Repetitive Constructs in C-II/Demonstration of Series Generation.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | Program 1 4 | /** 5 | * C program to print Fibonacci series Fibonacci series: 6 | 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 u. n 7 | */ 8 | #include 9 | int main() 10 | { 11 | int a, b, c,n, i, terms; 12 | 13 | /* Input number from user */ 14 | printf("Enter number of terms: "); 15 | scanf("%d", &n); 16 | 17 | /* Fibonacci initialization */ 18 | a = 0; // Current term 19 | b = 1; //n-1th term 20 | c = 0; //n-2th term 21 | 22 | printf("Fibonacci terms: \n"); 23 | 24 | /* Iterate through n terms */ 25 | for(i=1; i<=n; i++) 26 | { 27 | printf("%d, ", c); 28 | a = b; // Copy n-1 to n-2 29 | b = c; // Copy current to n-1 30 | c = a + b; // New term 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Module 3-Introduction To OOP and C++/T06-Construtor and Function Overloading/Constructor and Function Overloading.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | Program 1 4 | #include 5 | using namespace std; 6 | /* Function arguments are of different data type */ 7 | long add(long, long); 8 | float add(float, float); 9 | int main() 10 | { 11 | long a,b,x; 12 | float c,d,y; 13 | cout <<"Enter two integers\n"; 14 | cin >> a >> b; 15 | x = add(a, b); 16 | cout <<"Sum of integeres:"< 6 | 7 | using namespace std; 8 | 9 | int main() { 10 | char str[] = " Internshala "; 11 | 12 | cout << str <<"- A no.1 internship & training website for students " << endl; 13 | } 14 | 15 | Program 2 16 | #include 17 | using namespace std; 18 | 19 | int main() 20 | { 21 | int rollnum; 22 | 23 | cout << "Enter your roll number:"; 24 | cin >> rollnum; 25 | cout << "\nYour roll number is: "< 32 | 33 | using namespace std; 34 | 35 | int main() { 36 | char str[] = "Unable to read"; 37 | 38 | cerr << "An error occured : " << str << endl; 39 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T08- IO Functions/IO_Functions.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | char ch = 'T'; 8 | char str[20] = "internshala.com"; 9 | float flt = 10.154; 10 | int no = 100; 11 | double dbl = 21.123456; 12 | printf("Character is %c \n", ch); 13 | printf("String is %s \n" , str); 14 | printf("Float value is %f \n", flt); 15 | printf("Integer value is %d\n" , no); 16 | printf("Double value is %lf \n", dbl); 17 | return 0; 18 | } 19 | 20 | 21 | Program 2 22 | #include 23 | int main() 24 | { 25 | char ch; 26 | char str[100]; 27 | printf("Enter any character \n"); 28 | scanf("%c", &ch); 29 | printf("Entered character is %c \n", ch); 30 | printf("Enter any string ( upto 100 character ) \n"); 31 | scanf("%s", &str); 32 | printf("Entered string is %s \n", str); 33 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T12-User defined data types-I/Structures.c.txt: -------------------------------------------------------------------------------- 1 | Program 1 2 | 3 | #include 4 | #include 5 | struct student 6 | { 7 | int rollnum; 8 | char name[20]; 9 | float percentage; 10 | }student1, student2; 11 | 12 | int main() 13 | { 14 | student1.rollnum=1; 15 | strcpy(student1.name, "Deepak"); 16 | student1.percentage = 86.5; 17 | 18 | printf(" Roll number is: %d \n", student1.rollnum); 19 | printf(" Name is: %s \n", student1.name); 20 | printf(" Percentage is: %f \n", student1.percentage); 21 | 22 | student2.rollnum=2; 23 | strcpy(student2.name, "Ishan"); 24 | student2.percentage = 96.5; 25 | 26 | printf(" Roll number is: %d \n", student2.rollnum); 27 | printf(" Name is: %s \n", student2.name); 28 | printf(" Percentage is: %f \n", student2.percentage); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /Module 3-Introduction To OOP and C++/T03-Classes and Objects/Classes and Objects.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | using namespace std; 5 | class Rectangle 6 | { 7 | public: 8 | double length; // Length of a rectangle 9 | double breadth; // Breadth of a rectangle 10 | }; 11 | int main() 12 | { 13 | Rectangle Rectangle1; // Declare Rectangle1 of type Rectangle 14 | Rectangle Rectangle2; // Declare Rectangle2 of type Rectangle 15 | double area = 0.0; // Store the area of a rectangle here 16 | // rectangle 1 specification 17 | Rectangle1.length = 6.0; 18 | Rectangle1.breadth = 7.0; 19 | // rectangle 2 specification 20 | Rectangle2.length = 5.0; 21 | Rectangle2.breadth = 6.0; 22 | // area of rectangle 1 23 | area = Rectangle1.length * Rectangle1.breadth; 24 | cout << "Area of Rectangle1 : " << area < 4 | #include 5 | 6 | struct student 7 | { 8 | int rollnum; 9 | char name[20]; 10 | float percentage; 11 | }student1, student2; 12 | 13 | int main() 14 | { 15 | 16 | 17 | student1.rollnum=1; 18 | strcpy(student1.name, "Deepak"); 19 | student1.percentage = 86.5; 20 | 21 | printf(" Roll number is: %d \n", student1.rollnum); 22 | printf(" Name is: %s \n", student1.name); 23 | printf(" Percentage is: %f \n", student1.percentage); 24 | 25 | student2.rollnum=2; 26 | strcpy(student2.name, "Ishan"); 27 | student2.percentage = 96.5; 28 | 29 | printf(" Roll number is: %d \n", student2.rollnum); 30 | printf(" Name is: %s \n", student2.name); 31 | printf(" Percentage is: %f \n", student2.percentage); 32 | return 0; 33 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T09-Decision Making in C-If else statement/Selection Statements- The Switch Statement.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code used in the video. 2 | 3 | Program 1 4 | /* C program to simulate a simple calculator to perform arithmetic operations like addition, subtraction, multiplication and division */ 5 | #include 6 | void main() 7 | { 8 | char operator; 9 | float num1, num2, result; 10 | 11 | printf("Enter two numbers \n"); 12 | scanf("%f %f", &num1, &num2); 13 | fflush(stdin); 14 | printf("Enter the operator [+,-,*,/] \n"); 15 | scanf("%s", &operator); 16 | switch(operator) 17 | { 18 | case '+': result = num1 + num2; 19 | break; 20 | case '-': result = num1 - num2; 21 | break; 22 | case '*': result = num1 * num2; 23 | break; 24 | case '/': result = num1 / num2; 25 | break; 26 | default : printf("Operator is invalid"); 27 | break; 28 | } 29 | printf("\n %5.2f %c %5.2f = %5.2f\n", num1, operator, num2, result); 30 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T09-Decision Making in C-If else statement/Introduction.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int num1, num2; 8 | 9 | /* Input two numbers from user */ 10 | printf("Enter two numbers: "); 11 | scanf("%d%d", &num1, &num2); 12 | 13 | /* If num1 is greater */ 14 | if(num1 > num2) 15 | { 16 | printf("%d is greater", num1); 17 | } 18 | 19 | /* If num2 is greater */ 20 | if(num2 > num1) 21 | { 22 | printf("%d is greater", num2); 23 | } 24 | 25 | /* If num2 is equal to num1 */ 26 | if(num1 == num2) 27 | { 28 | printf("Given numbers are equal"); 29 | } 30 | 31 | return 0; 32 | } 33 | 34 | 35 | Program 2 36 | #include 37 | void main() 38 | { 39 | int num; 40 | printf("Enter an integer \n"); 41 | scanf("%d", &num); 42 | if (num >= 0) 43 | printf("%d is greater than or equal to zero \n", num); 44 | else 45 | printf("%d is less than zero \n", num); 46 | return 0; 47 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T07-Math Functions/Math Functions.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code used in the video. 2 | 3 | Program 1 4 | #include 5 | #include 6 | 7 | int main() 8 | { 9 | //Program Example demonstrating use of various math functions 10 | float x; 11 | //Accept some float value for x 12 | printf("Enter the value of x : "); 13 | scanf("%f", &x); 14 | // Now apply different math functions 15 | printf("Round value of x : "); 16 | printf("%f \n", round(x)); 17 | printf("Ceiling value of x : "); 18 | printf("%f \n", ceil(x)); 19 | printf("Floor value of x : "); 20 | printf("%f \n", floor(x)); 21 | printf("Raising power of x to 3 : "); 22 | printf("%f \n", pow(x, 3)); 23 | printf("Square root of x : "); 24 | printf("%f \n", sqrt(x)); 25 | printf("Cube root of x : "); 26 | printf("%f \n", pow(x, 1/3.0)); 27 | printf("Natural Log value of x : "); 28 | printf("%f \n", log(x)); 29 | printf("Exp value of x : "); 30 | printf("%f \n", exp(x)); 31 | printf("Removing fractional part from x : "); 32 | printf("%d \n", (int) trunc(x)); 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T02-User defined functions/Methods of Calling a Function.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is mentioned in the video. 2 | 3 | #include 4 | void swap(int a, int b) 5 | { 6 | int c; 7 | c = a; 8 | a = b; 9 | b = c; 10 | printf("Swapped values are x=%d and y=%d\n",a,b); 11 | } 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | int x=7,y=4; 16 | printf("Original values are x=%d and y=%d\n",x,y); 17 | swap(x,y); 18 | printf("The values after swap are x=%d and y=%d",x,y); 19 | } 20 | 21 | 22 | 23 | 24 | Program 1 25 | Check for Prime Number using function 26 | 27 | 28 | #include 29 | #include 30 | int isPrime(int n) 31 | { 32 | 33 | int i; 34 | for(i = 2; i <= n-1; i++) 35 | { 36 | if (n % i == 0) 37 | return 0; 38 | 39 | } 40 | 41 | return 1; 42 | } 43 | 44 | int main() 45 | { 46 | int n; 47 | // Ask for a number 48 | printf ("Enter a number : "); 49 | scanf("%d", &n); 50 | if (isPrime(n)) 51 | printf("%d is Prime number", n) 52 | else 53 | printf("%d is not Prime number", n); 54 | return 0; 55 | } -------------------------------------------------------------------------------- /Module 3-Introduction To OOP and C++/T04-Constructors & Destructors/Types of Constructors.cpp.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | using namespace std; 6 | class Square 7 | { 8 | public: 9 | int side; 10 | Square(int x) 11 | { 12 | side=x; 13 | } 14 | Square (Square &s) // Copy constructor s is an object of type Square 15 | { 16 | side = s.side; // 17 | } 18 | }; 19 | int main() 20 | { 21 | Square c1(10); 22 | Square c2(c1); // Copy constructor used .... Here c1 is sent as a parameter 23 | cout << c2.side << endl; 24 | } 25 | 26 | Program 2 27 | #include 28 | using namespace std; 29 | 30 | class square 31 | { 32 | public: 33 | int side; 34 | square() 35 | { 36 | side=20; 37 | } 38 | }; 39 | 40 | int main() 41 | { 42 | square c; 43 | cout << c.side; 44 | } 45 | 46 | Program 3 47 | #include 48 | using namespace std; 49 | class Square 50 | { 51 | public: 52 | int side; 53 | Square(int x) 54 | { 55 | side=x; 56 | } 57 | }; 58 | int main() 59 | { 60 | Square c1(10); 61 | Square c2(20); 62 | Square c3(30); 63 | cout << c1.side< 5 | int main() 6 | { 7 | int a[2][3] = {{3,6,8},{9,3,4}}; 8 | int i, j; 9 | printf("Two Dimensional array elements:\n"); 10 | for(i=0; i<2; i++) // loop to control rows 11 | { 12 | for(j=0;j<3;j++) // loop to control columns 13 | { 14 | printf("%d ", a[i][j]); 15 | } 16 | printf("\n"); 17 | } 18 | return 0; 19 | } 20 | 21 | Program 2 22 | #include 23 | int main(){ 24 | /* 2D array declaration*/ 25 | 26 | int a[2][3] = {{3,6,8},{9,3,4}}; 27 | int i, j, sum = 0; 28 | printf("Two Dimensional array elements:\n"); 29 | for(i=0; i<2; i++) // loop to control rows 30 | { 31 | for(j=0;j<3;j++) // loop to control columns 32 | { 33 | printf("%d ", a[i][j]); 34 | } 35 | printf("\n"); 36 | } 37 | 38 | for (j= 0; j < 3; ++j) 39 | { 40 | for (i = 0; i < 2; ++i) 41 | { 42 | sum = sum + a[i][j]; 43 | } 44 | printf("Sum of the %d column is = %d\n", j, sum); 45 | sum = 0; 46 | } 47 | 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T05-Single Dimensional Arrays III/Concatenating and Merging One-Dimensional Arrays.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | 4 | // Merge arr1[0..n1-1] and b[0..n2-1] into 5 | // arr3[0..n1+n2-1] 6 | // Program code 7 | void mergeArrays(int a[], int b[], int c[]); 8 | int main() 9 | { 10 | int i; 11 | int a[] = {3, 6, 8, 9, 10, 13, 14}; 12 | int b[] = {4, 6, 7, 10, 16}; 13 | 14 | int c[12]; 15 | mergeArrays(a, b, c); 16 | printf("Array after merging\n"); 17 | for ( i=0; i < 12; i++) 18 | printf("%d ", c[i]); 19 | 20 | return 0; 21 | } 22 | 23 | void mergeArrays(int a[], int b[], int c[]) 24 | { 25 | int i = 0, j = 0, k = 0; 26 | // Traverse both array 27 | while (i<7 && j <5) 28 | { 29 | // Check if current element of first 30 | // array is smaller than current element 31 | // of second array. If yes, store first 32 | // array element and increment first array 33 | // index. Otherwise do same with second array 34 | if (a[i] < b[j]) 35 | c[k++] = a[i++]; 36 | else 37 | c[k++] = b[j++]; 38 | } 39 | 40 | // Store remaining elements of first array 41 | while (i < 7) 42 | c[k++] = a[i++]; 43 | 44 | // Store remaining elements of second array 45 | while (j < 5) 46 | c[k++] = b[j++]; 47 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T04-TInput & Output in C++-II/The Header File - fstream.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int main () { 8 | char data[100]; 9 | 10 | // open a file in write mode. 11 | ofstream outfile; 12 | outfile.open("internshala.dat"); 13 | // write inputted data into the file. 14 | 15 | cout << "Writing to the file" << endl; 16 | cout << "Enter your name: "; 17 | cin.getline(data, 100); 18 | 19 | outfile << data << endl; 20 | 21 | cout << "Enter your roll number: "; 22 | cin >> data; 23 | cin.ignore(); 24 | 25 | // again write inputted data into the file. 26 | outfile << data << endl; 27 | 28 | // close the opened file. 29 | outfile.close(); 30 | 31 | // open a file in read mode. 32 | ifstream infile; 33 | infile.open("internshala.dat"); 34 | 35 | cout << "Reading from the file" << endl; 36 | infile >> data; 37 | 38 | // write the data at the screen. 39 | cout << data << endl; 40 | 41 | // again read the data from the file and display it. 42 | infile >> data; 43 | cout << data << endl; 44 | 45 | // close the opened file. 46 | infile.close(); 47 | 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T02-Abstract Classes/Abstract Classes.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | using namespace std; 5 | // Base class 6 | class Shape { 7 | public: 8 | // pure virtual function providing interface framework. 9 | virtual int getArea() = 0; 10 | void setWidth(int w) { 11 | width = w; 12 | } 13 | 14 | void setHeight(int h) { 15 | height = h; 16 | } 17 | void setSidet(int s) { 18 | side = s; 19 | } 20 | protected: 21 | int width; 22 | int height; 23 | int side; 24 | }; 25 | // Derived classes 26 | class Rectangle: public Shape { 27 | public: 28 | int getArea() { 29 | return (width * height); 30 | } 31 | }; 32 | class Square: public Shape { 33 | public: 34 | int getArea() { 35 | return (side* side); 36 | } 37 | }; 38 | int main(void) { 39 | Rectangle Rect; 40 | Square Sq; 41 | Rect.setWidth(3); 42 | Rect.setHeight(6); 43 | // Print the area of the object. 44 | cout << "Total Rectangle area: " << Rect.getArea() << endl; 45 | Sq.setSidet(5); 46 | // Print the area of the object. 47 | cout << "Total Square area: " << Sq.getArea() << endl; 48 | return 0; 49 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T09-Decision Making in C-If else statement/Selection Statements- The if-else-if-else Ladder and Nested if Statement.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main(void) 6 | { 7 | int a, b, c; 8 | printf("Enter a,b,c: "); 9 | scanf("%d %d %d", &a, &b, &c); 10 | if (a > b && a > c) 11 | { 12 | printf("a is greatest "); 13 | } 14 | else if (b > a && b > c) 15 | { 16 | printf("b is greatest"); 17 | } 18 | else if (c > a && c > b) 19 | { 20 | printf("c is greatest"); 21 | } 22 | else 23 | { 24 | printf("All or any two numbers are equal"); 25 | } 26 | } 27 | 28 | 29 | Program 2 30 | #include 31 | int main(void) 32 | { 33 | int yourmarks; 34 | printf("Enter yourmarks"); 35 | scanf("%d",&yourmarks); 36 | int passingMarks=40; 37 | if(yourmarks >= passingMarks) 38 | { 39 | if(yourmarks>90) 40 | printf("You have passed the exam and your grade is A"); 41 | else if (yourmarks>75) 42 | printf("You have passed the exam and your grade is B"); 43 | else 44 | printf("You have passed the exam and your grade is C"); 45 | } 46 | else 47 | { 48 | printf("You have failed the exam"); 49 | } 50 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T06-Exception Handling/Built-in and User-defined Exceptions.cpp.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | 4 | Program 1 5 | #include 6 | using namespace std; 7 | 8 | // define a new exception inheriting from the base class 9 | class new_exception : public exception { 10 | public : 11 | const char *what() const throw() { 12 | return "New exception thrown"; 13 | } 14 | }; 15 | 16 | int main() { 17 | try { 18 | throw new_exception(); 19 | } catch (new_exception &e) { 20 | cout << "Caught : " << e.what() << endl; 21 | } catch (...) { // default exception 22 | cout << "Other exception thrown" << endl; 23 | } 24 | return 0; 25 | } 26 | 27 | Program 2 28 | #include 29 | using namespace std; 30 | 31 | void func(int size) { 32 | int *arr = new int[size]; 33 | int i; 34 | for (i = 0; i < size; i++) { 35 | arr[i] = i; 36 | } 37 | } 38 | 39 | int main() { 40 | int size = 2000000000000000000; // abnormally large size 41 | try { 42 | cout << "Calling func() " << endl; 43 | func(size); 44 | } catch (bad_exception &e) { 45 | cout << "Exception found : " << e.what() << endl; 46 | } catch (bad_alloc &e) { 47 | cout << "Exception Caught : " << e.what() << endl; 48 | } 49 | return 0; 50 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T07-Namespace/Namespace in C++.cpp.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | using namespace std; 6 | namespace ns1 7 | { 8 | int value = 10; 9 | } 10 | namespace ns2 11 | { 12 | 13 | double value = 0.5; 14 | } 15 | 16 | int main() 17 | { 18 | // Access value variable within ns1 19 | cout << ns1::value << '\n'; 20 | 21 | // Access value variable within ns2 22 | cout << ns2::value << '\n'; 23 | return 0; 24 | } 25 | 26 | Program 2 27 | // Creating namespaces 28 | #include 29 | using namespace std; 30 | namespace ns1 31 | { 32 | int value() { return 10; } 33 | } 34 | namespace ns2 35 | { 36 | double value() { return 0.5; } 37 | } 38 | using namespace ns1; 39 | int main() 40 | { 41 | cout < 50 | using namespace std; 51 | namespace ns1 52 | { 53 | int value() { return 10; } 54 | } 55 | namespace ns2 56 | { 57 | double value() { return 0.5; } 58 | } 59 | 60 | int main() 61 | { 62 | // Access value function within ns1 63 | cout << ns1::value() << '\n'; 64 | 65 | // Access value function within ns2 66 | cout << ns2::value() << '\n'; 67 | 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T11-Repetitive Constructs in C/Loops - The while and do-while Loops.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int i=7; 8 | while(i<=500) 9 | { 10 | printf("%d",i); 11 | printf("\n"); 12 | i +=7; 13 | } 14 | return 0; 15 | } 16 | 17 | 18 | Program 2 19 | #include 20 | #include 21 | #include 22 | int main(void) 23 | { 24 | char ch1; 25 | int ch; 26 | float l, b, peri, area, diag; 27 | do 28 | { 29 | 30 | printf("Rectangle Menu"); 31 | printf("\n 1. Area"); 32 | printf("\n 2. Perimeter"); 33 | printf("\n 3. Exit\n"); 34 | printf("\nEnter your choice: "); 35 | scanf("%d", &ch); 36 | if(ch == 1 || ch == 2) 37 | { 38 | printf("Enter length & breadth: "); 39 | scanf("%f", &l); 40 | scanf("%f", &b); 41 | } 42 | switch(ch) 43 | { 44 | case 1 : area = l * b ; 45 | printf("Area = %f",area); 46 | break ; 47 | case 2 : peri = 2 * (l + b); 48 | printf("Perimeter = %f",peri); 49 | break; 50 | 51 | case 3 : printf("Breaking..Press a key.."); 52 | getch(); 53 | exit(1); 54 | default : printf("Wrong choice !!!!"); 55 | printf("\nEnter a valid one"); 56 | break; 57 | } //end of switch 58 | printf("\nWant to enter more (y/n) ? "); 59 | scanf("%s", &ch1); 60 | 61 | }while(ch1 == 'y' || ch1 == 'Y'); 62 | getch(); 63 | } -------------------------------------------------------------------------------- /Module 3-Introduction To OOP and C++/T03-Classes and Objects/Member Functions in Classes.cpp.txt: -------------------------------------------------------------------------------- 1 | Below is the code which is used in the video. 2 | 3 | #include 4 | using namespace std; 5 | class Rectangle 6 | { 7 | public: 8 | double length; // Length of a rectangle 9 | double breadth; // Breadth of a rectangle 10 | // Member functions declaration 11 | double getArea(void); 12 | void setLength( double len ); 13 | void setBreadth( double bre ); 14 | }; 15 | // Member functions definitions 16 | double Rectangle::getArea(void) 17 | { 18 | return length * breadth; 19 | } 20 | 21 | void Rectangle::setLength( double len ) 22 | { 23 | length = len; 24 | } 25 | void Rectangle::setBreadth( double bre ) 26 | { 27 | breadth = bre; 28 | } 29 | // Main function for the program 30 | int main() 31 | { 32 | Rectangle Rectangle1; // Declare Rectangle1 of type Rectangle 33 | Rectangle Rectangle2; // Declare Rectangle2 of type Rectangle 34 | double area = 0.0; // Store the area of a rectangle here 35 | // rectangle 1 specification 36 | Rectangle1.setLength(12.0); 37 | Rectangle1.setBreadth(5.0); 38 | // rectangle 2 specification 39 | Rectangle2.setLength(10.0); 40 | Rectangle2.setBreadth(12.0); 41 | // area of rectangle 1 42 | area = Rectangle1.getArea(); 43 | cout << "Area of Rectangle1 : " << area < 5 | using namespace std; 6 | class square 7 | { 8 | public: 9 | int side; 10 | square() 11 | { 12 | side=20; 13 | } 14 | }; 15 | 16 | int main() 17 | { 18 | square c; 19 | cout << c.side; 20 | } 21 | 22 | 23 | Program 2 24 | #include 25 | using namespace std; 26 | class square 27 | { 28 | public: 29 | int side; 30 | square(); // Constructor declaration 31 | }; 32 | square::square() // Constructor definition 33 | { 34 | side=20; 35 | } 36 | int main() 37 | { 38 | square c; 39 | cout << c.side; 40 | } 41 | 42 | 43 | Program 3 44 | #include 45 | using namespace std; 46 | class square 47 | { 48 | private: 49 | int side; 50 | square(); // Constructor declaration 51 | }; 52 | square::square() // Constructor definition 53 | { 54 | side=20; 55 | } 56 | int main() 57 | { 58 | square c; 59 | cout << c.side; 60 | } 61 | 62 | 63 | Program 4 64 | #include 65 | using namespace std; 66 | class square 67 | { 68 | public: 69 | int side; 70 | square(); // Constructor declaration 71 | ~square()// Destructor declaration 72 | { 73 | cout << "object is deleted"; 74 | } 75 | }; 76 | square::square() // Constructor definition 77 | { 78 | side=20; 79 | } 80 | int main() 81 | { 82 | square c; 83 | cout << c.side< 6 | using namespace std; 7 | // base class 8 | class Vehicle 9 | { 10 | public: 11 | Vehicle() 12 | { 13 | cout << "This is a Vehicle" << endl; 14 | } 15 | }; 16 | 17 | // first sub class 18 | class Scooter: public Vehicle 19 | { 20 | 21 | }; 22 | 23 | // second sub class 24 | class Bus: public Vehicle 25 | { 26 | 27 | }; 28 | 29 | // main function 30 | int main() 31 | { 32 | // 33 | Scooter obj1; 34 | Bus obj2; 35 | return 0; 36 | } 37 | 38 | Program 2 39 | #include 40 | using namespace std; 41 | 42 | // base class 43 | class Vehicle 44 | { 45 | public: 46 | Vehicle() 47 | { 48 | cout << "This is a Vehicle" << endl; 49 | } 50 | }; 51 | 52 | //base class 53 | class Fare 54 | { 55 | public: 56 | Fare() 57 | { 58 | cout<<"Fare of Vehicle\n"; 59 | } 60 | }; 61 | 62 | // first sub class 63 | class Scooter: public Vehicle 64 | { 65 | 66 | }; 67 | 68 | // second sub class 69 | class Bus: public Vehicle, public Fare 70 | { 71 | 72 | }; 73 | 74 | // main function 75 | int main() 76 | { 77 | Scooter obj1; 78 | Bus obj2; 79 | return 0; 80 | } 81 | 82 | Next live chat: Today (7:00 - 8:00 PM) 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T12- Repetitive Constructs in C-II/Demonstration of Elementary Techniques.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | /* Find the sum of all numbers between 1 and 10 */ 5 | #include 6 | #include 7 | int main() 8 | { 9 | // Declaring variable 10 | int i, s = 0; 11 | // Loop Section 12 | for (i = 1; i <= 10; i++) 13 | { 14 | s = s + i; 15 | } 16 | // Printing the sum of 10 numbers 17 | printf("Sum = %d\n", s); 18 | return 0; 19 | } 20 | 21 | 22 | Program 2 23 | /* Print the minimum and maximum of 10 numbers accepted from user */ 24 | #include 25 | #include 26 | int main() 27 | { 28 | // Declare variables 29 | int n, i, min, max; 30 | // Accept the first number 31 | printf("Enter a number : "); 32 | scanf("%d", &n); 33 | // Initialize min and max 34 | min = max = n; 35 | 36 | for(i=2; i <= 10; i++) 37 | { 38 | printf("Enter a number : "); 39 | scanf("%d", &n); 40 | if (min > n) 41 | min = n; 42 | if (max < n) 43 | max = n; 44 | } 45 | printf ("Minimum = %d Maximum = %d", min, max); 46 | return 0; 47 | } 48 | 49 | 50 | Program 3 51 | /*Print the factors for a number*/ 52 | #include 53 | #include 54 | int main() 55 | { 56 | // Declare variables 57 | int n, i; 58 | 59 | // Accept a number 60 | printf("Enter a number : "); 61 | scanf("%d", &n); 62 | for(i=1; i <= n; i++) 63 | { 64 | if (n % i == 0) 65 | printf("%d ", i); 66 | } 67 | return 0; 68 | } -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T08-Dealing with characters/Dealing with Characters.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | #include 4 | int main () { 5 | int var1 = 'a'; 6 | int var2 = '4'; 7 | int var3 = '\t'; 8 | 9 | if( isalnum(var1) ) { 10 | printf("var1 = |%c| is alphanumeric\n", var1 ); 11 | } else { 12 | printf("var1 = |%c| is not alphanumeric\n", var1 ); 13 | } 14 | 15 | if( isalnum(var2) ) { 16 | printf("var2 = |%c| is alphanumeric\n", var2 ); 17 | } else { 18 | printf("var2 = |%c| is not alphanumeric\n", var2 ); 19 | } 20 | 21 | if( isalnum(var3) ) { 22 | printf("var3 = |%c| is alphanumeric\n", var3 ); 23 | } else { 24 | printf("var3 = |%c| is not alphanumeric\n", var3 ); 25 | } 26 | return(0); 27 | } 28 | 29 | 30 | Program 2 31 | #include 32 | #include 33 | 34 | int main () { 35 | int var1 = 'a'; 36 | int var2 = '4'; 37 | int var3 = '\t'; 38 | if( isalpha(var1) ) { 39 | printf("var1 = |%c| is an alphabet\n", var1 ); 40 | } else { 41 | printf("var1 = |%c| is not an alphabet\n", var1 ); 42 | } 43 | 44 | if( isalpha(var2) ) { 45 | printf("var2 = |%c| is an alphabet\n", var2 ); 46 | } else { 47 | printf("var2 = |%c| is not an alphabet\n", var2 ); 48 | } 49 | 50 | if( isalpha(var3) ) { 51 | printf("var3 = |%c| is an alphabet\n", var3 ); 52 | } else { 53 | printf("var3 = |%c| is not an alphabet\n", var3 ); 54 | } 55 | 56 | return(0); 57 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T01-Dealing with inheritance/Inheritance.cpp.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | // C++ program to demonstrate implementation of Inheritance 5 | #include 6 | using namespace std; 7 | //Base class 8 | class School 9 | { 10 | public: 11 | int id_p; 12 | }; 13 | // Sub class inheriting from Base Class(School) 14 | class Student : public School 15 | { 16 | public: 17 | int id_c; 18 | }; 19 | //main function 20 | int main() 21 | { 22 | Student obj1; 23 | // An object of class student has all data membersand member functions of class school 24 | obj1.id_c = 91; 25 | obj1.id_p = 6; 26 | cout << "Student id is " << obj1.id_c << endl; 27 | cout << "School id is " << obj1.id_p << endl; 28 | return 0; 29 | } 30 | 31 | Program 2 32 | #include 33 | using namespace std; 34 | class Parent 35 | { 36 | public : 37 | Parent() 38 | { 39 | cout << "Inside the Parent" << endl; 40 | } 41 | Parent(int x) 42 | { 43 | cout << "Inside the Parent with parameter value " << x << endl; 44 | } 45 | void method1() 46 | { 47 | Parent(10); 48 | cout << "Inside the Method1 of Parent" << endl; 49 | } 50 | }; 51 | class Child:public Parent 52 | { 53 | public : 54 | Child() 55 | { 56 | Parent(5); // Parent constructor call 57 | cout << "Inside the Child" << endl; 58 | } 59 | void method1() 60 | { 61 | Parent(7); // Parent constructor call 62 | cout << "Inside the Method1 of Child" << endl; 63 | } 64 | }; 65 | int main() 66 | { 67 | Child ch; 68 | ch.method1(); 69 | } 70 | -------------------------------------------------------------------------------- /Module 2-Advanced C Programming/T04-Single Dimensional Arrays II/Searching in Arrays.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int array[10], search, c, n; 8 | 9 | printf("Enter the number of elements in array\n"); 10 | scanf("%d",&n); 11 | 12 | printf("Enter %d integer(s)\n", n); 13 | for (c = 0; c < n; c++) 14 | scanf("%d", &array[c]); 15 | 16 | printf("Enter the number to search\n"); 17 | scanf("%d", &search); 18 | 19 | for (c = 0; c < n; c++) 20 | { 21 | if (array[c] == search) /* if required element found */ 22 | { 23 | printf("%d is present at location %d.\n", search, c+1); 24 | break; 25 | } 26 | } 27 | if (c == n) 28 | printf("%d is not present in array.\n", search); 29 | return 0; 30 | } 31 | 32 | 33 | Program 2 34 | #include 35 | int main() 36 | { 37 | int c, first, last, middle, n, search, array[100]; 38 | 39 | printf("Enter number of elements\n"); 40 | scanf("%d",&n); 41 | 42 | printf("Enter %d integers\n", n); 43 | 44 | for (c = 0; c < n; c++) 45 | scanf("%d",&array[c]); 46 | 47 | printf("Enter value to find\n"); 48 | scanf("%d", &search); 49 | 50 | first = 0; 51 | last = n - 1; 52 | middle = (first+last)/2; 53 | 54 | while (first <= last) 55 | { 56 | if (array[middle] < search) 57 | first = middle + 1; 58 | else if (array[middle] == search) 59 | { 60 | printf("%d found at location %d.\n", search, middle+1); 61 | break; 62 | } 63 | else 64 | last = middle - 1; 65 | middle = (first + last)/2; 66 | } 67 | if (first > last) 68 | printf("Not found! %d is not present in the list.\n", search); 69 | 70 | return 0; 71 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T04-Operators-I/Operators.c.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | #include 5 | int main() 6 | { 7 | int x=60, y=20, add,sub,mul,div,mod; 8 | add = x+y; 9 | sub = x-y; 10 | mul = x*y; 11 | div = x/y; 12 | mod = x%y; 13 | printf("Addition of x, y is : %d\n", add); 14 | printf("Subtraction of x, y is : %d\n", sub); 15 | printf("Multiplication of x, y is : %d\n", mul); 16 | printf("Division of x, y is : %d\n", div); 17 | printf("Modulus of x, y is : %d\n", mod); 18 | } 19 | 20 | 21 | Program 2 22 | #include 23 | int main() 24 | { 25 | int x=60; 26 | printf("x++ gives : %d\n", x++); // 60 is displayed then, x is //increased to 61. 27 | printf("++x gives : %d\n", ++x); // Initially, x = 61. It is increased //to 62 then, it is displayed. 28 | 29 | } 30 | 31 | 32 | Program 3 33 | #include 34 | int main() 35 | { 36 | int x=60,y=20; 37 | if (x == y) 38 | { 39 | printf("x and y are equal"); 40 | } 41 | else 42 | { 43 | printf("x and y are not equal"); 44 | } 45 | } 46 | 47 | 48 | Program 4 49 | #include 50 | int main() 51 | { 52 | int x=60,y=20; 53 | 54 | if (x>y && x !=0) 55 | { 56 | printf("&& Operator : Both conditions are true\n"); 57 | } 58 | if (y>x || x!=20) 59 | { 60 | printf("|| Operator : Only one condition is true\n"); 61 | } 62 | if (!(x>y && x !=0)) 63 | { 64 | printf("! Operator : Both conditions are true\n"); 65 | } 66 | else 67 | { 68 | printf("! Operator : Both conditions are true. " \ 69 | "But, status is inverted as false\n"); 70 | } 71 | } -------------------------------------------------------------------------------- /Module 4-Advanced C++ Programming/T03-Input & Output in C++-I/The Header File - iomanip.cpp.txt: -------------------------------------------------------------------------------- 1 | Below are the codes which are used in the video. 2 | 3 | Program 1 4 | // CPP Program to test std::setfill manipulator 5 | #include 6 | #include // std::setfill, std::setw 7 | int main() 8 | { 9 | 10 | std::string str = "inetrnshala"; 11 | 12 | // setfill is x and width is set as 15 13 | // And std::right is used set str to right of ('x') << std::setw(15); 14 | std::cout << std::setfill('x') << std::setw(15); 15 | std::cout << str << std::endl; 16 | return 0; 17 | } 18 | 19 | Program 2 20 | // CPP Program to illustrate 21 | // std::setbase manipulator 22 | #include 23 | #include // std::setbase 24 | int main() 25 | { 26 | // set base to hexadecimal 27 | std::cout << std::setbase(16); 28 | 29 | // displaying 25 in hexadecimal 30 | std::cout << 25 << std::endl; 31 | 32 | // set base to Octal 33 | std::cout << std::setbase(8); 34 | 35 | // displaying 25 in Octal 36 | std::cout << 25 << std::endl; 37 | return 0; 38 | } 39 | 40 | Program 3 41 | #include // std::cout, std::fixed 42 | #include // std::setprecision 43 | 44 | int main () { 45 | double f =3.14124; 46 | std::cout << std::setprecision(5) << f << '\n'; 47 | std::cout << std::setprecision(9) << f << '\n'; 48 | std::cout << std::fixed; 49 | std::cout << std::setprecision(5) << f << '\n'; 50 | std::cout << std::setprecision(9) << f << '\n'; 51 | return 0; 52 | } 53 | 54 | Program 4 55 | #include = 56 | #include / std::setprecision 57 | 58 | int main () { 59 | double f =3.14124; 60 | std::cout << std::setprecision(5) << f << '\n'; 61 | std::cout << std::setprecision(9) << f << '\n'; 62 | 63 | return 0; 64 | } -------------------------------------------------------------------------------- /Module 1-Fundamentals of C Programming/T10- Decision Making in C - Ternary Operators/Selection Statements - Program Demonstrations.c.txt: -------------------------------------------------------------------------------- 1 | Below is the code used in the video. 2 | 3 | Program 1 4 | /** 5 | * Question 6 | *In ICSE examinations on 3 subjects: English,Maths,and Science. 7 | * Students are given offers to select their streams 8 | * Based on the following conditions : 9 | * Condition Stream 10 | * >= 70 in individual subjects Pure Science 11 | * >= 70 on Science >= 60 in others Bio-Science 12 | * >= 60 on Maths and >= 50 in others Commerce 13 | * Rest if passed in all subjects Arts 14 | * Less 30 in any subject will lead to failing 15 | * An eligible person for any specific stream may 16 | * Choose a stream with lower marks requirement 17 | * Write a program to accept the marks for each subjects and print the stream offered 18 | */ 19 | 20 | #include 21 | int main(void) 22 | { 23 | int e, m, s; 24 | // Accept the marks 25 | printf("\nEnter marks of English :"); 26 | scanf("%d", &e); 27 | printf("\nEnter marks of Maths : "); 28 | scanf("%d", &m); 29 | printf("\nEnter marks of Science : "); 30 | scanf("%d", &s); 31 | // Assign the grades and print 32 | if ( e >= 30 && m >= 30 && s >= 30) 33 | { 34 | if (e >= 70 && m >= 70 && s >= 70) 35 | printf("Eligible for : Pure-Science, Bio-Science, Commerce and Humanities"); 36 | else if ( e >= 60 && m >= 60 && s >= 70) 37 | printf ("Eligible for : Bio-Science, Commerce and Humanities"); 38 | else if ( e >= 50 && m >= 60 && s >= 50 ) 39 | printf ("Eligible for : Commerce and Humanities"); 40 | else 41 | printf ("Eligible for : Humanities only"); 42 | } 43 | else 44 | printf ("Failed : Try next year"); 45 | return 0; 46 | } --------------------------------------------------------------------------------