C++ declaration / Basic element in C++

With help of necessary components or element we construct or write C++ program. Elements or components are also given in the terms of token. Token: - it is an individual element which is used to construct a program. 1. Character set: - Alphabet Character: - Upper case: - [ A – Z ] = [... Continue Reading →

Advertisements

26. Write a program to find whether a number is even or odd by using nested switch case?

#include<iostream.h> #include<conio.h> void main() {                 int a,b;                 clrscr();                 cout<<"Enter A Number :- ";                 cin>>a;                 switch(a)                                 {                                 case 0:                                                 cout<<"The Number Is Even";                                                 break;                                 default:                                                 b=a%2;                                                 if(b<0)                                                                 {                                                                 b=-b;                                                                 }                                                 switch(b)                                                                 {                                                                 case 0:                                                                                 cout<<"The Number is... Continue Reading →

25. Write a program to perform arithmetic operation over two variables?

A. #include<iostream.h> #include<conio.h> void main() {                 int a,b;                 char ch;                 clrscr();                 cout<<"Enter The Arithmetic Operator :- ";                 cin>>ch;                 cout<<"Enter The Value of A & B : \n";                 cin>>a>>b;                 switch(ch)                                 {                                 case '+':                                                 cout<<"The Addition = "<<a+b;                                                 break;                                 case '-':                                                 cout<<"The  Subtraction... Continue Reading →

65) An example of opening a file for output?

A. #include<iostream.h> #include<fstream.h> #include<conio.h> void main() {                 char name[20];                 int age;                 clrscr();                 ofstream outfile("Test.txt");                 cout<<"Enter Name - ";                 cin>>name;                 cout<<"Enter Age - ";                 cin>>age;                 outfile<<name<<"\t"<<age;                 outfile.close();                 getch(); } B. #include<iostream.h> #include<fstream.h> #include<conio.h> void main() {                 char name[20];                 int age;                 clrscr();                ... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: