Tuesday, 12 July 2016

Software Engineering Part 3


  1. At which level does the Software process rating start in continuous assessment model?

      2
      3
      1
      0

  2. What is the final level of the software process assessment ratings?

      Both of the listed options
      Optimised
      Completion
      None of the listed options

  3. Quantitative assessments are evaluated based on which of the following?

      Action taken
      Process planned
      Objective planned
      Scores
     

  4. Which of the following is an activity performed in SCAMPI method?

      Final reporting
      Primary activity
      Technical analysis
      Information gathering

Monday, 27 June 2016

Software Engineering Part 2


  1. The approach to construction affects the project's ability to reduce complexity, anticipate change, and construct for verification. State whether the statement is TRUE or FALSE.

  2.   True
      False

  3. The choice pf construction method affects which of the following?

  4.   All of the given options
      the order in which construction prerequisite are performed
      and the degree to which construction prerequisites are expected to be completed before construction work begins
      extent to which construction prerequisites are performed
  5. What are the correct sequence of steps followed while debugging a piece of code?

  6.   1. Identify the exact place in the code causing it
      2. Find the defect in the code
      3. Identify the source of problem
      4. Test to check if the fix is working correctly
      5. Fix the defect
      1,2,3,4,5
      2,4,3,1,5
      2,3,1,5,4
      1,3,5,2,4

  7. Software Construction procedure high volume of configure items. Thus Software Construction is related Software Configuration Management. State whether the statement is True or False.

  8.   False
      True

  9. A measurement of code construction can be useful for which of the following purpose?
  10.   improving the construction process
      ensuring quality during construction
      managing construction
      all of the given options

Wednesday, 8 June 2016

Software Engineering Part - I


  1. Which of the following diagram depicts the logic of use case descriptions. It shows the information that passes between objects in the system and throughout the execution of the use case?

  2.   activity diagram
      class diagram
      use case diagram
      flowchart diagram
      sequence diagram

     
  3. Requirements refinement and documentation takes place very early on in the project cycle. State True or False.

  4.   True
      False

     
  5. The activity diagram analysis technique is used in which of the below analysis areas?

  6.   Process flow analysis
      Structured Analysis
      Object-oriented analysis
      Solution Development Analysis

     
  7. Which of the below is NOT the most common type of Environmental requirement?

  8.   interface requirements
      audit requirements
      legal and regulatory requirements
      globalization and localization requirements

     
  9. Which of the below depicts workflow or a sequence of related activities by showing the order in which activities occur and the decisions that control the flow?

  10.   activity diagram
      dataflow diagram
      workflow diagram
      flowchart diagram
      sequence diagram

     
  11. What is the popluar model used by Business Analysts to analyze the requirements?

  12.   Usage Model
      Process and Flow model
      Data and Behaviour model
      All the listed options

     
  13. Which one of the following cannot be depicted using state machine diagrams about an object?

  14.   the transitions between states
      the events that cause the transitions
      data that flows within the domain
      the possible states it can be in
     

  15. The benefits of knowing how to refine requirements is that you will be able to _______

  16.   classify quality of service requirements according to type
      recognize the importance of considering assumptions and constraints when analyzing requirements
      effectively decompose requirements for documentation
      use appropriate techniques to document requirements
      All the listed options

  17. Functional requirements are required for all projects, and must be thoroughly documented and analyzed. State True or False.

  18.   True
      False

     
  19. UML defines standards for the format and components of activity diagrams.

  20.   True
      False

  21. Identify non functional requirement(s)?
  22.   Security
      All the listed options
      Performance
      Usability

  23. Identify the requirement that states -"A system must track all failed login attempts".

  24.   Operational requirement
      Interface requirement
      Environment requirement
      Performance requirement
      Privacy requirement

  25. The advantage of ____________ is that functional requirements are traceable and map to objectives.
  26.   flowchart
      models
      textual documentation
      matrix documentation
      diagrams

    Note: If any of the answer is wrong. Please post a comment.

Tuesday, 17 May 2016

