Sei sulla pagina 1di 5

Write the correct option or answer in your Tutorial Book

1. Which of the following is/are right way/s to Initialize an array?


a. int num[6] = { 2, 4, 12, 5, 45, 5 };
b. int n{} = { 2, 4, 12, 5, 45, 5 };
c. int Array{6} = { 2, 4, 12 };
d. int n[] = {1,2,4,5,7,8};
e. int n6(6) = { 2, 4, 12, 5, 45, 5 };

2. What will be the output of the following program?

void main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
}

3. What will be the output of the following program?

int main(void){
char p;
char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};
p = (buf + 1)[5];
printf("%d", p);
return 0;
}
a. 5
b. 6
c. 9
d. Error
e. None of the above

4. Derive the Output for following codes

int main(){
int a1[5]={6,1,2,3,4},i;
for(i=0;i<5;i++)
printf("The value of Array[%d] is %d\n\n",i,a1[i]);
scanf("%d%d",a1,&a1[3]);
for(i=0;i<5;i++)
printf("The value of Array[%d] is %d\n\n",i,a1[i]);
return 0;
}

5. What will be the output of the following program?

int main(){
int a[5]={1,2,3,4,6};
float b[5]={2,3,-6,7,8};
int i=0,j=0;
for(i=0;i<5;i++)
printf("%f\n",a[i]+b[i]);
return 0;
}

6. What will be the output of the following program?

int main(){
float arr[] = {12.4, 2.3, 4.5, 6.7};
printf("%d\n",sizeof(arr)/sizeof(arr[0]));
return 0;
}

7. What will be the output of the following program?

int main(){
int arr[10] = {1,2,3,4,5};
int arr2[10] = {1,2,3,4,5};
if(arr==arr2)
printf("The array are equal");
else
printf("Not equal");
return 0;
}

8. What will be the output of the following program?

int main() {
char word[]={'h','e','l','l','o'};
int i;
for(i=0;i<6;++i)
printf("%c",word[i]);
printf("\n");
return 0;
}

9. What will be the output of the following program?

int main()
{
char arr[7]="Network";
printf("%s",arr);
}

10. What will be the output of the following program?

int main()
{
int arr[1]={10};
printf("%d\n",0[arr]); return 0;
}

11. What will be the output of the following program if array begins at 65432?

int main()
{
int arr[] = {12, 14, 15, 23,45};
printf("%u, %u\n",arr, &arr);
return 0;
}

12. What will be the output of the following program?

int main()
{
char str[11]={'H', 'e', 'l', 'l','o',' ','w','o','r','l','d'};
printf(%s,str);
}

13. What will be the output of the following program?

int main()
{
int a;
char c[]= c programming is one of the best basic programming language;
for(a=0; c[a]!= \0; ++a)
if((a%2) == 0)
printf(%c %c,c[a],c[a]);
}

14. The element in 4th logical column and 6th logical row of array Data will be accessed
as_________ and will be stored at _______th location form first array element

15. What will be the output of the following program?

Void main( )
{
int num[26], temp ;
num[0] = 100 ;
num[25] = 200 ;
temp = num[25] ;
num[25] = num[0] ;
num[0] = temp ;
printf ( "\n%d %d", num[0], num[25] ) ;
}

16. What will be the output of the following program if the array begins at 65472 and
each integer occupies 4 bytes?

int main() {
int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};
printf("%u, %u, %u\n", a, a+1, &a+1);
return 0;
}

17. What will be the output of the following program?

main(){
char str[ ] = "learning C is fun!:)" ;
printf ( "\n%s", str ) ;
printf ( "\n%s", &str ) ;
printf ( "\n%c", str[2] ) ;
printf ( "\n%s", &str[2] ) ;
return 0;
}

18. What will be the output of the following program?

void main(){
int n[3][3] = {
2, 4, 3,
6, 8, 5,
3, 5, 1
};
int i, j ;
for ( i = 0 ; i <= 2 ; i++ )
for ( j = 0 ; j <= 2 ; j++ )
printf ( "\n%d", n[j][i] ) ;
}

19. What will be the output of the following code strip?


char item[]=Clock;
printf(%.3s,item);

20. What will be the output of the program?


void main( )
{
int array[26], i ;
for ( i = 0 ; i <= 25 ; i++ )
{
array[i] = 'A' + i ;
printf ( "\n%d %c", array[i], array[i] ) ;
}
}

Potrebbero piacerti anche