Answers for "c structs"

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
3

struct

#include <stdio.h>

main () {
	struct person {
		char[] name;
		int age;
	}
}
Posted by: Guest on November-28-2020
0

struct in c

// dichiarazione della struct
struct libro
{
  char titolo[100];
  char autore[50];
  int anno_pubblicazione;
  float prezzo;
};

//dichiarazione dell'istanza biblio
struct libro biblio;
Posted by: Guest on April-19-2021
0

how to put a structure into a structure in c

#include <stdio.h>
#include <string.h>
 
struct student_college_detail
{
    int college_id;
    char college_name[50];
};
 
struct student_detail 
{
    int id;
    char name[20];
    float percentage;
    // structure within structure
    struct student_college_detail clg_data;
}stu_data;
 
int main() 
{
    struct student_detail stu_data = {1, "Raju", 90.5, 71145,
                                       "Anna University"};
    printf(" Id is: %d n", stu_data.id);
    printf(" Name is: %s n", stu_data.name);
    printf(" Percentage is: %f nn", stu_data.percentage);
 
    printf(" College Id is: %d n", 
                    stu_data.clg_data.college_id);
    printf(" College Name is: %s n", 
                    stu_data.clg_data.college_name);
    return 0;
}
Posted by: Guest on March-02-2020

Code answers related to "C"

Browse Popular Code Answers by Language