Posts

DATA TYPE in C/C++

Image
  BUILT IN OF PRIMARY DATA TYPE     int (Integer) float(Floating-point) double (Double Floating-point) char (Character) wchar_t (Wide Character) bool (Boolean) void (Empty) Modified Data Types List    signed int - (used for integers) unsigned - int (can only store positive integers) short (used - for small integers (range -32768 to 32767)) unsigned short - (used for small positive integers (range 0 to 65,535)) Long - (used for large integers) unsigned long - (used for large positive integers ) long long - (used for very large integers) unsigned long long - (used for very large positive integers) long double - (used for large floating-point numbers) signed char - (used for characters (guaranteed range -127 to 127)) unsigned char - (used for characters (range 0 to 255)) Derived Type Data Type    Function Array Pointers References User-Defined Data Type   Class Structure Union Enumeration Typedef defined DataType

What Are Tokens in C/C++?

Image
  What Are Tokens?   In simple terms, tokens represent the smallest meaningful components of any program that the compiler easily comprehends. They can be classified into six sub-categories: 1. Keywords 2. Constants 3. Strings 4. Identifiers 5. Operators 6. Special Symbols Now, let's explore each category: Keywords : Keywords are reserved terms in programming languages that provide specific functionalities to the program. They cannot be used as variable names. C/C++ pre-processor directives, such as header files, can modify keywords before compilation.   Constants : Constants, like variables, are unchanging values. The key distinction is that the program cannot modify the value of a constant after it has been defined. Constants can belong to various data types, including integer, floating-point, octal, hexadecimal, character, and string constants.   Strings : Strings are arrays of characters ending with a null character "\0". They are enclo

Calculating the sum of diagonal elements and then finding the difference in C++

Image
                            #add of diagonal of 2d array                           #include <iostream> using namespace std; #include <math.h> int main() {     int arr[3][3] = {1, 4, 2, 5, 2, 8, 2, 5, 9};     int sum1 = 0 , sum2 = 0;      for (int i = 0; i < 3; i++) {         sum1 += arr[i][i];          sum2 += arr[i][2 - i];      }     int d = abs(sum1 - sum2);     cout << "Sum of diagonal1: " << sum1 << endl;     cout << "Sum of diagonal2: " << sum2 << endl;     cout << "Diff between the sums: " << d << endl;     return 0; }

HOW TO PASS ARRAY IN FUNCTION

Image
       SUM OF ALL ELEMENTS OF ARRAY   #include <iostream> using namespace std;   int abc(int brr[], int n)    //abc is the name of function {               int sum=0;               for(int i=0; i<n; i++)               {                              sum+=brr[i];               }               return sum; }   int main() { int n = 10; int arr[n]= {1,2,3,4,5,6,7,8,9,10};   cout<<"Sum is : "<<abc(arr,n)<<endl;               return 0; }        AVERAGE OF ALL ELEMENTS OF ARRAY   #include <iostream> using namespace std;   double getAverage(int arr[], int size) {   int i, sum = 0;          double avg;                for (i = 0; i < size; i++) {       sum += arr[i];    }       avg = double(sum) / size;      return avg; }   int main () {      int balance[] = {1000, 2, 3, 17, 50};       cout << "Average value is: " <<    getAverage( balance, 5 )   << endl;  

C++ code for find the Length of the string without using strlen() function.

Image
#include <iostream> #include <string> using namespace std; int main() {     string str;     int length = 0;     cout << "Enter a string: " << endl;     getline(cin, str);     // this will take only one word               cin>>str;     for (int i = 0; str[i] != '\0'; i++) {         length++;     }     // or we can write                              length = str.length();     cout << "Length of string: " << length << endl;     return 0; }

Language-Generation

Image
Language Generation

Generations-of-Computers

Image
  What is a computer?            Computer is an advanced electronic device that takes raw data as an input from the user and processes it under the control of a set of instructions (called program), produces a result (output), and saves it for future use. This tutorial explains the foundational concepts of computer hardware, software, operating systems, peripherals, etc. along with how to get the most value and impact from computer technology. Functionalities of a Computer  There are three basic functionalities of a Computer System and they are  1. Input  2. Process  3. Output  But if we look at it in a very broad sense, any digital computer carries out the following five functions: Step 1 - Takes data as input.  Step 2 - Stores the data/instructions in its memory and uses them as required. Step 3 - Processes the data and converts it into useful information.  Step 4 - Generates the output.  Step 5 - Controls all the above four steps. Advantages of Computers Following are certain advant