Untitled Document - Merged
Untitled Document - Merged
C PROGRAM
ENGLISH
SUBJECT: CYOGA (MATH)
ASSIGNMENT
PROGRAMMING (1)
REGISTRATION NO : 233002410591
DEPARTMENT NAME: BSC (IT) CYBER SECURITY
YEAR: 1st Year
SEMESTER: 1
DATE OF SUBMISSION:
1. PRINT HELLO WORLD
#include <stdio.h>
int main() {
printf("Hello world");
return 0;
}
OUT PUT :
Hello world
#include <stdio.h>
int main() {
int a=2,b=3,s=0;
s=a+b;
return 0;
}
OUT PUT :
int main() {
int a,b,n;
printf("how much number of sum you want :");
scanf("%d",&n);
for (a=1;a<=n;a++)
{
b=b+a;
}
int main() {
int a,b,n,g;
printf("How much number of sum you want :");
scanf("%d",&n);
for (a=1;a<=n;a++)
{
g=a;
if (g%2==0)
{
b=b+a;
}
return 0;
}
OUT PUT :
How much number of sum you want :10
The sum of n number is 30
5. SUM OF ODD NUMBERS
#include <stdio.h>
int main() {
int a,b,n,g;
printf("how much number of sum you want :");
scanf("%d",&n);
for (a=1;a<=n;a++)
{
g=a;
if (g%2==!0)
{
b=b+a;
}
return 0;
}
OUT PUT:
how much number of sum you want :10
the sum of n number is 25
6. EVALUATION OF THE PROVIDED FACTORIAL NUMBER
#include <stdio.h>
int main() {
int a,b=1,n,g;
printf("enter your number :");
scanf("%d",&n);
for (a=1;a<=n;a++)
{
b=b*a;
}
return 0;
}
OUT PUT :
Enter your number 4
the factoryeal of n number is 24
#include <stdio.h>
int main() {
int num, digit, sum = 0;
printf("Enter a number: ");
scanf("%d", &num);
while (num != 0) {
digit = num % 10;
sum += digit;
num /= 10;
}
return 0;
}
OUT PUT :
Enter a number: 234
Sum of digits: 9
8.AREA OF A TRIANGLE
#include <stdio.h>
int main() {
float base, height, area;
return 0;
}
OUT PUT:
Enter the base of the triangle: 4
Enter the height of the triangle: 5
Area of the triangle: 10.00