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

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

1 Answers   HCL,


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

0 Answers   Student,


3) Int Matrix of certain size was given, We had few valu= es in it like this. =97=97=97=97=97=97=97=97=97=97=97 1 = | 4 | | 5 | &= nbsp; | 45 =97=97=97=97=97=97=97=97=97=97=97 &n= bsp; | 3 | 3 | 5 | = | 4 =97=97=97=97=97=97=97=97=97=97=97 34 |&nbs= p; 3 | 3 | | 12 | &= nbsp; =97=97=97=97=97=97=97=97=97=97=97 3 | &nbs= p; | 3 | 4 | = | 3 =97=97=97=97=97=97=97=97=97=97=97 3 | = ; | | | = ; 3 | =97=97=97=97=97=97=97=97=97=97=97 &= nbsp; | | 4 | = ; | 4 | 3 We w= ere supposed to move back all the spaces in it at the end. Note: = If implemented this prog using recursion, would get higher preference.

0 Answers   RoboSoft,


main() { clrscr(); } clrscr();

2 Answers  


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }

3 Answers   Hexaware,






create a login program that ask username and password. if you input username or password 3 times wrong, the program will terminate else the program will prompt a message "congratulations"

2 Answers  


What are the files which are automatically opened when a C file is executed?

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  


#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }

0 Answers  


main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,


main() { char str1[] = {‘s’,’o’,’m’,’e’}; char str2[] = {‘s’,’o’,’m’,’e’,’\0’}; while (strcmp(str1,str2)) printf(“Strings are not equal\n”); }

1 Answers  


void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }

1 Answers  


Categories