Print the marks obtained by a student in five tests

Problem statement:- Program to Print the marks obtained by a student in five tests.

Data requirement:-

   Input Data:- arr

  Output Data:-arr

  Additional Data:- i

Program in C

Here is the source code of the C Program to Print the marks obtained by a student in five tests.

Code:

#include<stdio.h>
int main()
{
    int arr[ ]={95,88,77,45,69},i=0;
    printf("Marks obtained by a student in five tests are:");
    while(i<5)
    {
        printf("%d ",arr[i]);
        i++;
    }
}

Input/Output:
Marks obtained by a student in five tests are:95 88 77 45 69

Program in C++

Here is the source code of the C++ Program to Print the marks obtained by a student in five tests.

Code:

#include<iostream>
using namespace std;
int main()
{
    int arr[ ]={54,91,87,59,40},i=0;
    cout<<"Marks obtained by a student in five tests are:";
    while(i<5)
    {
        cout<<arr[i]<<" ";
        i++;
    }
}

Input/Output:
Marks obtained by a student in five tests are:54 91 87 59 40

Program in Java

Here is the source code of the Java Program to Print the marks obtained by a student in five tests.

Code:

public class p1 {
public static void main(String[] args) {
int arr[ ]={95,88,77,45,69},i=0;
System.out.print("Marks obtained by a student in five tests are:");
    while(i<5)
    {
       System.out.print(arr[i]+" ");
        i++;
    }
}
}

Input/Output:
Marks obtained by a student in five tests are:95 88 77 45 69 

Program in Python

Here is the source code of the Python Program to Print the marks obtained by a student in five tests.

Code:

import array
arr=array.array('i', [95,88,77,45,69])
print("Marks obtained by a student in five tests are:")
for i in range(0,5):
    print(arr[i],end=" ")

Input/Output:
Marks obtained by a student in five tests are:
95 88 77 45 69 


Post a Comment

0 Comments