Tag Archives: Struct

Problem 85: Product

Create a structure named Product with following two fields-

1. name (string)
2. price (double)

Then create a function named printProductInfo() which takes a parameter of Product type and print the information of that Product. Finally, in main function create a variable of structure Product named myProduct and call the printProductInfo() function passing myProduct as the parameter.
code:

 

Struct Problem 1: 101cproblems

Problem 81: Struct GPA

Create a simple structure named Student that holds the following variables-
i. id (integer)
ii. cgpa (float)
iii. name (string)
Now create an instance of that structure named s1 and scan the values from the user. Finally print the id, cgpa and name which user entered.

code:

Source:http://101cproblems.com/problem-81/

Another approach:

 

Use Pointer with Struct

code: