Practices AssignmentC++ : Structures
Item S[4]= {{1,”Bread”,11.0,20},{2, “Butter”,25.0,40},{3,”Cream”,65,15},{4,”Jam”,95.5,20}};cout<<S[0].I_no;cout<<S[1].I_name[4];cout<<S[2].I_qty;cout<<S[3].I_name;}
(d)
Find the output of the following program:
3#include <iostream.h>struct GAME{ int Score;int Bonus;};void Play(GAME &g, int N=10){g.Score++;g.Bonus+=N;}void main(){GAME G={110,50};Play(G,10);cout<<G.Score<<":"<<G.Bonus<<endl;Play(G);cout<<G.Score<<":"<<G.Bonus<<endl;Play(G,15);cout<<G.Score<<":"<<G.Bonus<<endl;}
(e)
Rewrite the following program after removing all syntactical error(s), if any. Underline each correction.#include<iostream.h>int main(){structure student{int. rno, mark;}stu;student stuA= (1001,49);student stuB= stuA;if (stuA!= stuB)stuA.mark= 55;elsestuB.mark= 25;cout<<stuA.mark<<stub.mark;(2)
Submitted By : Nita aroraKHMS
Add a Comment