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

print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!

35 Answers   Tata Elxsi, TCS, VI eTrans,


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


how can u draw a rectangle in C

53 Answers   Accenture, CO, Codeblocks, Cognizant, HCL, Oracle, Punjab National Bank, SAP Labs, TCS, University, Wipro,


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

11 Answers   Wipro,


void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit=--giveit); }

1 Answers  






How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.

2 Answers  


main() { int x=5; clrscr(); for(;x<= 0;x--) { printf("x=%d ", x--); } } a. 5, 3, 1 b. 5, 2, 1, c. 5, 3, 1, -1, 3 d. –3, -1, 1, 3, 5

2 Answers   HCL,


main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }

2 Answers  


main() { char *str1="abcd"; char str2[]="abcd"; printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd")); }

1 Answers  


#include <stdio.h> int main(void) { int a=4, b=2; a=b<<a+b>>2 ; printf("%d",a); return 0; }

0 Answers   Student,


What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }

1 Answers  


Write a program that produces these three columns sequence nos. using loop statement Sequence nos. Squared Squared + 5 1 1 6 2 4 9 3 9 14 4 16 21 5 25 30

1 Answers   GoDB,


Categories