Skip to main content

Posts

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

                            #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

       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;        ...

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

#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

Language Generation

Generations-of-Computers

  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...

Flow Charts - What Is a Flow Chart? When to Use a Flowchart? Flowchart Symbols & Components

  Flow Charts     Flow charts are a useful tool in many situations, as we make a process easy to understand at a glance. Using just a few words and some simple symbols, they show clearly what happens at each stage and how this affects other decisions and actions.   What Is a Flow Chart?     In 1921, the Frank and Lillian presented what was only a "graphic-based method" in a presentation titled: “ Process Charts: First Steps in Finding the One Best Way to do Work ”, to members of the American Society of Mechanical Engineers (ASME). When to Use a Flowchart?     Flowchart is a very simple yet powerful tool to improve productivity in both our personal and work life. Here are some ways flowchart can be helpful:   ·      Document a process ·      Present solution to a problem ·      Brainstorm ideas in a meeting ·      Design an operation system ·    ...
Array in c Programmimg  An array is a data structure in C programming that stores a fixed-size collection of elements of the same data type. In C, arrays are defined by their size and their data type. For example, an array of 10 integers would be defined as "int myArray[10];" and an array of 5 characters would be defined as "char myArray[5];". One of the main advantages of using arrays in C programming is that they allow for efficient access and manipulation of large amounts of data. For example, if you wanted to perform a specific operation on each element of an array, you could use a for loop to iterate through the array, rather than writing out the operation for each individual element. Arrays in C can be defined with a fixed size, called a static array, or with a size that can change at runtime, called a dynamic array. Static arrays have a fixed size, determined at the time of creation and cannot be modified afterwards. Dynamic arrays allow for the size to be mo...