Skip to main content

Posts

Frequency Of Elements in an Array

  Algorithm Step 1: Create a map of integer to store key-value pairs. map<int,int> Step 2: Now iterate over all the elements of the array and count their frequency by the help of map Step 3: Now make a iterator for map to iterate over the map items Step 4: This is the final step. Just print all the elements and their frequency stored in map respectively  Code

Academy Of Technology (2nd Internal)

 ES-CS201 (Programming Solution Of Question Bank) This is only for 2nd Semester Students Hi, I am Arnab. Here you can find out full solution of codes given in the question bank of AOT for ES-CS201 subject. So don't panic for your examination. Just copy down the codes from my website & run in your local machine to get more clear concepts. If you have any query please contact me without any hesitation from here .  So guys are you ready to get full marks??? Let's start Q1. Write a C program to calculate the sum of all negative and positive elements in an array. // Code to calculate all positive and negative values in an array #include<stdio.h> int main() { int n; scanf("%d",&n); int arr[n]; for(int i = 0; i < n; i++){ scanf("%d",&arr[i]); } int sum_of_pos = 0; int sum_of_neg = 0; for(int i: arr){ if(i<0){ sum_of_neg += i; } else{ sum_of_pos += i; } } printf("%d\n", sum_of_pos); print...

How to Code a Menu Driven Volume Finder Of Different Shapes

How to find volume of different shapes using a menu Now, let's talk about a little bit about this code. You have to write a program which will let you choose what shape's volume you want to find out & after this it will execute for that particular shape to find out it's volume.  So to code this our main target is to build a menu. So how can we do that? It's really simple. We just use a switch case to do this program. BASIC STEPS TO CODE THIS PROGRAM 1. First you should take the integer variable so that we can choose option from this like, Press 1 to find volume of cone, Press 2 to find volume of cylinder & so on. After that we should take float variables to store height, length, radius, width, edge length etc. 2. Next we use a switch case to execute the option driven code. 3. Now we will separately consider each case & make proper formula to find out the correct answer for that specific option selected shape's volume. That's all.  Isn't it so sim...

7 Benefits of Using Python for Web Development

 7 Benefits of Using Python for Web Development Python is one of the most popular programming languages in the world, and with good reason: it’s easy to learn, it’s fast, and it’s incredibly versatile. This makes it ideal not only for web development, but also for big data analysis, scientific computing, mobile apps, data science—the list goes on and on. However, there are still some lingering questions as to why you should choose Python over its competitors like PHP or Ruby, so here are seven reasons that will hopefully convince you to use Python in your next web development project. 1) Python code is easy to read Developers who use Python are forced to create code that is easier to read, thereby boosting productivity. But unlike with other programming languages, developers using Python don’t have to worry about formal training or memorizing syntax. For example, in order to add two numbers together in C++, a developer must remember that += means addition. However, in Python, + den...

C code to calculate product of even digits of a given number

 C code to calculate product of even digits of a given number Code Steps: 1. First input the number 2. Now initialize a variable =1, that stores the multiplication  3. Now start a while loop until number = 0 4. Inside while loop just find out all the digits by finding the remainder & check it if it is divisible by 2  5. If the number is divisible by 2 then multiply that number with the variable that was initialize = 1 6. At last return the multiplication storing variable.  C Code Snippet #include <stdio.h> int main (){     int num ;     int product = 1 ;     printf ( "Enter the number: " );     scanf ( " %d " , & num );     int temp = num ;     while ( num != 0 ){                 int digit = num % 10 ;         num = num / 10 ;         if ( digit % 2 == 0 ){         ...

What is the Difference Between Web Development and Android Development?

 What is the Difference Between Web Development and Android Development? While many people believe that web development and Android development are the same thing, this couldn’t be further from the truth. While both fields involve code and computers, the two actually have significantly different processes, tools, and skillsets required to complete their work. In this article, we’ll explore some of the key differences between web development and Android development in order to help you decide which profession may be better suited to your skill level and interests. Web Development vs Android Development The Ultimate Android vs Web Developers Showdown : There’s a massive amount of discussion around which type of development, web or android, is better. Both sides have passionate proponents who make compelling arguments. We don’t want to get into that argument. Instead, we’re going to look at both types of development and point out some strengths and weaknesses that make each different ...

How to code if two numbers are co-prime or not?

 C code for two numbers to check if they are co-prime or not Question: How can we understand if two numbers are coprime or not? Ans:  A Prime Number is defined as a Number which has no factor other than 1 and itself. But, Co-prime Numbers are Considered in pairs and two Numbers are  Co-prime  if they have a Common factor as 1 only . Their HCF is 1. Now come to the main point that is how to code it in C language so that we can get the correct output. C code snippet: #include <stdio.h> int main (){     int num1 , num2 , hcf ;     printf ( "Enter the first number: " );     scanf ( " %d " , & num1 );     printf ( "Enter the second number: " );     scanf ( " %d " , & num2 );     for ( int i = 1 ; i <= num1 ; i ++ )      {       if ( num1 % i == 0 && num2 % i == 0 )       {         hcf = i ;       ...