what does \n and %d mean?
Here, in C programming \n is an escape character that helps to create a new line whereas %d is a format specifier that allows to specify only Integer values.
WAP to input any number and display no of odd numbers in it.
The following is a program to input any number and display no of odd numbers in it:
In JAVASCRIPT
let const num = string(prompt("Enter the number: "))
const a = typeof num
let tot_num = ""
if (a == "number") {
for (let i=0; i<num.length; i++) {
num1 = parseInt (num[i])
if (num1%2 == !0) {
tot_num += string(num1)
}
console.log(tot_num)
}
} else {
console.log("Invalid format of Input was given.")
}
Program to input any number and display number of odd numbers in it;
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
int main() {
int i, number, num1, num2=0, num3, num4 =0, rem, rem1, rem2, rev = 0;
printf("Enter your number ==> ");
scanf("%d", &number);
num1 = number;
while(num1 != 0) {
rem = num1%10;
rem1 = rem%2;
if (rem1 != 0) {
num2 = num2*10 + rem;
}
num1 /= 10;
}
num3 = num2;
while (num2 != 0) {
rem2 = num2 % 10;
rev = rev * 10 + rem2;
num2 /= 10;
num4 += 1;
}
printf("The odd numbers in your program is %d \n", rev);
printf("The number of odd numbers in your program is %d", num4);
return 0;
}