Sub Queries MCQ


  1. The SQL _______ Query is used to delete the existing records from a table.

  2.         DELETE
            REMOVE
            DELETIT

  3. Subqueries that return more than one row can only be used with multiple value operators, such as the IN operator.
    state True or False:

  4.         True
            False

  5. Which one of the following sorts rows in SQL?

  6.         SORT BY
            ALIGN BY
            ORDER BY
            GROUP BY

  7. We can test for the nonexistence of tuples in a subquery by using the _____ construct.

  8.         EXISTS
            NOT EXISTS
  9. Subquery is usually added in the WHERE Clause of the SQL statement.
    state True or False:

            True
            False

Thursday, 14 April 2016

SQL MCQ Questions

  1. Which of the following creates temporary relation for the query on which it is defined ?
  2.         With
            From
            Where
            Select
  3. The EXISTS keyword will be true if:
  4.         Any row in the subquery meets the condition only.
            All rows in the subquery fail the condition only.
            Both of these two conditions are met.
            Neither of these two conditions is met.
  5. Which of the following relational algebra operations do not require the participating tables to be union-compatible?
  6.         Union
            Insertion
            Difference
            Join
  7. Which of the following operations need the participating relations to be union compatible?
  8.         Union
            Insertion
            Difference
            All the above
  9. Select name from instructor where salary <=100000 and salary >=90000;
    This query can be replaced by which of the following ?
  10.         Select name from instructor where salary between 90000 and 100000;
            Select name from employee where salary <= 90000 and salary>=100000;
            Select name from employee where salary between 90000 and 100000;
            Select name from instructor where salary between 100000 and 90000;
  11. Select __________
    from instructor
    where dept name= ’Comp. Sci.’;
    Which of the following should be used to find the mean of the salary ?
  12.         Mean(salary)
            Count(salary)
            Avg(salary)
            Sum(salary)
  13. Aggregate functions are functions that take a ___________ as input and return a single value
  14.         Collection of values
            Single value
            Aggregate value
            Both a & b

Saturday, 19 March 2016

DBMS Questions


  1. A table is the primary unit of physical storage of data in a database.State True or False.
  2.         True
            False

  3. Which one of the following is a large database from which information can be extracted and analyzed?
  4.         Database
           Sysbase
           Datawarebase
           DBMS

  5. Which one of the following data model resembles like a tree structure?
  6.         Network model
            Database model
            Relational model
            Hierarchical model

  7. Which of the given option is true regarding the database?
  8.         Data Sharing
            Data concurrency
            All the listed options
            Data Integrity
            Data security

  9. DBMS can replace a file processing system. State True or False.
            True
            False

  10. What is the advantage of minimizing the data redundancy?
            Avoid inaccuracies and inconsistencies in the data
            Save Time in processing the data
            All the above
  11.        To free up the storage space

  12. Which of the following are the types of data models
            All of the listed option
            Network Model
            Hierarchial Model
            Relational Model

  13. Database system is used to restrict the user from unauthorized access.State True or False
            True
            False

  14. Which one of the following is true about RDBMS?
      1. It has relations data integrity
      2. It can maintain many users at the same time
      3. It doesn’t support client/server based application
      4. It is a relational database system
      5. It cant maintain many user at the same time.
            1,3
            2,4
            3,4,5
            1,2,4
            4,5

  15. What is the main component of DBMS?
            Data Modelling
            Data Dictionary
            OLAP Database
            Data Sharing

  16. In which form does the data gets stored in the database?
            Electronic form
            Rich text form
            Non Electronic form
            None of the listed options

  17. Which of the given term refers to Data about the data?
            Data Abstraction
            Views
            Metadata
            Program

  18. DBMS controls redundancy.State True or False.
            False
            True

  19. DBMS helps us to?
      1. Define Schemas and Subschemas in a database and establish relationships between different data elements
      2. Enter Data Into Database
      3. Manipulate and Process Data
      4. None of the listed options
            1&2
            1&3
            4
            1&2&3

  20. The traditional storage of data which is organized by the customers by storing it in separate folders. This is the example of which type of database system?
            Object oriented
            Hierarchical
            Relational
            Network

  21. Arena is married to Vasu and she has a unique SSN. This is an example of a (an):
            Unary Relationship
            Binary Relationship
            Hierarchical Relationship
            Ternary Relationship

  22. In DBMS, what will be the outcome when we map a multivalued attribute for any entity from the ER model to the relational model?
            None of the above
            Many relations, one for each of the distinct values of the attribute
            A column in the relation that represents the entity E
            One relation that contains a foreign key and a column for the attribute

  23. The efficient performance of the database is based on which of the following factors?
      1. Database Design
      2. Application Design
      3. Network Speed
      4. None of the listed option
           1,2,3
            1,3
            1,2
            4

  24. There are two tables Customers and Orders. The customers table would include information about the names , addresses and phone numbers of customers, the order table would include information about the products ordered , the customers,order dates and sales prices ,the Sales manager wants to view only the number of orders placed by each customer on a given date, A Finance Manager in the same company can group the table entries to view only the names and addresses of customers with pending payments.This Grouping of data is possible in?
           Hierarchical Database
            Relational Databse
            Network Database
            Object Oriented Database

