+ 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;

18th Jan 2018, 3:48 PM
stuti
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.
18th Jan 2018, 5:04 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 1
Thanks
18th Jan 2018, 5:15 PM
stuti
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; }
22nd Mar 2018, 8:23 AM
stuti
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..
22nd Mar 2018, 8:24 AM
stuti