Answers for "what is a structure in c"

C
27

struct in C

#include<stdio.h>
#include<string.h>

struct Student{
long int rollNo;
int age;
char name[50];
int totalMarks;
};

int main(){

    struct Student s1;
    //accessing members of the struct
    s1.rollNo = 1232234643;
    s1.age = 10;
    char s[]="Jonathan";
    strcpy(s1.name,s);
    s1.totalMarks = 450;

    printf("RollNumber: %d nName: %s nTotal Marks: %d",s1.rollNo,s1.name,s1.totalMarks);

return 0;
}
Posted by: Guest on June-04-2020
0

Structures in C

#include <stdio.h>
struct date 
{
        int day;
        int month;
        int year;
};
int main(void)
{
    struct date today;
    today.day = 1;
    today.month = 1;
    today.year = 2003;
    if (today.day==1 && today.month==1)
        printf(“Happy New year");
    return 0;
}
Posted by: Guest on November-24-2021

Code answers related to "C"

Browse Popular Code Answers by Language