Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

4) WAP that prints a multiplication table for a given number and the number of rows in the table.

Code:

#include <stdio.h>

int main() {

int number, rows;

printf("Enter the number: ");

scanf("%d", &number);

printf("Enter the number of rows: ");

scanf("%d", &rows);

for (int i = 1; i <= rows; ++i) {

printf("%d X %d = %d\n", number, i, number * i);

return 0;

Output:

emp.allowance.basic=5000;
emp.allowance.da=1000;
emp.allowance.hra=1500;
printf(" ID:%d\n Name:%s\n Dept:%s\n Age:%d\n", emp.eid,
emp.ename, emp.dept, emp.age);
printf(" Basic Salary:%d\n DA:%d\n HRA:%d\n", emp.allowance.basic,
emp.allowance.da, emp.allowance.hra);
getch();
}

5) WAP that shows the binary equivalent of a given positive number between 0 to 255.

Ans:
Code:

#include <stdio.h>

int main() {

int decimalNumber;

printf("Enter a positive number between 0 and 255: ");

scanf("%d", &decimalNumber);

if (decimalNumber < 0 || decimalNumber > 255) {

printf("Invalid input. Please enter a number between 0 and 255.\n");

} else {

printf("Binary equivalent of %d: ", decimalNumber);

for (int i = 7; i >= 0; --i) {

int bit = (decimalNumber >> i) & 1;

printf("%d", bit);

printf("\n");

return 0;

Output:

You might also like