Prepare for your Next Interview
This is a discussion on Question!!! within the C and C++ forums, part of the Software Development category; I hav another question wanna ask..... The question is as below: Write a program that contains 2 arrays which contained name and age Name Age Rose 8 Jack 13 Jin ...
|
|||
|
I hav another question wanna ask..... The question is as below:
Write a program that contains 2 arrays which contained name and age Name Age Rose 8 Jack 13 Jin 20 Katty 34 1st array stored the names and 2nd array stored the age. classify them into children, teenagers and adult according 2 age. The output(name,age,classification)are to be saved in an output file. thanks a lot.... ![]() |
| Sponsored Links |
|
|||
|
Re: Question!!!
#include<stdio.h>
main() { int num[10],i,n,child,teenager,adult,name; clrscr(); printf("How many elements?"); scanf("%d",&n); printf("\nEnter %s and %d=",name,n); for(i=0;i<n;i++) scanf("%d",&num[i]); adult=num[0]; for(i=0;i<n;i++) { if(num[i]>adult) adult=num[i]; } second=-999 for(i=0;i<n;i++) { if(num[i]!=adult) if(num[i]>teenager) teenager=num[i] else child=num[i]; } printf("\nAdult=%d",adult); printf("\nTeenage=%d",teenager); printf("\nchild=%d",child); getch(): } |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| asp question | shimulpaul | ASP.NET | 8 | 1 Week Ago 11:54 PM |
| question | sumerram | Interviews | 6 | 09-01-2008 11:01 PM |
| php question | sunilkumar_godd | PHP | 1 | 08-21-2008 05:55 AM |
| EIM Question | dravikumar23 | Seibel | 0 | 08-15-2008 08:35 AM |
| Question | shitalpatil | Brainteasers | 3 | 03-08-2007 07:32 AM |