Note: If any of the answer is wrong please post a comment. I will update it.

Decipher my Ciphertext


In the language of cryptography, ciphertext refers to a message encoded with a particular key. Plaintext refers to the original, unencoded text. In this problem, both the ciphertext and the key are simply strings of upper-case characters. The ciphertext is generated from the plaintext by “adding” corresponding characters of the plaintext and the key together. If the plaintext is shorter than the key, only some of the key will be used. Similarly, if the plaintext is shorter than the key, the key will be used multiple times.

For example, to encode the plaintext “HELLO” with the key “CAT”:
Plaintext: HELLO
Key: CATCA
Ciphertext: KFFOP

And to encode the plaintext “DOG” with the key “FIDO”:
Plaintext: DOG
Key: FID
Ciphertext: JXK

To add two letters together, use the following convention: A=1, B=2, …, Z=26. If the sum of two letters is greater than 26, subtract 26 from the sum. For example: A + E = 1 + 5 = 6 = F, and D + X = 4 + 24 = 28 = 2 = B.

Given a ciphertext/key pair, determine the corresponding plaintext.

Input Format :
Input will consist of pairs of lines, with the first line being the ciphertext and the second line being the key. Both will consist of only uppercase letters.
Output Format:
For each ciphertext/key pair, print the corresponding plaintext message.

Example:
Sample Input:
HELLO
CAT

Sample Output:
KFFOP

Code:
  #include<stdio.h>
#include<string.h>
int main()
{
  char p[50]={0},key[50]={0};
    int x=0;
  char c[50]={0};
  int i,l1,l2;
  scanf("%s",p);
  scanf("%s",key);
  l1=strlen(p);
  l2=strlen(key);
  if(l1<=l2)
  {
    goto END;
  }
  else if(l1>l2)
  {
    for(i=l2;i<l1;i++)
    {
      key[i]=key[x];
      x++;
    }
    //printf("\n%s",key);
    goto END;
  } 
  END:
  for(i=0;i<l1;i++)
  {
    p[i]=(int)p[i]-64;
    key[i]=(int)key[i]-64;
    c[i]=p[i]+key[i];
    if(c[i]>26)
      c[i]=c[i]-26;
    c[i]=c[i]+64;
    printf("%c",c[i]);
  }
  return 0;
}
    
  

Fibonacci Roots


The first two terms in the Fibonacci sequence are 0 and 1, respectively, and each subsequent term is the sum of the previous two. Using this definition to calculate the first several terms in the sequence, we get

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Let us define the Fibonacci roots of a positive integer n to be the two smallest consecutive Fibonacci numbers whose sum is greater than or equal to n.

Input Format: 
Input consists of a single integer which corresponds to n.
Assumption: 
Assume that n is less than or equal to 2000.
Output Format: 
Output consists of integers, separated by a space.
Sample Input 1 : 
31
Sample Output 1: 
13 21
Sample Input 2 : 
89
Sample Output 2: 
34 55

Code:
  #include<stdio.h>
int main(){
  int a=0,b=1,c=0,n;
  scanf("%d",&n);
  while(1){
    c=a+b;
    if(c>=n)
      goto END;
    a=b;
    b=c;
  }
  END: printf("%d %d",a,b);
  return 0;
}

Vowel or Consonant


Write a program to determine whether the input character is a vowel or consonant.

Input and Output Format: 
Input consists of a single character. Output consists of a string --- “Vowel” / “Consonant” / “Not an alphabet”
Refer sample input and output for formatting specifications.
All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1: 
Enter a character
a
Vowel
Sample Input and Output 2: 
Enter a character
Z
Consonant

Sample Input and Output 3: 
Enter a character
#
Not an alphabet

Code:
  #include<stdio.h>
