( C prog) write an output for the following code fragment int a[]= {1, 2, 3, 4, 5, 6}: int *ip; int i; ip=a; ip +=3; *ip= *ip * 3; for (i=0; i <6; ++i) printf("%d," a[i]);
Dear Student,
Here i have re-written the C program as per the requirement. And also commented out the code for your better undertanding. below i have attached the code and the corresponding output.
NOTE:1 Please note that the below programs have been tested on ubuntu 14.04 system and compiled under gcc compiler. This code will also work on other IDE's.
--------------------------------------------------------------------------------------------------------------------------------------
Program.. -------------------------------------------------------------------------------------------------------------------------------------
//Header file declaration
#include<stdio.h>
#include<stdlib.h>
int main()
{
//this is the array initialization
int a[]= {1, 2, 3, 4, 5, 6};
//pointer and variable declaration
int *ip;
int i;
//assining pointer to tha array
ip=a;
//adding a value to pointer variable
ip +=3;
//multiplying pointer by three
*ip= *ip * 3;
//loop to print updated array values
for(i=0; i <6; ++i)
printf("%d ", a[i]);
printf("\n");
return 0;
}//end of the program
----------------------------------------------------------------------------------------------------------------------------------------
here i have attached the output of the program as a screen shot...
Output:
-------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Kindly Check and Verify Thanks...!!!
( C prog) write an output for the following code fragment int a[]= {1, 2, 3,...
Write the output from the following code fragment: for (int i = 1; I < 7; ++i) { switch (i) { case 1: printf ("\n%d Banana", i); case 2: printf ("\n%d Kumquat", i);
20) What is the output of the following segment of C code: int avg(int n, int* a); int main () { int array[4]={1,0,6,9}; printf("%d", avg(4, array)+ 1); system("pause"); return 0; } int avg(int n, int* a) { int i, sum=0; for (i=0;i<n;i++) { sum+=a[i]; } return sum/n; } a) 16 b) 5 c) 4 d) 8 21) What is the output of the following segment of C code: int x = 2; int y = 3;...
What is the output of the following fragment? please explain. C language int i = 1; int j = 1; while (i < 5) { i++; j = j * 2; } printf(“%d”, j); (a) 4 (b) 8 (c) 16 (d) 32
What is the output of the following code fragment? int i = 1; while( i <= 5 ) if(i == 2 || i == 4) System.out.println(i + ":" + " is an even index) System.out.println("i: " + i); i++;
Given the following code in C, what is the output of this program? (10 Points) int mainO f 5. int i=10; for(int j-l;j-3;j++) int i=5 printf("i=%dn', i); printf("f%d\n", i); return 0;
QUESTION Z What is the output of the following code: int list[] = {1, 2, 3, 4, 5, 6}; for (int i = 1; i < 6; i++) list[i] = list[i - 1]; for (int i = 0; i < 6; i++) cout << list[i] << ""; 0 1 2 3 4 5 6 0 2345 61 0 111111 0 234 566
1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...
2. What is the output of the following code fragment? n = 1; while (n <= 5) { n++; cout << n << ' '; a.1 2 3 4 5 b. 1 2 3 4 c. 1 1 1 forever d. 2 3 4 5 e. 2 3 4 5 6 3. What is the termination condition for the following While loop? while (beta > 0 && beta < 10) { cout << beta << endl; cin >> beta; }...
What is the output of the following code? #include« stdio.h» 2 4 int main() 6 int a=15,b=12,c=5, d-e; 7 printf("the value of d is %d",d); return 0; 8 9 10 Ly 0 29 O 30 0 28 O 31
Given the following code fragment: int * SW_Ptr; *SW_Ptr = 0x00000987; int Nib2 = (*SW_Ptr >> 8) & 0xF; int Nib1 = (*SW_Ptr >> 4) & 0xF; int Nib0 = (*SW_Ptr) & 0xF; Which is the correct value of Nib1, Nib2, Nib3. Microcontrollers using c prog