Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
104 views
in Control Statements by (29.8k points)
closed by

Write a program to do the following:

1. Inputs the values for variables ‘n’ and ‘m’. 

2. Prints the numbers between ‘m’ and ‘n’ which are exactly divisible by ‘m’. 

3. Checks whether the numbers divisible by ‘m’ are odd or even.

OR

Write a program using nested loop that inputs a number ‘n’ which generates an output as follows. Hint: if the value of ‘n’ is 5, the output will be as ‘n’

1 Answer

+1 vote
by (29.6k points)
selected by
 
Best answer

1. 

25 

25 16 

25 16 9 

25 16 9 4 

25 16 9 4 1

2.

#include<iostream.h>

#include<conio.h>

void main() 

clrscr(); 

int i,n,m; 

cout<<“Enter values for n and m”;

cin>>n>>m; 

for(i=1;i<=n;i++) 

if(i%m == 0)

cout<<i<<",";

getch();

 } 

3.

#include<iostream.h>

#include<conio.h>

void main() 

clrscr(); 

int i,n,m; 

cout<<“Enter values for n and m”;

cin>>n>>m; 

for(i=1;i<=n;i++) 

if(i%m == 0)

{

cout<<i<<"\t";

if(i%2 == 0)

cout<<"even"<<endl;

else

cout<<"odd"<<endl;

}

getch();

 } 

OR

#include<iostream.h>

 #include<conio.h> 

#include<string.h>//for strlen() 

main() 

{

clrscr(); 

int n,i,j; 

cout<<"enter a value for n:";

cin>>n; 

for(i=n;i>0;i- -)

for(j=n;j>=i;j~) 

cout<<j x j<<"\t";

cout<<endl;

}

getch();

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

...