Skip to main content

Qbasic Programs for Class 9 & 10

1. WAP to input any number and display the factors.
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END
USING SUB PROCEDURE
DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END
SUB FACT (N)
PRINT "FACTORS OF"; N; "=";
FOR I = 1 TO N
IF N MOD I = 0 THEN PRINT I;
NEXT I
END SUB




2. WAP to input any number and display the prime factors.
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "PRIME FACTORS OF"; N; "=";
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF N MOD I = 0 AND C = 2 THEN PRINT I;
NEXT I
END
USING SUB PROCEDURE
DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END
SUB FACT (N)
PRINT "PRIME FACTORS OF"; N; "=";
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF N MOD I = 0 AND C = 2 THEN PRINT I;
NEXT I
END SUB
3. WAP to input any number and find sum of factors.
CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END
USING SUB PROCEDURE
DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END
SUB FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
PRINT "SUM OF FACTORS="; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "SUM OF FACTORS=";  FACT (N)
END
FUNCTION FACT (N)
S = 0
FOR I = 1 TO N
IF N MOD I = 0 THEN S = S + I
NEXT I
FACT = S
END FUNCTION
4. WAP to input any number and display the factorial of a given number.
CLS
INPUT "ENTER ANY NUMBER"; N
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END
USING SUB PROCEDURE
DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END
SUB FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
PRINT "FACTORIAL ="; F
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "FACTORIAL ="; FACT (N)
END
FUNCTION FACT (N)
F = 1
FOR I = 1 TO N
F = F * I
NEXT I
FACT = F
END FUNCTION
5. WAP to input any number and display the prime factorial of a given number.
CLS
INPUT "ENTER ANY NUMBER"; N
F = 1
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF C = 2 THEN F = F * I
NEXT I
PRINT "PRIME FACTORIAL ="; F
END
USING SUB PROCEDURE
DECLARE SUB FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL FACT (N)
END
SUB FACT (N)
F = 1
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF C = 2 THEN F = F * I
NEXT I
PRINT "PRIME FACTORIAL ="; F
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION FACT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "PRIME FACTORIAL ="; FACT (N)
END
FUNCTION FACT (N)
F = 1
FOR I = 1 TO N
C = 0
FOR J = 1 TO I
IF I MOD J = 0 THEN C = C + 1
NEXT J
IF C = 2 THEN F = F * I
NEXT I
FACT = F
END FUNCTION

Comments

Post a Comment

Express your opinion

Popular posts from this blog

Are you Hacked ? A Cozy Guide to Online Security - Must Know

Imagine your online life like a cozy house you’ve built on the internet. You store personal items (emails, photos, bank details) inside it, invite friends and family to visit (social media), and even shop for new items right from your living room (e-commerce). The problem? Hackers are lurking around, trying to sneak in when you’re not looking! Just like you’d lock your front door and install a security camera, you can take simple steps to protect your digital home. In this blog, we’ll walk through some friendly, easy-to-understand methods to keep hackers at bay.  Let’s get started! 1. Check If Your Information Is Out There What This Means Have you ever wondered if someone has your password? Or if your email was part of a major data breach? Tools like Have I Been Pwned , Pentester   can instantly check if your email address or password has been leaked during a hack. Why It’s Important If your credentials are floating around the internet, you’ll want to change those passwords im...

Quantum Computing Trends - 2023

 Introduction Quantum computing stands on the brink of a revolution. This emerging technology, harnessing the principles of quantum mechanics, promises to transform computation by performing complex tasks much faster than current classical computers. In 2023, we witness quantum computing evolving from theoretical constructs to practical, scalable technologies with broad applications in various sectors. Background Study The study of quantum computing has been marked by significant milestones. Initially dominated by theoretical studies and small-scale experimental setups, the field has seen rapid advancements in hardware, software, and algorithm development. Major tech companies and research institutions have been key players in driving these innovations, leading to an increasingly diverse and competitive landscape. Current State and Trends in Quantum Computing IBM's Pioneering Efforts: IBM has been instrumental in advancing superconducting qubits technology. After unveiling a 127-qu...

Android vs iPhone Security: Why No System is 100% Secure

When I went to the CYBERUS Spring School in early April 2025 (April 7–11, 2025, at Université Bretagne Sud in Lorient, France), one of the topics we talked about was the age old query: Which phone is safer, the  iPhone or the  Android ? The conversations were instructive to me as a security enthusiast. We discussed technical ideas like mobile app sandboxing and even how two apps from the same developer could access data in spite of platform security measures. The discussions underlined an important realization I've had over the years: while IOS and Android both have robust security mechanisms, neither is completely impenetrable. In this essay, I'll provide a professional (but hopefully easy-to-read) analysis of Android vs iPhone security, interspersed with my own viewpoints, demonstrating why no system can claim perfect security. Security by Design: IOS and Android Approaches Apple's IOS and Google's Android have fundamentally different approa...