Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Structure in C++ programming language

Posted on October 13, 2017June 28, 2020

"<yoastmark

Table of Contents

  • Structure in C++ programming language
    • Related

Structure in C++ programming language

In this tutorial, we will discuss the concept of Structure in C++programming language

In the C++ programming language, the structure is a collection of a variety of different data types under a single unit with a name.

 

How to declare a structure

The struct keyword defines a structure in the name of the structure. Then we can declare  one or more data members inside the curly braces  of the structure

Syntax

"<yoastmark

Example

"<yoastmark

struct – it is a keyword in C++
student – structure name
The structure student is defined. It has four members for access data,  name, age, marks and average      

Always use structure to end a declaration with a semicolon(;)


Program 1

"<yoastmark

When the above program is executed, it produces the following results


Enter name :
Kamalraj
Enter student id :
12
Enter age :
23
Enter payment :
600
Student information
...............................
Student Name : Kamalraj
Student age : 23
Student id : 12
Student marks : 70
Student payment : 600
In this program, first, variables name, age, marks and pay are declared inside the student structure
Then the user is asked to enter the name, age, pay and marks of a student inside the main() function and it is stored in their variables
Finally, student information is displayed on the screen

Program 2


"<yoastmark



When the above program is executed, it produces the following result.


rahulan Emp no is: 123
rahulan sex is: m
samanthy Emp no is: 234
Samantha sex is: f

 

Related post

Structure in C Language                                           
Structure with function in C Language 
 Structure with the pointer in C Language      Structure with the pointer in C++
 Structure with function C++ Language     Nested Structure in C Language

Related

Recent Posts

  • Multiply two numbers in Java using scanner| 5 different ways
  • 5 different ways to Divide two numbers in Java using scanner
  • Learn 8 Ways to Subtract Two Numbers Using Methods in Java
  • 10 ways to subtract two numbers in Java
  • Java Code Examples – Multiply Two Numbers in 5 Easy Ways
  • How to Divide two numbers in Java| 5 different ways

tag

Addition (8) Array (38) C++ language (91) C language (98) c sharp (23) Division (8) Function (29) if else (32) Java language (108) JavaScript (5) loops (138) Multiply (8) Oop (2) patterns (66) PHP (13) Python Language (38) Subtraction (9) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2026 Code for Java c | Powered by SuperbThemes