Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

Student Structure Program in C

Student Structure Program in C

✅ Student Details using Structure in C

#include <stdio.h>

struct student {
    char name[20];
    int roll;
    float marks;
};

int main() {
    struct student s;

    printf("=== ENTER STUDENT DETAILS ===\n");
    printf("Enter the name of the student:\n");
    scanf(" %[^\n]", s.name);  // Accepts spaces

    printf("Roll Number of the student:\n");
    scanf("%d", &s.roll);

    printf("Enter marks of the student:\n");
    scanf("%f", &s.marks);

    printf("\n=== STUDENT DETAILS ===\n");
    printf("Name: %s\n", s.name);
    printf("Roll Number: %d\n", s.roll);
    printf("Marks: %.2f\n", s.marks);

    return 0;
}
  

πŸ“˜ Explanation:

This C program uses a structure to store and print details of a student. The structure contains three members: name (string), roll (integer), and marks (float). The program takes input using scanf, including a method to accept strings with spaces, and then displays the data using printf. This example introduces basic use of structures, string input handling, and formatted output.

🧾 Sample Output:

=== ENTER STUDENT DETAILS ===
Enter the name of the student:
John Doe
Roll Number of the student:
101
Enter marks of the student:
87.5

=== STUDENT DETAILS ===
Name: John Doe
Roll Number: 101
Marks: 87.50
  

πŸ”‘ Keywords:

Structure in C, student data structure, scanf with spaces, display student info, C program using struct, formatted output, beginner C example

πŸ“Œ Hashtags:

#CProgramming #StructuresInC #StudentDetails #BeginnerC #PrintfScanf #CProjects #LearnC

Comments

πŸŒ™