Answers for "structure of a C program"

C
1

structure and function in c

#include <stdio.h>
#include <string.h>
 
struct student 
{
           int id;
           char name[20];
           float percentage;
};
 
void func(struct student *record);
 
int main() 
{
          struct student record;
 
          record.id=1;
          strcpy(record.name, "Raju");
          record.percentage = 86.5;
 
          func(&record);
          return 0;
}
 
void func(struct student *record)
{
          printf(" Id is: %d n", record->id);
          printf(" Name is: %s n", record->name);
          printf(" Percentage is: %f n", record->percentage);
}
Posted by: Guest on July-27-2020
1

C program structure

pre-processor directives
global declarations

main()
{
    local variable deceleration
    statement sequences
    function invoking
}
Posted by: Guest on August-28-2021
0

structure and function in c

#include <stdio.h>
#include <string.h>
 
struct student 
{
            int id;
            char name[20];
            float percentage;
};
struct student record; // Global declaration of structure
 
void structure_demo();
 
int main() 
{
            record.id=1;
            strcpy(record.name, "Raju");
            record.percentage = 86.5;
 
            structure_demo();
            return 0;
}
 
void structure_demo()
{
            printf(" Id is: %d n", record.id);
            printf(" Name is: %s n", record.name);
            printf(" Percentage is: %f n", record.percentage);
}
Posted by: Guest on July-27-2020

Code answers related to "C"

Browse Popular Code Answers by Language