Answer to Question #5307 in C++ for anum

Question #5307
write a program which takes the names of5 students(anum,effat,anila,faiza,fiza).store them in an ar ray.now disp[lay the name of the student which have minimum length?
1
Expert's answer
2011-11-25T11:00:23-0500
// StudentName.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "conio.h"
#include <iostream>
#include "string"
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
string st[5];
st[0]="anum";
st[1]="effat";
st[2]="anila";
st[3]="faiza";
st[4]="fiza";
int min=st[0].length();
int number=0;
for(int i=0;i<5;i++){
if(st[i].length()<min){
min=st[i].length();
number+=i;
}
}
cout<<st[number];
getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS