C Array (PartII)

1. What would be printed from the following C program?
#include<stdio.h>
#include<conio.h>
int main(){
  int arr[5]={1,3,5,7,9}; //initialize arr array
  int i;
  for(i=0;i<5;i++) //output arr array
       printf("%d\t",arr[i]*arr[i]);
  getch();
  return 0;
}
Check answer 2. What would be printed from the following C program?
#include<stdio.h>
#include<conio.h>
int main(){
  int arr[5]={1,3,5,7,9}; //initialize arr array
  int i;
  for(i=4;i>=0;i--) //output arr array
       printf("%d\t",arr[i]);
  getch();
  return 0;
}
Check answer 3.What would be printed from the following C program?
#include <stdio.h>
#include <conio.h>

int main(){
  int list1[5]={1,3,5,7,9}; //initialize list1 array
  int list2[5];
  int i;
  for(i=0;i<5;i++)
      list2[i]=list1[i]+1; //assign values to list2
  for(i=0;i<5;i++) //output list2
      printf("%d\t",list2[i]);
  getch();
  return 0;

}
 Check answer 4. What would be printed from the following C program?
#include <stdio.h>
#include <conio.h>

int main(){
   int list[10]={1,2,3,4,5,6,7,8,9,10}; //initialize list array
   int i;
   for(i=0;i<5;i++)
   { //switching elements
      int temp=list[i];
      list[i]=list[9-i];
      list[9-i]=temp;
   }
   for(i=0;i<10;i++) //output list
       printf("%d\t",list[i]);
   getch();
   return 0;

} Check answer


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.
Copyright @ 2011-2013 worldbestlearningcenter. All Rights Reserved.