Thi Sweek C
Thi Sweek C
14/11/24
AIM:
Question:1
Source code:
#include<stdio.h>
int CubeNum(number)
{return number*number*number;}
void main()
{int n;
scanf("%d",&n);
int result=CubeNum(n);
Output:
Question:2
Source code:
#include<stdio.h>
int factNum(int n)
{int fact=1,i;
for (i=1;i<=n;i++)
{fact=i*fact;}
return fact;}
void main()
{int n,result,j,sum=0;
scanf("%d",&n);
for(j=1;j<=n;j++)
{sum+=factNum(j)/j;}
Output:
Question:3
Source code:
#include<stdio.h>
int PrimeNum(int n)
{if (n <= 1) {
return 0; }
if (n % i == 0) {
return 0; }}
return 1;}
void main()
{int n, result;
scanf("%d", &n);
result = PrimeNum(n);
if (result == 1) {
else
Output:
Question:4
Source code:
include <stdio.h>
#include <math.h>
int checkArmstrong(int n) {
int original = n;
int sum = 0;
int digits = 0;
while (n != 0) {
n /= 10;
digits++;}
n = original;
while (n != 0) {
n /= 10;}
int checkPerfect(int n) {
int sum = 0;
if (n % i == 0) {
sum += i;}}
return (sum == n) ? 1 : 0;
}
void main(){
int n;
scanf("%d", &n);
if (checkArmstrong(n)) {
} else {
if (checkPerfect(n)) {
} else {
Output:
Question:5
check the perfect number and print the numbers (note: Not return any value)
Source code:
Output:
Question:6
Input three numbers from user and find maximum and minimum of the given
Source code:
Output:
Question:7
Source code:
Output:
Question:8
Input radius of circle from user and find diameter, circumference and area of the
Source code:
Output:
Question:9
Find the factorial and Fibonacci series of the number using function
Fact()
Fibo()
Source code:
Output:
Question:10
Read the number from the user and find number of digits, sum of digits and
NumDigi()
SumDigi()
ReverseDigi()
Source code:
Output: