1.QBASIC PROGRAM TO PRINT EVEN NUMBERS FROM 50 TO 100
2.QBASIC PROGRAM TO PRINT EVEN NUMBERS FROM 100 TO 50
3.QBASIC PROGRAM TO PRINT ODD NUMBERS FROM 51 TO 100
Answers
Answered by
5
#include <stdio.h>
int main() {
int counter;
printf("Even numbers between 50 to 100\n");
/*
* Initialize counter with 50, and increment it in every iteration.
* For every value of counter check whether it is even number or
* not and print it accordingly
*/
for(counter = 50; counter <= 100; counter++) {
/* Even numbers are divisible by 2 */
if(counter%2 == 0) {
/* counter is even, print it */
printf("%d ", counter);
}
}
return 0;
}
3rd program
____________________
#include <stdio.h>
int main() {
int counter;
printf("Odd numbers between 51 to 100\n");
/*
* Initialize counter with 51, and increment it in every iteration.
* For every value of counter check whether it is odd number or
* not and print it accordingly
*/
for(counter = 51; counter <= 100; counter++) {
/* Odd numbers are not divisible by 2. When an Odd
number is divided by 2, it leaves 1 as remainder */
if(counter%2 == 1) {
/* counter is odd, print it */
printf("%d ", counter);
}
}
return 0;
}
</stdio.h>
hope it helps u
int main() {
int counter;
printf("Even numbers between 50 to 100\n");
/*
* Initialize counter with 50, and increment it in every iteration.
* For every value of counter check whether it is even number or
* not and print it accordingly
*/
for(counter = 50; counter <= 100; counter++) {
/* Even numbers are divisible by 2 */
if(counter%2 == 0) {
/* counter is even, print it */
printf("%d ", counter);
}
}
return 0;
}
3rd program
____________________
#include <stdio.h>
int main() {
int counter;
printf("Odd numbers between 51 to 100\n");
/*
* Initialize counter with 51, and increment it in every iteration.
* For every value of counter check whether it is odd number or
* not and print it accordingly
*/
for(counter = 51; counter <= 100; counter++) {
/* Odd numbers are not divisible by 2. When an Odd
number is divided by 2, it leaves 1 as remainder */
if(counter%2 == 1) {
/* counter is odd, print it */
printf("%d ", counter);
}
}
return 0;
}
</stdio.h>
hope it helps u
rajdasmunshi005:
CAN U PLEASE WRITE IT IN SEQUENCE OF 1. 2. AND 3.
Answered by
10
This is the answer. If it is wrong tell me
Attachments:
Similar questions