int main(){
  char in;
  char arr[11]={'a','e','i','o','u','A','E','O','U','I'};
    int i,flag=0,con=0;
  printf("Enter a character\n");
  scanf("%c",&in);
  if(((in>='a') && (in<='z'))||((in>='A')&&(in<='Z')))
  {
    for(i=0;i<10;i++)
    {
      if(in==arr[i]){
        flag++;
        break;
      }
      else
        con++;
    }
  }
  else 
    printf("Not an alphabet\n");
  
  if(con)
    printf("Consonant");
  if(flag)
    printf("Vowel");

  
  
  return 0;
}

Anagrams


Write a program to find whether the 2 given strings are anagrams or not. Anagrams are words or phrases made by mixing up the letters of other words or phrases,

Input and Output Format: 
Input consists of 2 string. Assume that all characters in the string are lowercase letters or spaces and the maximum length of the string is 100.
Refer sample input and output for formatting specifications.
All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1: 
Enter the first string
anitha
Enter the second string
amphisoft
anitha and amphisoft are not anagrams

Sample Input and Output 2: 
Enter the first string
the eyes
Enter the second string
they see the eyes and they see are anagrams

Code:
  #include<stdio.h>
#include<string.h>
int main(){
  char s1[200],s2[200];
  int first[26]={0},second[26]={0},c=0,i,flag=0;
    //int l,l1;
  printf("Enter the first string\n");
  gets(s1);
  printf("Enter the second string\n");
  gets(s2);
  
    while(s1[c]!='\0')
    {
      first[s1[c]-'a']++;
      c++;
    }
    c=0;
    while(s2[c]!='\0')
    {
      second[s2[c]-'a']++;
      c++;
    }
    for(i=0;i<26;i++){
      if(first[i]!=second[i])
        flag=1;
    }
      
  if(flag==0)
    printf("%s and %s are anagrams",s1,s2);
  else
    printf("%s and %s are not anagrams",s1,s2);
  
  return 0;
}

Zero Duplicates


Write a program that will read in a list of numbers and will then print out the same list except numbers that have already been printed will be printed as a zero instead.

Input Format: 
Input consists of n+1 integers where n is the number of elements in the list. The first integer corresponds to n. The remaining n integers correspond to the elements in the list. 
Assume that the maximum value of n is 100. 

Output Format: 
Output consists of n integers on separate lines.

Sample Input : 
5
2
3
4
3
6
Sample Output: 
2
3
4
6

Code:
  #include<stdio.h>
int main(){
  int n,a[100],i,c,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  
  for(i=0;i<n;i++)
  {
    c=0;
    for(j=0;j<i;j++)
    {
      if(a[i]==a[j]){
        c=1;
        break;
      }
    }
    if(c==1)
      printf("0\n");
    else
      printf("%d\n",a[i]);
  }
  
  return 0;
}

The Next Palindrome


A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. For a given positive integer K, write the value of the smallest palindrome larger than K to output. 

Input 
The first line contains an integer, which corresponds to K. Assume that K is less than 200000. 

Output
Output consists of a single integer, which corresponds to the smallest palindrome larger than K.

Sample Input 1:
808

Sample Output 1:
818

Sample Input 2:
2133

Sample Output 2:
2222

Code:
  #include<stdio.h>
int main()
{
  long int num,pa=0,rem,temp;
  scanf("%ld",&num);
  while(num!=pa){
    num=num+1;
    temp=num;
    pa=0;
    while(temp!=0){
      rem=temp%10;
      pa=rem+pa*10;
      temp=temp/10;
    }
  }
  printf("%ld",pa);
  return 0;
}

TENNIS COURT


Many of the current final year students of a college are excellent tennis players. They always emerge as champions in the State Level Inter-Collegiate Tennis Meet. They want their juniors to carry on their legacy in the field of tennis and they started training their juniors in tennis. They were happy to see them play very well during their coaching sessions. They had a very comfortable win over one of the top teams in the game played at their college. But to their dismay, their juniors performed very poorly in the games conduced at other venues.

The think-tank of the College Tennis club was pondering over the reasons for their poor performance in the meets. David came up with a possible reason for the poor performance of their junior team. The tennis court in their college is a grass court but the tennis courts in most other competitive venues are synthetic courts. Their junior team has learnt playing tennis in the grass court and they found it very difficult to adapt their game to synthetic courts. The entire team agreed with this reason and they planned to request the chairman to convert the grass tennis court to synthetic tennis court.

