#include <iostream> using namespace std ; int main () { /*###AN ARRAY IS A COLLECTION OF ITEMS OF SIMILAR TYPES STORES IN CONTIGUOS(CHIPAK CHIPAK KE) MEMORY LOCATION ###SOMETIMES A SIMPLE VARIABLE IS NOT ENOUGH TO HOLD ALL THE DATA ###FOR EXAMPLE hume 2500 students ke marks store krne h so 2500 variables bnana fesile nhi hoga ###to solve this problem we can define an array with size 2500 that can hold the marks of all students ###ginti 0 se start hogi ye c++ ka rule hai, 0,1,2... indices hote h*/ /********ARRAYS EXAMPLE********/ //int marks[4] = {5, 7, 57, 75}; //bracket m 4 likhna optional hai kyuki compiler khud hi figure out krelta hai //cout<<marks[0]<<endl; //cout<<marks[1]<<endl; //cout<<marks[2]<<endl; //cout<<marks[3]<<endl; //yaha humne marks naam ka ek array bnaya jo continuous data store kr raha h //another way to ma...
#include <iostream> using namespace std ; int sum ( int a , int b ){ cout << "by function1 is " ; return a + b; } int sum ( int a , int b , int c ){ cout << "by function2 is " ; return a + b + c; } int volume ( int a ){ return a * a * a; } int volume ( int r , int h ){ return 3.14 * r * r * h; } int volume ( int l , int b , int h ){ return l * b * h; } int main (){ cout << "the sum of 5 and 7 " << sum ( 5 , 7 ) << endl; cout << "the sum of 5, 7 and 57 " << sum ( 5 , 7 , 57 ) << endl; cout << "the volume of cube of side length 5 is " << volume ( 5 ) << endl; cout << "the volume of cylinder of radius 5 and height 7 is " << volume ( 5 , 7 ) << endl; cout << "the volume of cuboid of length 5, bredth 7...
/*OOPS---> Classes and Objects C++--> initially called as C with classes by stroustroup Class--> extension of structures in C Structures had limitations - members are public - a function cannot be created inside structure - no methods Classes --> Structures + more Classes --> can have methods and properties Classes --> can make few members as private and few as public Structues in c++ are typedef (mtlb typedef na lgakr bi structures ke varibales define kre to vo hojaenge) you can declare objects along with class declaration like this: class Employee { class definition } krishna, shalini; harry.salary = 9 makes no sense if salary is private */ /************NESTING OF MEMBER FUNCTIONS******** */ #include <iostream> using namespace std ; // int main(){ // binary b; // b.read(); // ...
Comments
Post a Comment