24. Write a program to show the output with dangling else?

#include<iostream.h> #include<conio.h> void main() {                 int i=20;                 clrscr();                 if(i>10)                                 if(i!=20)                                                 cout<<" I is Not Equal To 20";                                 else                                                 cout<<" I Holds 20 ";                 getch(); }


23. Write a program to check whether a number entered is integer or float?

#include<iostream.h> #include<conio.h> void main() {                 float f;                 int i;                 clrscr();                 cout<<"Enter A Number :- ";                 cin>>f;                 i=(int)f;                 cout<<endl;                 if(f==i)                                 {                                 cout<<i<<" Number is Integer ";                                 }                 else                                 {                                 cout<<f<<" Number is Float ";                                 }                 getch(); }

22. Write a program to calculate square of a number whose list significant digit is five or seven?

#include<iostream.h> #include<conio.h> void main() {                 int num,digit;                 clrscr();                 cout<<"Enter A Number :- ";                 cin>>num;                 digit=num%10;                 if(digit==5)                                 {                                 cout<<"The Square = "<<num*num;                                 }                 else if(digit==7)                                 {                                 cout<<"The Square = "<<num*num;                                 }                 else                                 {                                 cout<<"\n\tInvalid number";                                 }                 getch(); }

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: