Write a program that reads a dynamic array of 40
integers and displays only even integers

Answers were Sorted based on User's Feedback



Write a program that reads a dynamic array of 40 integers and displays only even integers..

Answer / guest

logic is:


for(i=0;i<40;i++)
{
if(a[i]%2==0)

{
printf("%d",a[i]);
}

}

Is This Answer Correct ?    3 Yes 1 No

Write a program that reads a dynamic array of 40 integers and displays only even integers..

Answer / mohammedayub.y(c.i.e.t)

#include<stdio.h>
#include<conio.h>
void main()
{
int Array[40],i;
printf("Enter the array elements one by one:\n");
for(i=0;i<40;i++)
{
scanf("%d",&Array[i]);
}
printf("The even integers are:\n");
for(i=0;i<40;i++)
{
if(Array[i]%2==0) printf("%d\n",Array[i]);
}
getch();
}

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers   CSC,


main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } } a. OK I am done b. OK I am gone c. compile error d. none of the above

3 Answers   HCL,


write a c program to print magic square of order n when n>3 and n is odd?

1 Answers   HCL,


void main() { if(~0 == (unsigned int)-1) printf(“You can answer this if you know how values are represented in memory”); }

1 Answers  


main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }

1 Answers  






void main() { int const * p=5; printf("%d",++(*p)); }

3 Answers   Infosys, Made Easy, State Bank Of India SBI,


Write a program to receive an integer and find its octal equivalent?

7 Answers  


union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


main() { char *p; p="Hello"; printf("%c\n",*&*p); }

1 Answers  


Print an integer using only putchar. Try doing it without using extra storage.

2 Answers  


String copy logic in one line.

11 Answers   Microsoft, NetApp,


Categories