+ 1
Can anyone plz tll while displaying ch why it gives the output as. A
#include<iostream> using namespace std; int main() { int a=32,*x=&a; char ch=65,&eco=ch; *x+=ch; cout<<a<<" , "<<ch<<endl; return 0;
4 odpowiedzi
+ 1
char is a data type that holds a single character in ASCII values, which are stored as integers. When you set it to 65, it is set to A because 65 is the ASCII value of A. When you do *x += ch; it does *x += the ASCII value of A, which is 65.
+ 1
Thanks
0
#include <iostream. h>
struct dress
{ int size, cost, tax, total_cost ;
} ;
void change (dress& s, int flag =1)
{ if(flag==1)
{ s.cost +=20 ;
s. total_cost = s. cost + s. cost * s. tax/100;
}
}
void main ()
{ dress s1={40, 580, 8), s2={34,550,10} ;
change(s1) ;
cout<<s1. size<<',' <<s1. cost<<',' <<s2. total_cost;
change(s2, 2) ;
cout<<s2. size<<','<<s2.cost<<','<<s2.total_cost <<endl;
}
0
Can someone plz tell how do we handle the strings... Using this example.. And how values are allocated from string to the variables used..