C Program to Store Information of Single Variable.

#include <stdio.h>
struct student{
    char name[50];
    int roll;
    float marks;
};
int main(){
    struct student s;
    printf("Enter information of students:\n\n");
    printf("Enter name: ");
    scanf("%s",s.name);
    printf("Enter roll number: ");
    scanf("%d",&s.roll);
    printf("Enter marks: ");
    scanf("%f",&s.marks);
    printf("\nDisplaying Information\n");
    printf("Name: %s\n",s.name);
    printf("Roll: %d\n",s.roll);
    printf("Marks: %.2f\n",s.marks);
    return 0;
}
Expected Output:
Enter information of students:

Enter name: Adele
Enter roll number: 21
Enter marks: 334.5

Displaying Information
name: Adele
Roll: 21
Marks: 334.50

Post a Comment

Previous Post Next Post