Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

write a complete program which initializes part of an array of integer.docx

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité

Consultez-les par la suite

1 sur 2 Publicité

write a complete program which initializes part of an array of integer.docx

Télécharger pour lire hors ligne

write a complete program which initializes part of an array of integer grades at the time of its declaration with 6 values and then calls a function to find, return, and print the highest grade.
Solution
Grades.c
#include <stdio.h>
int find(int grades[]);
int main()
{
int grades[6];
for(int i=0; i<6; i++){
printf(\"Enter Integer Grade : \ \");
scanf(\"%d\", &grades[i]);
}
int maxGrade = find(grades);
printf(\"The Maximum Grade is %d \",maxGrade);
return 0;
}
int find(int grades[]){
int max = 0;
for(int i=0; i<6; i++){
if(max < grades[i])
max = grades[i];
}
return max;
}
Output:
Enter Integer Grade :
87
Enter Integer Grade :
65
Enter Integer Grade :
45
Enter Integer Grade :
34
Enter Integer Grade :
87
Enter Integer Grade :
56
The Maximum Grade is 87
.

write a complete program which initializes part of an array of integer grades at the time of its declaration with 6 values and then calls a function to find, return, and print the highest grade.
Solution
Grades.c
#include <stdio.h>
int find(int grades[]);
int main()
{
int grades[6];
for(int i=0; i<6; i++){
printf(\"Enter Integer Grade : \ \");
scanf(\"%d\", &grades[i]);
}
int maxGrade = find(grades);
printf(\"The Maximum Grade is %d \",maxGrade);
return 0;
}
int find(int grades[]){
int max = 0;
for(int i=0; i<6; i++){
if(max < grades[i])
max = grades[i];
}
return max;
}
Output:
Enter Integer Grade :
87
Enter Integer Grade :
65
Enter Integer Grade :
45
Enter Integer Grade :
34
Enter Integer Grade :
87
Enter Integer Grade :
56
The Maximum Grade is 87
.

Publicité
Publicité

Plus De Contenu Connexe

Plus par lez31palka (20)

Plus récents (20)

Publicité

write a complete program which initializes part of an array of integer.docx

  1. 1. write a complete program which initializes part of an array of integer grades at the time of its declaration with 6 values and then calls a function to find, return, and print the highest grade. Solution Grades.c #include <stdio.h> int find(int grades[]); int main() { int grades[6]; for(int i=0; i<6; i++){ printf("Enter Integer Grade : "); scanf("%d", &grades[i]); } int maxGrade = find(grades); printf("The Maximum Grade is %d ",maxGrade); return 0; } int find(int grades[]){ int max = 0; for(int i=0; i<6; i++){ if(max < grades[i]) max = grades[i]; } return max; } Output: Enter Integer Grade : 87 Enter Integer Grade :
  2. 2. 65 Enter Integer Grade : 45 Enter Integer Grade : 34 Enter Integer Grade : 87 Enter Integer Grade : 56 The Maximum Grade is 87

×