They sent a request to the Chairman and he readily agreed but he asked to do it with minimal expenditure. He gave them square stones. 

The tennis court in the college is rectangular in shape of size n*m metres. We need to pave the court with square stones. The square stone is of size a*a. 

What is the least number of stones needed to pave the tennis court? It's allowed to cover the surface larger than the Tennis Court, but the court has to be covered. It's not allowed to break the stones. The sides of stones should be parallel to the sides of the court. 

Input Format: 
Input consists of 3 integers. The first integer corresponds to 'n', the length of the court. The second integer corresponds to 'm', the width of the court. The third integer corresponds to 'a', the side of the square stone. 

Output Format: 
Output consists of ta single integer k, where k is the least number of stones needed. 

Sample Input: 
 6 
6 
4 
Sample Output: 
4

Code:
  #include<stdio.h>
#include<math.h>
int main(){
  int l,b,la,ba,plate,a;
  scanf("%d",&l);
  scanf("%d",&b);
  scanf("%d",&a);
  la=round((float)l/a);
  ba=round((float)b/a);
  plate=la*ba;
  printf("%d",plate);
  return 0;
}
  

SMS Language


SMS language or textese (also known as txt-speak, txtese, chatspeak, txt, txtspk, txtk, txto, texting language, txt lingo, SMSish, txtslang,or txt talk) is a term for the abbreviations and slang commonly used with mobile phone text messaging. 

 Some of the abbreviations used are

  • s for yes
  • u for you
  • 2day for today
  • y for why

Many grandpa's have started sending SMSes to their grand children. But they are not familiar with the SMS lingo. 

Can you help them by writing a program that would convert a given text in proper English to SMS lingo? Consider only the 4 words listed above. 

Input Format: 
Input consists of a single string. Assume that the maximum length of the string is 200 and all letters are in lower-case. 

Output Format: 
Output consists of a single string. 

Sample Input 1: 
where were you yesterday? 

Sample Output 1: 
where were u yesterday? 

Sample Input 2: 
why is today a working day for you? 

Sample Output 2: 
y is 2day a working day for u?

Code:
  #include<stdio.h>
#include<string.h>
void replace(char *);
int main(){
  char s1[100];
  gets (s1);
  replace(s1);
  printf("\n%s",s1);
  return 0;
}
void replace(char *s1)
{
  char r[4][10]={"yes","you","today","why"};
    char rep[4][5]={"s","u","2day","y"};
      char buff[500];
  int i;
  char *ch;
  for(i=0;i<4;i++)
    if((ch=strstr(s1,r[i]))){
      strncpy(buff,s1,ch-s1);
      buff[ch-s1]=0;
      sprintf(buff+(ch - s1),"%s%s",rep[i],ch+strlen(r[i]));
      s1[0]=0;
      strcpy(s1,buff);
      return replace (s1);
    }
}

ENCODING


In this program you will be given a letter to encode. The difference here is that different rules are used for different letters and the counting process can cause you to wrap around the alphabet. Using the numerical value of each letter (A=1, B=2, ... Z= 26) the rules are as follows:


As an example if the letter to encode is a B, the B has a numerical value of 2 and encodes to a 4 and becomes a D, the 4th letter of the alphabet.
The G has a numerical value of 7. It encodes to a 5 and becomes an E.
The numerical value of Z is 26. Its largest factor is 13. You must count 156 (13*12) letters. This has the effect of wrapping around the alphabet 6 complete times and ending at Z. If a numerical value of zero is evaluated print a # symbol.
[Hint: ASCII value of A is 65].

INPUT: 
Input consists of an upper case letter.
OUTPUT: 
Print the encoded letter it produces.
SAMPLE INPUT 1
B
SAMPLE OUTPUT 1
D
SAMPLE INPUT 2
Z
SAMPLE OUTPUT 2
Z

Code:
  #include<stdio.h>
void prin(int);
int main(){
  unsigned char c,r;
  int k,r1=0,i=2;
  scanf("%c",&c);
  c=c-64;
  if(c>=1 && c<=5)
  k=1;
  else if(c>=6 && c<=10)
  k=2;
  else if(c>=11 && c<=15)
  k=3;
  else if(c>=16 && c<=20)
    k=4;
  else if(c>=21 && c<=26)
    k=5;
    
   switch(k)
  {
    case 1:
    r=c*2;
    break;
    case 2:
    r=(c%3)*5;
    break;
    case 3:
    r=(c%4)*8;
    break;
    case 4:
    r=c+10;
    break;
    case 5:
    {
      for(i=2;i<c;i++)
      {
        r1=c%i;
        if(r1==0)
          r=i*12;
      }
      break;
    }
  }
  
  if(r==0)
    r=-29;
  else if(r>26)
  {
    r=r%26;
    if(r==0)
      r=26;
  } 
  r=r+64;
  printf("%c",r);
  return 0;
}
    
        

Railway – Seating arrangement for Sleeper Class


Write a program to determine the type of berth when the seat/berth number in the train is given.
Input Format: 
Input consists of a single integer. Assume that the range of input is between 1 and 72.
Output Format: 
Output consists of a single string. [Upper or Middle or Lower or Side Lower or Side Upper]

Sample Input 1: 
9
Sample Output 1: 
Lower

Sample Input 2: 
72
Sample Output 2: 
Side Upper





Code:
  #include<stdio.h>
#include<string.h>
int main(){
  int n,k;
  scanf("%d",&n);
  k=n%8;
  if(k==1 || k==4)
    printf("Lower");
  if(k==2 || k==5)
    printf("Middle");
  if(k==3 || k==6)
    printf("Upper");
  if (k==0)
    printf("Side Upper");
  if(k==7)
    printf("Side Lower");
           
           
           
    return 0;
}
    

Sum of positive numbers


Write a program to find the sum of positive numbers in an array.

Input Format: 
Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.

Output Format: 
Refer sample output for details.
Sample Input :
5
2
3
6
8
-1
Sample Output : 
The sum of the positive numbers in the array is 19

Code:
  #include<stdio.h>
int main(){
  int n,a[20],i,sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>0)
      sum=sum+a[i];
  }
  printf("The sum of the positive numbers in the array is %d",sum);
  return 0;
}
  
  

Compatible Arrays


2 arrays are said to be compatible if they are of the same size and if the ith element in the first array is greater than or equal to the ith element in the second array for all i.Write a program to find whether 2 arrays are compatible or not.

Input Format: 
Input consists of 2n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. The last 'n' integers correspond to the elements in the second array. Assume that the maximum value of n is 15.

Output Format: 
Refer sample output for details. Sample Input 1:
5
2
3
6
8
1
1
1
1
1
1

Sample Output 1:
Compatible

Sample Input 2: 
5
2
3
6
8
1
1
1
1
1
2

Sample Output 2:
Incompatible

Code:
  #include<stdio.h>
int main(){
  int n,a[20],b[20],i,flag=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    scanf("%d",&b[i]);
    if(a[i]<b[i])
      flag=1;
  }
  if(flag)
    printf("Incompatible");
  else
    printf("Compatible");
  
  
  return 0;
}

Sum of 2 arrays


Write a program to find the sum of the corresponding elements in 2 arrays.

Input Format: 

Input consists of 2n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the first array. The last 'n' integers correspond to the elements in the second array. Assume that the maximum value of n is 15.

Output Format: 
Refer sample output for details.

Sample Input 1: 
 5
 2
 3
 6
 8
 1
 1
 1
 1
 1
 1

Sample Output 1: 
 3
 4
 7
 9
 2

Code:
  #include<stdio.h>
int main(){
  int n,a[20],b[20],i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(j=0;j<n;j++)
    scanf("%d",&b[j]);
  for(i=0;i<n;i++)
    printf("%d ",a[i]+b[i]);
  return 0;
}

Sum of array elements


Write a C program to find the sum of the elements in an array.

Input Format:

Input consists of n+1 integers. The first integer corresponds to ‘n’ , the size of the array. The next ‘n’ integers correspond to the elements in the array. Assume that the maximum value of n is 15.

Output Format:
Refer sample output for details.

Sample Input 1: 
 5
 2
 3
 6
 8
 1

Sample Output 1: 
The sum of the elements in the array is 20

Code:

  #include<stdio.h>
int main(){
  int n,i,a[20],sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
    sum=sum+a[i];
  }
  printf("The sum of the elements in the array is %d",sum);
  return 0;
}