02 February 2022

Arryas With Pointers

Arrays Input With the Help Of  Pointers --->

#include<stdio.h>
 
int main()
{
    int marks[4];
    int *ptr;
    ptr = &marks[0];

    for(int i=0; i<4; i++){
        printf("Enter the marks for student %d :\n", i+1);
        scanf("%d", ptr);
        ptr++;
    }

    for(int i=0; i<4; i++){
        printf("The marks of student %d is : %d\n", i+1, marks[i]);
           
    }
 
return 0;
}

OUTPUT--->

Enter the marks for student 1 : 98 Enter the marks for student 2 : 69 Enter the marks for student 3 : 89 Enter the marks for student 4 : 97
The marks of student 1 is : 98 The marks of student 2 is : 69 The marks of student 3 is : 89 The marks of student 4 is : 97



No comments:

Post a Comment